Skip to content
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

Merged
merged 1 commit into from
Jan 19, 2017

Conversation

richardimaoka
Copy link
Contributor

Refs #32777

Please let me know if any question or anything doesn't look right about this.

@rust-highfive
Copy link
Collaborator

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.

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a 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,
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same (and same).

```
"##,


Copy link
Member

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>
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a 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!
Copy link
Member

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 '//'.

Copy link
Member

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. ;)

Copy link
Contributor Author

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...

@richardimaoka
Copy link
Contributor Author

@GuillaumeGomez thank you very much for quick reviews. I think all your comments are reflected now.

@GuillaumeGomez
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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

@richardimaoka richardimaoka force-pushed the E0491-long-explanation branch from 0c9b60b to c525094 Compare January 17, 2017 13:18
@richardimaoka
Copy link
Contributor Author

Squashed into a single commit and removed the unnecessary 'F' as advised.

@GuillaumeGomez
Copy link
Member

Thanks!

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Jan 17, 2017

📌 Commit c525094 has been approved by GuillaumeGomez

@richardimaoka
Copy link
Contributor Author

Is this still in change requested state?

@GuillaumeGomez
Copy link
Member

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.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jan 19, 2017
…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.
bors added a commit that referenced this pull request Jan 19, 2017
Rollup of 11 pull requests

- Successful merges: #38457, #38922, #38970, #39039, #39091, #39115, #39121, #39149, #39150, #39151, #39165
- Failed merges:
@bors bors merged commit c525094 into rust-lang:master Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants