Skip to content

Avoid ICE in From/TryFrom diagnostic under -Znext-solver#152661

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
BartSimpson001:fix-next-solver-from-ice
Feb 17, 2026
Merged

Avoid ICE in From/TryFrom diagnostic under -Znext-solver#152661
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
BartSimpson001:fix-next-solver-from-ice

Conversation

@BartSimpson001
Copy link

@BartSimpson001 BartSimpson001 commented Feb 15, 2026

Fixes #152518.

Under -Znext-solver=globally, trait_ref.args may contain fewer
elements than expected. The diagnostic logic in
fulfillment_errors.rs assumed at least two elements and
unconditionally called type_at(1), which could lead to an
index out-of-bounds panic during error reporting.

This change adds a defensive check before accessing the second
argument to avoid the ICE. A UI regression test has been added.

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Feb 15, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2026

r? @petrochenkov

rustbot has assigned @petrochenkov.
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, types
  • compiler, types expanded to 68 candidates
  • Random selection from 14 candidates

@petrochenkov
Copy link
Contributor

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 16, 2026

📌 Commit b55673b has been approved by petrochenkov

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 Feb 16, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 16, 2026
…m-ice, r=petrochenkov

Avoid ICE in From/TryFrom diagnostic under -Znext-solver

Fixes rust-lang#152518.

Under `-Znext-solver=globally`, `trait_ref.args` may contain fewer
elements than expected. The diagnostic logic in
`fulfillment_errors.rs` assumed at least two elements and
unconditionally called `type_at(1)`, which could lead to an
index out-of-bounds panic during error reporting.

This change adds a defensive check before accessing the second
argument to avoid the ICE. A UI regression test has been added.
rust-bors bot pushed a commit that referenced this pull request Feb 17, 2026
Rollup of 6 pull requests

Successful merges:

 - #145399 (Unify wording of resolve error)
 - #152512 (core: Implement feature `float_exact_integer_constants`)
 - #152661 (Avoid ICE in From/TryFrom diagnostic under -Znext-solver)
 - #152703 (Remove `rustc_query_system`)
 - #152727 (`probe_op` silence ambiguity errors if tainted)
 - #152728 (Port #![default_lib_allocator] to the new attribute parser)
rust-bors bot pushed a commit that referenced this pull request Feb 17, 2026
Rollup of 11 pull requests

Successful merges:

 - #152700 (miri subtree update)
 - #152715 (`rust-analyzer` subtree update)
 - #151783 (Implement RFC 3678: Final trait methods)
 - #152512 (core: Implement feature `float_exact_integer_constants`)
 - #152661 (Avoid ICE in From/TryFrom diagnostic under -Znext-solver)
 - #152703 (Remove `rustc_query_system`)
 - #152206 (misc doc improvements)
 - #152664 (Fix mis-constructed `file_span` when generating scraped examples)
 - #152698 (Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`)
 - #152727 (`probe_op` silence ambiguity errors if tainted)
 - #152728 (Port #![default_lib_allocator] to the new attribute parser)
@rust-bors rust-bors bot merged commit 572b53f into rust-lang:main Feb 17, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 17, 2026
rust-timer added a commit that referenced this pull request Feb 17, 2026
Rollup merge of #152661 - BartSimpson001:fix-next-solver-from-ice, r=petrochenkov

Avoid ICE in From/TryFrom diagnostic under -Znext-solver

Fixes #152518.

Under `-Znext-solver=globally`, `trait_ref.args` may contain fewer
elements than expected. The diagnostic logic in
`fulfillment_errors.rs` assumed at least two elements and
unconditionally called `type_at(1)`, which could lead to an
index out-of-bounds panic during error reporting.

This change adds a defensive check before accessing the second
argument to avoid the ICE. A UI regression test has been added.
@lqd
Copy link
Member

lqd commented Feb 17, 2026

I'll cc @rust-lang/initiative-trait-system-refactor for this workaround

Comment on lines +287 to +288
// Defensive: next-solver may produce fewer args than expected.
if trait_ref.args.len() > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't. There's a more involved underlying bug here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

though actually, this whole diagnostics looks somewhat non-sensical. If the DefId of the root goal is From or TryFrom, this doesn't tell you anything about the leaf_trait_predicate. It could be an arbitrary trait goal?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not the next-solver that produces fewer args.
The problem is that obligation, i.e. its trait def just has the fewer args(=1) here and it is ZeroablePrimitive in this case.
I'll look into why we are trying to report a fulfillment error on it.

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 18, 2026
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#152700 (miri subtree update)
 - rust-lang/rust#152715 (`rust-analyzer` subtree update)
 - rust-lang/rust#151783 (Implement RFC 3678: Final trait methods)
 - rust-lang/rust#152512 (core: Implement feature `float_exact_integer_constants`)
 - rust-lang/rust#152661 (Avoid ICE in From/TryFrom diagnostic under -Znext-solver)
 - rust-lang/rust#152703 (Remove `rustc_query_system`)
 - rust-lang/rust#152206 (misc doc improvements)
 - rust-lang/rust#152664 (Fix mis-constructed `file_span` when generating scraped examples)
 - rust-lang/rust#152698 (Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`)
 - rust-lang/rust#152727 (`probe_op` silence ambiguity errors if tainted)
 - rust-lang/rust#152728 (Port #![default_lib_allocator] to the new attribute parser)
@BartSimpson001 BartSimpson001 deleted the fix-next-solver-from-ice branch February 18, 2026 08:07
@BartSimpson001 BartSimpson001 restored the fix-next-solver-from-ice branch February 18, 2026 08:07
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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: fulfillment_errors: index out of bounds: the len is 1 but the index is 1

7 participants

Comments