mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Remove similar errors about raw underscore lifetime
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
@@ -2899,9 +2899,21 @@ fn with_generic_param_rib<'c, F>(
|
||||
}
|
||||
|
||||
if param.ident.name == kw::UnderscoreLifetime {
|
||||
// To avoid emitting two similar errors,
|
||||
// we need to check if the span is a raw underscore lifetime, see issue #143152
|
||||
let is_raw_underscore_lifetime = self
|
||||
.r
|
||||
.tcx
|
||||
.sess
|
||||
.psess
|
||||
.raw_identifier_spans
|
||||
.iter()
|
||||
.any(|span| span == param.span());
|
||||
|
||||
self.r
|
||||
.dcx()
|
||||
.emit_err(errors::UnderscoreLifetimeIsReserved { span: param.ident.span });
|
||||
.create_err(errors::UnderscoreLifetimeIsReserved { span: param.ident.span })
|
||||
.emit_unless(is_raw_underscore_lifetime);
|
||||
// Record lifetime res, so lowering knows there is something fishy.
|
||||
self.record_lifetime_param(param.id, LifetimeRes::Error);
|
||||
continue;
|
||||
|
||||
@@ -5,6 +5,5 @@
|
||||
|
||||
fn f<'r#_>(){}
|
||||
//~^ ERROR `_` cannot be a raw lifetime
|
||||
//~| ERROR `'_` cannot be used here [E0637]
|
||||
|
||||
fn main() {}
|
||||
|
||||
@@ -4,12 +4,5 @@ error: `_` cannot be a raw lifetime
|
||||
LL | fn f<'r#_>(){}
|
||||
| ^^^^
|
||||
|
||||
error[E0637]: `'_` cannot be used here
|
||||
--> $DIR/raw-underscore-lifetime.rs:6:6
|
||||
|
|
||||
LL | fn f<'r#_>(){}
|
||||
| ^^^^ `'_` is a reserved lifetime name
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0637`.
|
||||
|
||||
Reference in New Issue
Block a user