-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ICE with inferred type in const
or static
item
#89161
Conversation
(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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not overly familiar with this code.
--> $DIR/issue-74086.rs:2:17 | ||
| | ||
LL | static BUG: fn(_) -> u8 = |_| 8; | ||
| ^^^^^^^^^^^ not allowed in type signatures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this span doesn't seem as helpful as before :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
dyn
type could be nested (as inVec<dyn Fn(& _)>
), which causes the ICE described in #88643.