fix: Do not ICE on normalization failure of an extern static item#149210
fix: Do not ICE on normalization failure of an extern static item#149210bors merged 1 commit intorust-lang:mainfrom
Conversation
|
rustbot has assigned @jdonszelmann. Use |
| @@ -1191,7 +1191,24 @@ pub(crate) fn check_static_item<'tcx>( | |||
| let is_foreign_item = tcx.is_foreign_item(item_id); | |||
|
|
|||
| let forbid_unsized = !is_foreign_item || { | |||
There was a problem hiding this comment.
Even though it was already done this way, I quite dislike the block on the right hand side of the or. Could you rewrite this condition to be a bit clearer?
| item_ty, | ||
| &ObligationCause::dummy(), | ||
| |ty| match tcx | ||
| .try_normalize_erasing_regions(wfcx.infcx.typing_env(wfcx.param_env), ty) |
There was a problem hiding this comment.
This is an area of the compiler I'm still learning about, so I asked @BoxyUwU for her opinion to also learn from that (<3). To summarize our discussion:
Though this works the erasing_regions part is a bit awkward and probably unnecessary. It also skips some error reporting, hence we get a Result back. Though we think this probably almost never goes into the Err() case, it might be better to use wfcx.normalize instead. If there are diagnostics, it would then also emit those.
Having said that, maybe it leads to duplicate diagnostics so let me know if that works out or not.
ec630b3 to
cf46682
Compare
|
@bors r+ rollup |
Rollup of 8 pull requests Successful merges: - #147736 (Stabilize `asm_cfg`) - #148652 (Cleanup and refactor FnCtxt::report_no_match_method_error) - #149167 (skip checking supertraits in object candidate for `NormalizesTo` goal) - #149210 (fix: Do not ICE on normalization failure of an extern static item) - #149268 (add implementation-internal namespace for globalasm) - #149274 (Fix invalid link generation for type alias methods) - #149302 (Fix comment wording in simplify_comparison_integral.rs) - #149305 (Simplify OnceCell Clone impl) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - rust-lang/rust#147736 (Stabilize `asm_cfg`) - rust-lang/rust#148652 (Cleanup and refactor FnCtxt::report_no_match_method_error) - rust-lang/rust#149167 (skip checking supertraits in object candidate for `NormalizesTo` goal) - rust-lang/rust#149210 (fix: Do not ICE on normalization failure of an extern static item) - rust-lang/rust#149268 (add implementation-internal namespace for globalasm) - rust-lang/rust#149274 (Fix invalid link generation for type alias methods) - rust-lang/rust#149302 (Fix comment wording in simplify_comparison_integral.rs) - rust-lang/rust#149305 (Simplify OnceCell Clone impl) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - rust-lang/rust#147736 (Stabilize `asm_cfg`) - rust-lang/rust#148652 (Cleanup and refactor FnCtxt::report_no_match_method_error) - rust-lang/rust#149167 (skip checking supertraits in object candidate for `NormalizesTo` goal) - rust-lang/rust#149210 (fix: Do not ICE on normalization failure of an extern static item) - rust-lang/rust#149268 (add implementation-internal namespace for globalasm) - rust-lang/rust#149274 (Fix invalid link generation for type alias methods) - rust-lang/rust#149302 (Fix comment wording in simplify_comparison_integral.rs) - rust-lang/rust#149305 (Simplify OnceCell Clone impl) r? `@ghost` `@rustbot` modify labels: rollup
Fixes #148161