-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Remove duplicate error about raw underscore lifetime #143280
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2902,7 +2902,16 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if param.ident.name == kw::UnderscoreLifetime { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// To avoid emitting two duplicate errors, we need to check if the span is a raw underscore lifetime, see issue #143152 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let is_raw_underscore = self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.tcx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.sess | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.psess | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.raw_identifier_spans | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.any(|span| span == param.span()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if param.ident.name == kw::UnderscoreLifetime && !is_raw_underscore { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
self.r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.dcx() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.emit_err(errors::UnderscoreLifetimeIsReserved { span: param.ident.span }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+2905
to
2917
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I think the comment could be tweaked; instead of "two duplicate errors", b/c the error is not duplicate, we should say something different. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This test is to ensure that the raw underscore lifetime won't emit two duplicate errors. | ||
// See issue #143152 | ||
|
||
//@ edition: 2021 | ||
|
||
fn f<'r#_>(){} | ||
//~^ ERROR `_` cannot be a raw lifetime | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: `_` cannot be a raw lifetime | ||
--> $DIR/raw-underscore-lifetime.rs:6:6 | ||
| | ||
LL | fn f<'r#_>(){} | ||
| ^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
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'm wondering if I should split it into 2 parts, as this doesn't seem very aesthetically pleasing taking up so many lines. However it seems to give the wrong impression that the variable in the middle will be used multiple times.