Skip to content

Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs - #159049

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
sjwang05:issue-158967
Jul 30, 2026
Merged

Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs#159049
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
sjwang05:issue-158967

Conversation

@sjwang05

@sjwang05 sjwang05 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

When the cast suggestion sees a where for<'a> Foo: From<&'a String> pred where Foo doesn't impl From<&'a String>, it calls skip_binder() on the main and leaf preds, giving us a type like &'a String. When we try to look for impls of From<<&'a String as Deref>::Target> for the suggestion, we see the escaping 'a and ICE.

This PR changes the skip_binder()s to no_bound_vars(). As a consequence, we skip creating the help line when the From/TryFrom bound is higher-ranked.

fixes #158967

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 10, 2026
@rustbot

rustbot commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

r? @mati865

rustbot has assigned @mati865.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 20 candidates

@rust-log-analyzer

This comment has been minimized.

@mati865

mati865 commented Jul 10, 2026

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned JonathanBrouwer and unassigned mati865 Jul 10, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Jul 24, 2026
@rustbot rustbot assigned lcnr and unassigned JonathanBrouwer Jul 24, 2026
@lcnr

lcnr commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5b4b02e has been approved by lcnr

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 29, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 29, 2026
Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs

When the cast suggestion sees a `where for<'a> Foo: From<&'a String>` pred where `Foo` doesn't `impl From<&'a String>`, it calls `skip_binder()` on the main and leaf preds, giving us a type like `&'a String`. When we try to look for impls of `From<<&'a String as Deref>::Target>` for the suggestion, we see the escaping `'a` and ICE.

This PR changes the `skip_binder()`s to `no_bound_vars()`. As a consequence, we skip creating the help line when the `From`/`TryFrom` bound is higher-ranked.

fixes rust-lang#158967
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 29, 2026
Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs

When the cast suggestion sees a `where for<'a> Foo: From<&'a String>` pred where `Foo` doesn't `impl From<&'a String>`, it calls `skip_binder()` on the main and leaf preds, giving us a type like `&'a String`. When we try to look for impls of `From<<&'a String as Deref>::Target>` for the suggestion, we see the escaping `'a` and ICE.

This PR changes the `skip_binder()`s to `no_bound_vars()`. As a consequence, we skip creating the help line when the `From`/`TryFrom` bound is higher-ranked.

fixes rust-lang#158967
rust-bors Bot pushed a commit that referenced this pull request Jul 29, 2026
Rollup of 17 pull requests

Successful merges:

 - #159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159592 (core: implement bounded random sampling)
 - #159898 (Add intrinsic-test alias and set  sample rate)
 - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`)
 - #158649 (Hermit: fix `readdir()` )
 - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs)
 - #160053 (test: add test suite for the 85681 issue)
 - #160087 (Add regression test for nested associated-type projection ICE)
 - #160090 (rustc_resolve: Further reduce mutability in resolver)
 - #160099 (Resolver: split module resolutions into local and external resolutions)
 - #160106 (Add suggestions for `must_implement_one_of`)
 - #160117 (Remove unnecessary format usage)
 - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once)
 - #160142 (bootstrap: remove use-lld config alias)
 - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N))
 - #160151 (Mark a doctest as requiring unwinding)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 29, 2026
Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs

When the cast suggestion sees a `where for<'a> Foo: From<&'a String>` pred where `Foo` doesn't `impl From<&'a String>`, it calls `skip_binder()` on the main and leaf preds, giving us a type like `&'a String`. When we try to look for impls of `From<<&'a String as Deref>::Target>` for the suggestion, we see the escaping `'a` and ICE.

This PR changes the `skip_binder()`s to `no_bound_vars()`. As a consequence, we skip creating the help line when the `From`/`TryFrom` bound is higher-ranked.

fixes rust-lang#158967
rust-bors Bot pushed a commit that referenced this pull request Jul 29, 2026
Rollup of 18 pull requests

Successful merges:

 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159592 (core: implement bounded random sampling)
 - #159898 (Add intrinsic-test alias and set  sample rate)
 - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`)
 - #158649 (Hermit: fix `readdir()` )
 - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs)
 - #160053 (test: add test suite for the 85681 issue)
 - #160087 (Add regression test for nested associated-type projection ICE)
 - #160090 (rustc_resolve: Further reduce mutability in resolver)
 - #160099 (Resolver: split module resolutions into local and external resolutions)
 - #160106 (Add suggestions for `must_implement_one_of`)
 - #160117 (Remove unnecessary format usage)
 - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once)
 - #160139 (iter: specialize Take::count using advance_by)
 - #160142 (bootstrap: remove use-lld config alias)
 - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N))
 - #160151 (Mark a doctest as requiring unwinding)
 - #160166 (Use correct feature gates for `f16`/`f128` `From` impls)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 29, 2026
Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs

When the cast suggestion sees a `where for<'a> Foo: From<&'a String>` pred where `Foo` doesn't `impl From<&'a String>`, it calls `skip_binder()` on the main and leaf preds, giving us a type like `&'a String`. When we try to look for impls of `From<<&'a String as Deref>::Target>` for the suggestion, we see the escaping `'a` and ICE.

This PR changes the `skip_binder()`s to `no_bound_vars()`. As a consequence, we skip creating the help line when the `From`/`TryFrom` bound is higher-ranked.

fixes rust-lang#158967
rust-bors Bot pushed a commit that referenced this pull request Jul 29, 2026
…uwer

Rollup of 18 pull requests

Successful merges:

 - #159898 (Add intrinsic-test alias and set  sample rate)
 - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`)
 - #158649 (Hermit: fix `readdir()` )
 - #158693 (Add type-check to offload intrinisc calls)
 - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs)
 - #159411 ([rustdoc] Correctly handle output options with --show-coverage)
 - #160053 (test: add test suite for the 85681 issue)
 - #160087 (Add regression test for nested associated-type projection ICE)
 - #160090 (rustc_resolve: Further reduce mutability in resolver)
 - #160099 (Resolver: split module resolutions into local and external resolutions)
 - #160106 (Add suggestions for `must_implement_one_of`)
 - #160117 (Remove unnecessary format usage)
 - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once)
 - #160139 (iter: specialize Take::count using advance_by)
 - #160142 (bootstrap: remove use-lld config alias)
 - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N))
 - #160151 (Mark a doctest as requiring unwinding)
 - #160166 (Use correct feature gates for `f16`/`f128` `From` impls)
rust-bors Bot pushed a commit that referenced this pull request Jul 30, 2026
Rollup of 20 pull requests

Successful merges:

 - #157669 (cfi: add diag mode support)
 - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`)
 - #158649 (Hermit: fix `readdir()` )
 - #158693 (Add type-check to offload intrinisc calls)
 - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs)
 - #159411 ([rustdoc] Correctly handle output options with --show-coverage)
 - #160053 (test: add test suite for the 85681 issue)
 - #160087 (Add regression test for nested associated-type projection ICE)
 - #160090 (rustc_resolve: Further reduce mutability in resolver)
 - #160099 (Resolver: split module resolutions into local and external resolutions)
 - #160101 (Add missing `needs-unwind` annotation to `add-spawn-hook-reentrancy-159923` test)
 - #160106 (Add suggestions for `must_implement_one_of`)
 - #160117 (Remove unnecessary format usage)
 - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once)
 - #160139 (iter: specialize Take::count using advance_by)
 - #160142 (bootstrap: remove use-lld config alias)
 - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N))
 - #160151 (Mark a doctest as requiring unwinding)
 - #160166 (Use correct feature gates for `f16`/`f128` `From` impls)
 - #160178 (Remove unused `va_start` intrinsic)
rust-bors Bot pushed a commit that referenced this pull request Jul 30, 2026
Rollup of 20 pull requests

Successful merges:

 - #157669 (cfi: add diag mode support)
 - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`)
 - #158649 (Hermit: fix `readdir()` )
 - #158693 (Add type-check to offload intrinisc calls)
 - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs)
 - #159411 ([rustdoc] Correctly handle output options with --show-coverage)
 - #160053 (test: add test suite for the 85681 issue)
 - #160087 (Add regression test for nested associated-type projection ICE)
 - #160090 (rustc_resolve: Further reduce mutability in resolver)
 - #160099 (Resolver: split module resolutions into local and external resolutions)
 - #160101 (Add missing `needs-unwind` annotation to `add-spawn-hook-reentrancy-159923` test)
 - #160106 (Add suggestions for `must_implement_one_of`)
 - #160117 (Remove unnecessary format usage)
 - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once)
 - #160139 (iter: specialize Take::count using advance_by)
 - #160142 (bootstrap: remove use-lld config alias)
 - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N))
 - #160151 (Mark a doctest as requiring unwinding)
 - #160166 (Use correct feature gates for `f16`/`f128` `From` impls)
 - #160178 (Remove unused `va_start` intrinsic)
@rust-bors
rust-bors Bot merged commit 4a525d9 into rust-lang:main Jul 30, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 30, 2026
rust-timer added a commit that referenced this pull request Jul 30, 2026
Rollup merge of #159049 - sjwang05:issue-158967, r=lcnr

Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs

When the cast suggestion sees a `where for<'a> Foo: From<&'a String>` pred where `Foo` doesn't `impl From<&'a String>`, it calls `skip_binder()` on the main and leaf preds, giving us a type like `&'a String`. When we try to look for impls of `From<<&'a String as Deref>::Target>` for the suggestion, we see the escaping `'a` and ICE.

This PR changes the `skip_binder()`s to `no_bound_vars()`. As a consequence, we skip creating the help line when the `From`/`TryFrom` bound is higher-ranked.

fixes #158967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: TraitPredicate(...) has escaping bound vars, so it cannot be wrapped in a dummy binder

6 participants