You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nll should respect lifetime annotations from multi-segment paths #54574
A-NLLArea: Non-lexical lifetimes (NLL)NLL-soundWorking towards the "invalid code does not compile" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
I did some investigation. I believe this problem is specific to inherent methods. There a bit of a challenge here:
The substitutions on the impl are not directly given by the user. The user only gives the self-type. The instantiate_value_path function handles this via unification:
"instantiate_value_path: (UFCS) {:?} was a subtype of {:?} but now is not?",
self_ty,
impl_ty);
}
}
}
which is pretty reasonable, but it does't work for us. The end result is that when we (later) invoke write_user_substs_from_substs the region information has been lost:
In fact, it's mildly invalid to call write_user_substs_from_substs at that point -- it's meant to be called before we start doing unifications, actually, although in this case it's sort of ok since the only unification we've done comes pretty directly from user-given types.
I don't think there's a super nice way to fix this. We might have to propagate the "user-given self type" all the way down to MIR, actually: in particular I don't think we can readily translate a "user-given self type" into a set of substitutions, due to annoying things like higher-ranked functions, for which equality is kind of complex.
A-NLLArea: Non-lexical lifetimes (NLL)NLL-soundWorking towards the "invalid code does not compile" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
Activity
nikomatsakis commentedon Oct 2, 2018
I did some investigation. I believe this problem is specific to inherent methods. There a bit of a challenge here:
The substitutions on the impl are not directly given by the user. The user only gives the self-type. The
instantiate_value_pathfunction handles this via unification:rust/src/librustc_typeck/check/mod.rs
Lines 5219 to 5236 in 1c5e9c6
which is pretty reasonable, but it does't work for us. The end result is that when we (later) invoke
write_user_substs_from_subststhe region information has been lost:rust/src/librustc_typeck/check/mod.rs
Line 5246 in 1c5e9c6
In fact, it's mildly invalid to call
write_user_substs_from_substsat that point -- it's meant to be called before we start doing unifications, actually, although in this case it's sort of ok since the only unification we've done comes pretty directly from user-given types.I don't think there's a super nice way to fix this. We might have to propagate the "user-given self type" all the way down to MIR, actually: in particular I don't think we can readily translate a "user-given self type" into a set of substitutions, due to annoying things like higher-ranked functions, for which equality is kind of complex.
Auto merge of #55093 - nikomatsakis:nll-issue-54574-multisegment-path…