Skip to content

Commit

Permalink
Tweak diagnostics on shadowing lifetimes/labels
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Dec 2, 2020
1 parent 6645da3 commit cdcce11
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 95 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late/lifetimes.rs
Expand Up @@ -1098,7 +1098,7 @@ fn signal_shadowing_problem(tcx: TyCtxt<'_>, name: Symbol, orig: Original, shado
)
};
err.span_label(orig.span, "first declared here");
err.span_label(shadower.span, format!("lifetime {} already in scope", name));
err.span_label(shadower.span, format!("{} `{}` already in scope", orig.kind.desc(), name));
err.emit();
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0496.stderr
Expand Up @@ -4,7 +4,7 @@ error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scop
LL | impl<'a> Foo<'a> {
| -- first declared here
LL | fn f<'a>(x: &'a i32) {
| ^^ lifetime 'a already in scope
| ^^ lifetime `'a` already in scope

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/shadowing.stderr
Expand Up @@ -20,15 +20,15 @@ error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scop
LL | trait Shadow<'a> {
| -- first declared here
LL | type Bar<'a>;
| ^^ lifetime 'a already in scope
| ^^ lifetime `'a` already in scope

error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope
--> $DIR/shadowing.rs:14:14
|
LL | impl<'a> NoShadow<'a> for &'a u32 {
| -- first declared here
LL | type Bar<'a> = i32;
| ^^ lifetime 'a already in scope
| ^^ lifetime `'a` already in scope

error: aborting due to 4 previous errors

Expand Down
56 changes: 28 additions & 28 deletions src/test/ui/hygiene/hygienic-labels-in-let.stderr
Expand Up @@ -2,7 +2,7 @@ warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:16:9
|
LL | 'x: loop { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: loop {
| -- first declared here
Expand All @@ -19,7 +19,7 @@ LL | 'x: loop {
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:64:9
Expand All @@ -28,13 +28,13 @@ LL | 'x: loop { $e }
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:16:9
|
LL | 'x: loop { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: loop {
| -- first declared here
Expand All @@ -51,7 +51,7 @@ LL | 'x: loop { $e }
| ^^
| |
| first declared here
| lifetime 'x already in scope
| label `'x` already in scope
...
LL | loop_x!(break 'x);
| ------------------ in this macro invocation
Expand All @@ -62,7 +62,7 @@ warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:16:9
|
LL | 'x: loop { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: for _ in 0..1 {
| -- first declared here
Expand All @@ -79,7 +79,7 @@ LL | 'x: loop {
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:76:9
Expand All @@ -88,7 +88,7 @@ LL | 'x: loop { $e }
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:76:9
Expand All @@ -97,7 +97,7 @@ LL | 'x: for _ in 0..1 {
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:76:9
Expand All @@ -106,13 +106,13 @@ LL | 'x: loop { $e }
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:27:9
|
LL | 'x: while 1 + 1 == 2 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: loop {
| -- first declared here
Expand All @@ -129,7 +129,7 @@ LL | 'x: loop { $e }
| -- first declared here
...
LL | 'x: while 1 + 1 == 2 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | while_true!(break 'x);
| ---------------------- in this macro invocation
Expand All @@ -140,7 +140,7 @@ warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:27:9
|
LL | 'x: while 1 + 1 == 2 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: for _ in 0..1 {
| -- first declared here
Expand All @@ -157,7 +157,7 @@ LL | 'x: loop { $e }
| -- first declared here
...
LL | 'x: while 1 + 1 == 2 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | while_true!(break 'x);
| ---------------------- in this macro invocation
Expand All @@ -168,7 +168,7 @@ warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:27:9
|
LL | 'x: while 1 + 1 == 2 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: for _ in 0..1 {
| -- first declared here
Expand All @@ -185,7 +185,7 @@ LL | 'x: loop {
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:90:9
Expand All @@ -194,7 +194,7 @@ LL | 'x: loop { $e }
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:90:9
Expand All @@ -203,7 +203,7 @@ LL | 'x: for _ in 0..1 {
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:90:9
Expand All @@ -212,7 +212,7 @@ LL | 'x: loop { $e }
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:90:9
Expand All @@ -221,7 +221,7 @@ LL | 'x: for _ in 0..1 {
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:90:9
Expand All @@ -230,13 +230,13 @@ LL | 'x: while 1 + 1 == 2 { $e }
| -- first declared here
...
LL | 'x: for _ in 0..1 {
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope

warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:39:9
|
LL | 'x: for _ in 0..1 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: loop {
| -- first declared here
Expand All @@ -253,7 +253,7 @@ LL | 'x: loop { $e }
| -- first declared here
...
LL | 'x: for _ in 0..1 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | run_once!(continue 'x);
| ----------------------- in this macro invocation
Expand All @@ -264,7 +264,7 @@ warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:39:9
|
LL | 'x: for _ in 0..1 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: for _ in 0..1 {
| -- first declared here
Expand All @@ -281,7 +281,7 @@ LL | 'x: loop { $e }
| -- first declared here
...
LL | 'x: for _ in 0..1 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | run_once!(continue 'x);
| ----------------------- in this macro invocation
Expand All @@ -292,7 +292,7 @@ warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:39:9
|
LL | 'x: for _ in 0..1 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: for _ in 0..1 {
| -- first declared here
Expand All @@ -309,7 +309,7 @@ LL | 'x: while 1 + 1 == 2 { $e }
| -- first declared here
...
LL | 'x: for _ in 0..1 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | run_once!(continue 'x);
| ----------------------- in this macro invocation
Expand All @@ -320,7 +320,7 @@ warning: label name `'x` shadows a label name that is already in scope
--> $DIR/hygienic-labels-in-let.rs:39:9
|
LL | 'x: for _ in 0..1 { $e }
| ^^ lifetime 'x already in scope
| ^^ label `'x` already in scope
...
LL | 'x: for _ in 0..1 {
| -- first declared here
Expand Down

0 comments on commit cdcce11

Please sign in to comment.