-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add error explanation for E0491 #39091
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
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.
Excellent work! Just some little nits, nothing to say about the content itself.
Erroneous code example: | ||
|
||
```compile_fail,E0491 | ||
//struct containing a reference requires a lifetime parameter, |
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.
Please add a whitespace after the '//'.
//struct containing a reference requires a lifetime parameter, | ||
//because the data the reference points to must outlive the struct (see E0106) | ||
struct Struct<'a> { | ||
ref_i32: &'a i32 |
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.
Please add a comma at the end of the line.
ref_i32: &'a i32 | ||
} | ||
|
||
//However, a nested struct like this, the signature itself does not tell |
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.
Same.
//whether 'a outlives 'b or the other way around. | ||
//So it could be possible that 'b of reference outlives 'a of the data. | ||
struct Nested<'a, 'b> { | ||
ref_struct: &'b Struct<'a> //compile error E0491! |
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.
Same (and same).
``` | ||
"##, | ||
|
||
|
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.
Why so much empty lines?
|
||
//'a: 'b means 'a outlives 'b | ||
struct Nested<'a: 'b, 'b> { | ||
ref_struct: &'b Struct<'a> |
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.
Same.
ref_i32: &'a i32 | ||
} | ||
|
||
//'a: 'b means 'a outlives 'b |
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.
Same.
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.
Just two nits remaining!
struct Nested<'a, 'b> { | ||
ref_struct: &'b Struct<'a> //compile error E0491! | ||
ref_struct: &'b Struct<'a>, //compile error E0491! |
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.
Still missing a whitespace after '//'.
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.
Oh and the '!' isn't needed. ;)
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.
ah sorry, fixing this now...
@GuillaumeGomez thank you very much for quick reviews. I think all your comments are reflected now. |
Thanks! Now please squash your commits and it'll be good to go! |
// 'a: 'b means 'a outlives 'b | ||
struct Nested<'a: 'b, 'b> { | ||
ref_struct: &'b Struct<'a>, | ||
}F |
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.
Missed this one: Why is there an 'F' here?
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.
oops sorry, :| will delete this F and squash my commits
0c9b60b
to
c525094
Compare
Squashed into a single commit and removed the unnecessary 'F' as advised. |
Thanks! @bors: r+ rollup |
📌 Commit c525094 has been approved by |
Is this still in change requested state? |
Reviews status are just an indication, nothing to worry. I have put your PR in the bot's queue. It'll handle the tests and the merge for us. |
…on, r=GuillaumeGomez Add error explanation for E0491 Refs rust-lang#32777 Please let me know if any question or anything doesn't look right about this.
Refs #32777
Please let me know if any question or anything doesn't look right about this.