-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't allow consts with unconstrained lifetimes in their types
- Loading branch information
1 parent
faee636
commit e179d5d
Showing
5 changed files
with
24 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
struct Foo; | ||
|
||
impl<'a> Foo { | ||
const CONST: &'a str = ""; | ||
//~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates | ||
} | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates | ||
--> $DIR/assoc-const-unconstrained-lifetime.rs:3:6 | ||
| | ||
LL | impl<'a> Foo { | ||
| ^^ unconstrained lifetime parameter | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0207`. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
error[E0308]: const not compatible with trait | ||
--> $DIR/trait-associated-constant.rs:21:5 | ||
| | ||
LL | const AC: Option<&'c str> = None; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ||
| | ||
= note: expected enum `Option<&'b str>` | ||
found enum `Option<&'c str>` | ||
note: the lifetime `'c` as defined here... | ||
error[E0207]: the lifetime parameter `'c` is not constrained by the impl trait, self type, or predicates | ||
--> $DIR/trait-associated-constant.rs:20:18 | ||
| | ||
LL | impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct { | ||
| ^^ | ||
note: ...does not necessarily outlive the lifetime `'b` as defined here | ||
--> $DIR/trait-associated-constant.rs:20:14 | ||
| | ||
LL | impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct { | ||
| ^^ | ||
| ^^ unconstrained lifetime parameter | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. | ||
For more information about this error, try `rustc --explain E0207`. |