Fix ICE in transmutability error reporting when type aliases are normalized#151703
Fix ICE in transmutability error reporting when type aliases are normalized#151703rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
|
rustbot has assigned @jdonszelmann. Use |
| if obligation.predicate != root_obligation.predicate { | ||
| if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(root_pred)) = | ||
| root_obligation.predicate.kind().skip_binder() | ||
| && root_pred.def_id() == trait_pred.trait_ref.def_id |
There was a problem hiding this comment.
| if obligation.predicate != root_obligation.predicate { | |
| if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(root_pred)) = | |
| root_obligation.predicate.kind().skip_binder() | |
| && root_pred.def_id() == trait_pred.trait_ref.def_id | |
| if obligation.predicate != root_obligation.predicate | |
| && let ty::PredicateKind::Clause(ty::ClauseKind::Trait(root_pred)) = | |
| root_obligation.predicate.kind().skip_binder() | |
| && root_pred.def_id() == trait_pred.trait_ref.def_id |
|
Btw, I'm curious, there is a comment If I understand this correctly, we should never reach this branch, but for some point we do, this brings me to believe that the problem occurs somewhere earlier |
|
Yes, I've thought about this too, and I tried to use root obligation check earlier to leave the to which looks incorrect to me. I've thought about this and recheck with root obligation to ensure we are dealing with same type in the |
|
Actually, It seems to be there is a better place for this check which will not cause diagnostics regression, I will deal with that tommorow |
|
I am a bit stuck in finding the right place for a check, as it will recheck after transmutability inconsistency, which is basically the same |
|
that's totally fine! thanks for getting back and explain your reasoning, that's very valuable but i'm afraid that i would not be able to dive into this because of being busy this week |
|
@zedddie where is the place you're referring to? could you factor it out into a function? |
|
In the About factoring out to a function, what comes to mind is creating a function which will check Am I on the right track? |
|
Yea, that seems reasonable, and then because it follows largely the same code path we can be reasonably sure the same cases do and don't error |
3401d79 to
6c88ef9
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
after some time away from computer I think my function is a bit unreadable, I will refactor it a bit |
6c88ef9 to
a257fb9
Compare
|
@jdonszelmann hi, can you take a look please? does it look good or I should change something? |
|
@bors r+ rollup |
…mann Fix ICE in transmutability error reporting when type aliases are normalized Fixes rust-lang#151462 Transmutability error reporting hit an ICE when type aliases were normalized for diagnostics. For example, when type `JustUnit = ()` normalizes to `()`, the check passes unexpectedly even though the original check with `JustUnit` failed. Fixed by adding a retry in the `Answer::Yes` arm that checks with the root obligation's types before panicking. The retry only occurs when the root obligation differs and is a Transmute trait predicate. Also added a test that reproduces the original ICE.
…mann Fix ICE in transmutability error reporting when type aliases are normalized Fixes rust-lang#151462 Transmutability error reporting hit an ICE when type aliases were normalized for diagnostics. For example, when type `JustUnit = ()` normalizes to `()`, the check passes unexpectedly even though the original check with `JustUnit` failed. Fixed by adding a retry in the `Answer::Yes` arm that checks with the root obligation's types before panicking. The retry only occurs when the root obligation differs and is a Transmute trait predicate. Also added a test that reproduces the original ICE.
…mann Fix ICE in transmutability error reporting when type aliases are normalized Fixes rust-lang#151462 Transmutability error reporting hit an ICE when type aliases were normalized for diagnostics. For example, when type `JustUnit = ()` normalizes to `()`, the check passes unexpectedly even though the original check with `JustUnit` failed. Fixed by adding a retry in the `Answer::Yes` arm that checks with the root obligation's types before panicking. The retry only occurs when the root obligation differs and is a Transmute trait predicate. Also added a test that reproduces the original ICE.
…uwer Rollup of 18 pull requests Successful merges: - #152799 (Subtree sync for rustc_codegen_cranelift) - #152569 (Stop using rustc_layout_scalar_valid_range_* in rustc) - #151059 (x86: support passing `u128`/`i128` to inline assembly) - #152097 (Suggest local variables for captured format args) - #152734 (Respect the `--ci` flag in more places in bootstrap) - #151703 (Fix ICE in transmutability error reporting when type aliases are normalized) - #152173 (Reflection TypeKind::FnPtr) - #152564 (Remove unnecessary closure.) - #152628 (tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)) - #152658 (compiletest: normalize stderr before SVG rendering) - #152766 (std::r#try! - avoid link to nightly docs) - #152780 (Remove some clones in deriving) - #152787 (Add a mir-opt test for alignment check generation [zero changes outside tests]) - #152790 (Fix incorrect target in aarch64-unknown-linux-gnu docs) - #152792 (Fix an ICE while checking param env shadowing on an erroneous trait impl) - #152793 (Do no add -no-pie on Windows) - #152803 (Avoid delayed-bug ICE for malformed diagnostic attrs) - #152806 (interpret: fix comment typo)
…uwer Rollup of 18 pull requests Successful merges: - #152799 (Subtree sync for rustc_codegen_cranelift) - #152814 (stdarch subtree update) - #151059 (x86: support passing `u128`/`i128` to inline assembly) - #152097 (Suggest local variables for captured format args) - #152734 (Respect the `--ci` flag in more places in bootstrap) - #151703 (Fix ICE in transmutability error reporting when type aliases are normalized) - #152173 (Reflection TypeKind::FnPtr) - #152564 (Remove unnecessary closure.) - #152628 (tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)) - #152658 (compiletest: normalize stderr before SVG rendering) - #152766 (std::r#try! - avoid link to nightly docs) - #152780 (Remove some clones in deriving) - #152787 (Add a mir-opt test for alignment check generation [zero changes outside tests]) - #152790 (Fix incorrect target in aarch64-unknown-linux-gnu docs) - #152792 (Fix an ICE while checking param env shadowing on an erroneous trait impl) - #152793 (Do no add -no-pie on Windows) - #152803 (Avoid delayed-bug ICE for malformed diagnostic attrs) - #152806 (interpret: fix comment typo)
…uwer Rollup of 18 pull requests Successful merges: - #152799 (Subtree sync for rustc_codegen_cranelift) - #152814 (stdarch subtree update) - #151059 (x86: support passing `u128`/`i128` to inline assembly) - #152097 (Suggest local variables for captured format args) - #152734 (Respect the `--ci` flag in more places in bootstrap) - #151703 (Fix ICE in transmutability error reporting when type aliases are normalized) - #152173 (Reflection TypeKind::FnPtr) - #152564 (Remove unnecessary closure.) - #152628 (tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)) - #152658 (compiletest: normalize stderr before SVG rendering) - #152766 (std::r#try! - avoid link to nightly docs) - #152780 (Remove some clones in deriving) - #152787 (Add a mir-opt test for alignment check generation [zero changes outside tests]) - #152790 (Fix incorrect target in aarch64-unknown-linux-gnu docs) - #152792 (Fix an ICE while checking param env shadowing on an erroneous trait impl) - #152793 (Do no add -no-pie on Windows) - #152803 (Avoid delayed-bug ICE for malformed diagnostic attrs) - #152806 (interpret: fix comment typo)
Rollup merge of #151703 - zedddie:fix-151462-ice, r=jdonszelmann Fix ICE in transmutability error reporting when type aliases are normalized Fixes #151462 Transmutability error reporting hit an ICE when type aliases were normalized for diagnostics. For example, when type `JustUnit = ()` normalizes to `()`, the check passes unexpectedly even though the original check with `JustUnit` failed. Fixed by adding a retry in the `Answer::Yes` arm that checks with the root obligation's types before panicking. The retry only occurs when the root obligation differs and is a Transmute trait predicate. Also added a test that reproduces the original ICE.
Fixes #151462
Transmutability error reporting hit an ICE when type aliases were normalized for diagnostics. For example, when type
JustUnit = ()normalizes to(), the check passes unexpectedly even though the original check withJustUnitfailed.Fixed by adding a retry in the
Answer::Yesarm that checks with the root obligation's types before panicking. The retry only occurs when the root obligation differs and is a Transmute trait predicate.Also added a test that reproduces the original ICE.