-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
NLL doesn't respect user types in closure signatures #54692
Comments
Tagging as RC2 |
So, the closure region requirements are as follows: > rustc ~/tmp/issue-54692.rs -Zverbose
note: External requirements
--> /home/nmatsakis/tmp/issue-54692.rs:6:5
|
6 | / |x: &'a i32| -> &'static i32 {
7 | | return &x;
8 | | };
| |_____^
|
= note: defining type: DefId(0/1:10 ~ issue_54692[317d]::foo[0]::{{closure}}[0]) with closure substs [
i8,
extern "rust-call" fn((&'_#1r i32,)) -> &'_#2r i32
]
= note: late-bound region is '_#3r
= note: number of external vids: 4
= note: where '_#1r: '_#2r |
You can see the |
The user-given signature of the closure is computed here, during the HIR typeck: rust/src/librustc_typeck/check/closure.rs Lines 529 to 533 in 1c5e9c6
(In general, reconciling the expected signature and the user-given signature is a royal pain, as is described in detail in that file.) I imagine what we have to do is probably to record the "supplied closure signature" somewhere, probably in a new table similar to The question is where it should be accessed from. I think it should probably be the closure's job to enforce these relations (if you read that code above, you might see why: in general, the user's signatures are written from the "POV" of the closure body, rather than its creator). This implies that MIR may want to grow a |
Hmm this may be blocking me in other areas. |
adding |
Got a report from @mikhail-m1 that they are actively working on this Unassigning @spastorino (since @mikhail-m1 is taking lead here) |
…=MatthewJasper enforce user annotations in closure signatures Not *quite* ready yet but I'm opening anyway. Still have to finish running tests locally. Fixes #54692 Fixes #54124 r? @matthewjasper
For example, the following code compiles
cc #47184
The text was updated successfully, but these errors were encountered: