Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest using
'static
in assoc consts and suggest when multiple lts…
… are needed
- Loading branch information
Showing
5 changed files
with
144 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 12 additions & 1 deletion
13
src/test/ui/suggestions/missing-lifetime-in-assoc-const-type.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
trait ZstAssert: Sized { | ||
const TYPE_NAME: &str = ""; //~ ERROR missing lifetime specifier | ||
const A: &str = ""; //~ ERROR missing lifetime specifier | ||
const B: S = S { s: &() }; //~ ERROR missing lifetime specifier | ||
const C: &'_ str = ""; //~ ERROR missing lifetime specifier | ||
const D: T = T { a: &(), b: &() }; //~ ERROR missing lifetime specifier | ||
} | ||
|
||
struct S<'a> { | ||
s: &'a (), | ||
} | ||
struct T<'a, 'b> { | ||
a: &'a (), | ||
b: &'b (), | ||
} | ||
|
||
fn main() {} |
68 changes: 63 additions & 5 deletions
68
src/test/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,73 @@ | ||
error[E0106]: missing lifetime specifier | ||
--> $DIR/missing-lifetime-in-assoc-const-type.rs:2:22 | ||
--> $DIR/missing-lifetime-in-assoc-const-type.rs:2:14 | ||
| | ||
LL | const TYPE_NAME: &str = ""; | ||
| ^ expected named lifetime parameter | ||
LL | const A: &str = ""; | ||
| ^ expected named lifetime parameter | ||
| | ||
help: consider using the `'static` lifetime | ||
| | ||
LL | const A: &'static str = ""; | ||
| ^^^^^^^ | ||
help: consider introducing a named lifetime parameter | ||
| | ||
LL | trait ZstAssert<'a>: Sized { | ||
LL | const A: &'a str = ""; | ||
| | ||
|
||
error[E0106]: missing lifetime specifier | ||
--> $DIR/missing-lifetime-in-assoc-const-type.rs:3:14 | ||
| | ||
LL | const B: S = S { s: &() }; | ||
| ^ expected named lifetime parameter | ||
| | ||
help: consider using the `'static` lifetime | ||
| | ||
LL | const B: S<'static> = S { s: &() }; | ||
| ^^^^^^^^^ | ||
help: consider introducing a named lifetime parameter | ||
| | ||
LL | trait ZstAssert<'a>: Sized { | ||
LL | const A: &str = ""; | ||
LL | const B: S<'a> = S { s: &() }; | ||
| | ||
|
||
error[E0106]: missing lifetime specifier | ||
--> $DIR/missing-lifetime-in-assoc-const-type.rs:4:15 | ||
| | ||
LL | const C: &'_ str = ""; | ||
| ^^ expected named lifetime parameter | ||
| | ||
help: consider using the `'static` lifetime | ||
| | ||
LL | const C: &'static str = ""; | ||
| ^^^^^^^ | ||
help: consider introducing a named lifetime parameter | ||
| | ||
LL | trait ZstAssert<'a>: Sized { | ||
LL | const A: &str = ""; | ||
LL | const B: S = S { s: &() }; | ||
LL | const C: &'a str = ""; | ||
| | ||
|
||
error[E0106]: missing lifetime specifiers | ||
--> $DIR/missing-lifetime-in-assoc-const-type.rs:5:14 | ||
| | ||
LL | const D: T = T { a: &(), b: &() }; | ||
| ^ expected 2 lifetime parameters | ||
| | ||
help: consider using the `'static` lifetime | ||
| | ||
LL | const D: T<'static, 'static> = T { a: &(), b: &() }; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
help: consider introducing a named lifetime parameter | ||
| | ||
LL | trait ZstAssert<'a>: Sized { | ||
LL | const TYPE_NAME: &'a str = ""; | ||
LL | const A: &str = ""; | ||
LL | const B: S = S { s: &() }; | ||
LL | const C: &'_ str = ""; | ||
LL | const D: T<'a, 'a> = T { a: &(), b: &() }; | ||
| | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0106`. |