-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
handle user type annotations in NLL for ref
bindings
#55401
Comments
@pnkfelix do you have an example of a program that fails to error as a result of this bug? |
I think this should error, but does not under NLL today: fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u32 {
let (ref y, _z): (&'a u32, u32) = (&22, 44);
*y //~ ERROR
} |
(this may not be that hard to fix. I punted because the other cases seemed way more important to get fixed ASAP, but its possible that a similar pattern can work for this too.) |
I don't think any fix for this is worth the effort of backporting, though... its a really subtle case. |
Update: Got confused by migration mode, this isn't fixed.
|
NLL: User type annotations refactor, associated constant patterns and ref bindings. Fixes #55511 and Fixes #55401. Contributes to #54943. This PR performs a large refactoring on user type annotations, checks user type annotations for associated constants in patterns and that user type annotations for `ref` bindings are respected. r? @nikomatsakis
spun off from #47184 and #54570 :
Most of the necessary support for checking lifetime constraints introduced via complex patterns has been added. But one exceptional case which has not been properly dealt with is
ref
bindings.If you look here the code explicitly says "ignore
pattern_user_ty
for now."rust/src/librustc_mir/build/matches/mod.rs
Lines 518 to 526 in 3e6f30e
(I fixed a lot of instances of FIXME(#47184) in PR #55274, but I punted on this one.)
The text was updated successfully, but these errors were encountered: