- Notifications
You must be signed in to change notification settings - Fork 14k
Adding E0623 for structs #43700
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
Adding E0623 for structs #43700
Conversation
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.
This line has >100 chars.
|
EDIT: woups, nevermind. I'm the one who's in the wrong here. |
98189ad to 5cf4f2a Compare 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.
Nitpick: This is a case where using match might match can make the code cleaner and let you be assured that you're not missing a case (the let x = if already emits an error for missing returns, but match without matching on _ makes it clear that you didn't forget a case):
let arg1_label = match (is_arg1_struct, is_arg2_struct) { (true, true) => "these structs".to_string(), (true, false) => "the struct and reference".to_string(), (false, true) => "the reference and the struct".to_string(), (false, false) => "these references".to_string(), }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.
different wording vs line 120
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.
There's no case where this method doesn't return Some, so you can change the method's signature to return String, instead of Option<String>.
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.
Empty else clause, simply remove it.
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 removing comments?
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.
For other reviewers: ex3-both-anon-regions-3.rs was moved to ex3-both-anon-regions-one-is-struct-2.rs
Generalized the error message after a discussion with @nikomatsakis. @estebank updated PR. |
a96ac00 to 529baac Compare | Maybe it would scale better to attach spans to anonymous lifetimes in |
| Fixed tidy checks |
5ef8486 to 6b08259 Compare | @nikomatsakis @estebank @arielb1 @kennytm Needed help with writing examples for the cases where I have made the code changes for this but the ui tests I have added don't trigger the error the way I thought it would. As per the logs I generated, for the above to examples, they seem to return a false value at EDIT - Turns out the |
11ddeb4 to 8da0aed Compare 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.
Update copyright year
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.
Update copyright year
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.
Update copyright year
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.
Update copyright year
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.
Update copyright year
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.
Update copyright year
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.
Update copyright year
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.
Update copyright year
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.
Update copyright year
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.
Revert trivial change to this file.
8da0aed to 11ddeb4 Compare | https://travis-ci.org/rust-lang/rust/jobs/263641387#L1240 |
f636e43 to 1ed03e7 Compare | @gaurikholkar: the CI failure that @estebank mentioned still exists in 1ed03e7... |
0239364 to 591b8f6 Compare | @kennytm I changed it to |
| @nikomatsakis Also, the |
| @gaurikholkar I don't see any error from Travis about 591b8f6 yet (it is still running), so no conclusion. Perhaps the error is pointing to other places. You don't need to mark |
591b8f6 to 58cfc83 Compare 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.
This line is too long.
[00:03:12] tidy error: /checkout/src/librustc/infer/error_reporting/named_anon_conflict.rs:38: line longer than 100 chars | @@ -0,0 +1,19 @@ | |||
| // Copyright 2017 The Rust Project Developers. See the COPYRIGHT | |||
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.
duplicate test?
| @@ -0,0 +1,17 @@ | |||
| // Copyright 2017 The Rust Project Developers. See the COPYRIGHT | |||
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.
duplicate test with previous (except x and y were replaced?)
| @@ -0,0 +1,20 @@ | |||
| // Copyright 2017 The Rust Project Developers. See the COPYRIGHT | |||
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.
duplicate test?
| | ||
| // This method returns whether the given Region is Anonymous | ||
| // and returns the DefId and the BoundRegion corresponding to the given region. | ||
| // The is_anon_anon is set true when we are dealing with cases where |
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.
Could you please store is_impl_item in FreeRegionInfo and branch on it instead of passing is_anon_anon as a parameter? It being a parameter is confusing.
| } | ||
| Some(hir_map::NodeImplItem(..)) => { | ||
| if let ty::BrAnon(..) = free_region.bound_region { | ||
| let anonymous_region_binding_scope = free_region.scope; |
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.
Actually, this bunch of code only detects whether we are in an impl item. Could you extract it to an is_bound_region_in_impl_item function and call it from whenever its needed?
| // corresponds to self and if yes, we display E0312. | ||
| // FIXME(#42700) - Need to format self properly to | ||
| // enable E0621 for it. | ||
| pub fn is_self_anon(&self, is_first: bool, scope_def_id: DefId) -> bool { |
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.
{ is_first && self.tcx .opt_associated_item(scope_def_id) .map(|i| i.method_has_self_argument) == Some(true) }| anon_reg_sub.boundregion); | ||
| if let (Some(anonarg_sup), Some(anonarg_sub)) = | ||
| (self.find_anon_type(sup, &br_sup), self.find_anon_type(sub, &br_sub)) { | ||
| (anonarg_sup, anonarg_sub, def_id_sup, def_id_sub, br_sup, br_sub) |
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.
style: you can return anon_reg_sup & anon_reg_sub.
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.
@arielb1 Are you saying use anon_reg_sup instead of Some(anon_reg_sup). Can you elaborate on this please?
| Ok by me modulo nits - I'll fix the binder trouble myself |
| @arielb1 updated |
151b5bb to 0f58e18 Compare 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.
maybe flatten these if let constraints with or_else! too? I hate to drag out this PR anymore though, so happy to do it as follow-up
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.
I'll open up a separate PR for that
0f58e18 to cb563a9 Compare | We decided to do more "flattening" as a separate PR. |
| @bors r+ |
| 📌 Commit cb563a9 has been approved by |
| @nikomatsakis Needs re-r+ after the CI actually passes. |
| @bors r+ |
| 📌 Commit 2cd1318 has been approved by |
Adding E0623 for structs This is a fix to #43275 The error message is ``` +error[E0623]: lifetime mismatch + --> $DIR/ex3-both-anon-regions-both-are-structs.rs:15:12 + | +14 | fn foo(mut x: Vec<Ref>, y: Ref) { + | --- --- these structs are declared with different lifetimes... +15 | x.push(y); + | ^ ...but data from `y` flows into `x` here + +error: aborting due to previous error ``` r? @nikomatsakis
| ☀️ Test successful - status-appveyor, status-travis |
This is a fix to #43275
The error message is
r? @nikomatsakis