Fix ICE with inferred type in const or static item#89161
Fix ICE with inferred type in const or static item#89161FabianWolff wants to merge 1 commit intorust-lang:masterfrom
const or static item#89161Conversation
|
(rust-highfive has picked a reviewer for you, use r? to override) |
|
r? @nikomatsakis maybe? |
|
☔ The latest upstream changes (presumably #89405) made this pull request unmergeable. Please resolve the merge conflicts. |
5ed0130 to
14bc878
Compare
nikomatsakis
left a comment
There was a problem hiding this comment.
I'm not overly familiar with this code.
There was a problem hiding this comment.
this span doesn't seem as helpful as before :(
There was a problem hiding this comment.
Fixed, though there are now a few almost-duplicate diagnostics if the static or const item has a function pointer type. I haven't been able to track this down/avoid this.
14bc878 to
836ce08
Compare
|
Sorry, my review comments were ... kind of inscrutable! I was in a hurry. What I wanted to ask was: can you explain what's going wrong? I'm not overly familiar with this code and I can't quite tell what it's intent is. |
|
Sure, although I'm no expert on this code either, I just tried to fix the bug in #88643. Basically, as you can see e.g. in #88643 (comment), the main problem is: In other words, there should be an error about the use of rust/compiler/rustc_typeck/src/collect/type_of.rs Lines 355 to 377 in 25ec827
rust/compiler/rustc_typeck/src/collect.rs Lines 833 to 834 in 25ec827 However, the latter check only handles I have therefore extended this check to not only look at the outermost type kind, but to actually visit the type and see whether it finds a |
|
☔ The latest upstream changes (presumably #93119) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@FabianWolff if you can rebase this, we can push this forward |
|
@FabianWolff @rustbot label: +S-inactive |
…yn-obj, r=pnkfelix Harden bad placeholder checks on statics/consts Resubmission of rust-lang#89161 Fixes rust-lang#88643 In rust-lang#83739, I added a check for trait objects on statics/consts but it wasn't robust. `is_suggestable_infer_ty` fn does a more strict check and finds more bad placeholders. See rust-lang#89161 (comment) for the more detailed explanation. r? `@pnkfelix` as you're the reviewer of the previous PR
Fixes #88643. Currently, there is a check in the compiler that handles the special case of a constant/static variable having a trait object type:
rust/compiler/rustc_typeck/src/collect.rs
Lines 837 to 838 in 840acd3
But this fails to account for the possibility that the
dyntype could be nested (as inVec<dyn Fn(& _)>), which causes the ICE described in #88643.