Avoid ICE in From/TryFrom diagnostic under -Znext-solver#152661
Avoid ICE in From/TryFrom diagnostic under -Znext-solver#152661rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@bors r+ |
…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.
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)
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)
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.
|
I'll cc @rust-lang/initiative-trait-system-refactor for this workaround |
| // Defensive: next-solver may produce fewer args than expected. | ||
| if trait_ref.args.len() > 1 { |
There was a problem hiding this comment.
It shouldn't. There's a more involved underlying bug here
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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)
Fixes #152518.
Under
-Znext-solver=globally,trait_ref.argsmay contain fewerelements than expected. The diagnostic logic in
fulfillment_errors.rsassumed at least two elements andunconditionally called
type_at(1), which could lead to anindex 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.