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
Lifetime error when using Self
instead of <StructName>
#66176
Comments
Seems like the error is correctly emitted in this case. When we write The same error message can be seen if we use struct MyStruct<'a> {
val: &'a bool
}
impl<'a> MyStruct<'a> {
fn make_new() {
let new_val = true;
let my_val = MyStruct::<'a> { val: &new_val };
//~^ ERROR `new_val` does not live long enough
}
} |
That seems extremely counterintuive to me - I would expect At a minimum, I think we should add something to the error message to indicate that this is going on (I assume changing the expansion of |
I wrote a longer message but then I noticed this:
It never did, in any position. It's always a fully applied type and |
triage: closing as not a bug. |
Might be difficult, but worth it if not too intrusive? If so, a new issue should probably be opened for that aspect. |
The following code compiles:
However, changing
MyStruct { val: &new_val }
toSelf { val: &new_val }
:gives the following error:
Minimized from #65897 (comment) (specifically, bcder v0.1.0 (github))
The text was updated successfully, but these errors were encountered: