-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Foo<Vec<X>> shouldn't imply X: 'static. | ||
// We don't use region constraints from trait impls in implied bounds. | ||
|
||
trait Trait { | ||
type Assoc; | ||
} | ||
|
||
impl<X: 'static> Trait for Vec<X> { | ||
type Assoc = (); | ||
} | ||
|
||
struct Foo<T: Trait>(T) | ||
where | ||
T::Assoc: 'static, // any predicate naming T::Assoc | ||
; | ||
|
||
fn foo<X>(_: Foo<Vec<X>>) {} | ||
//~^ ERROR `X` may not live long enough | ||
//~| ERROR `X` may not live long enough | ||
|
||
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,31 @@ | ||
error[E0310]: the parameter type `X` may not live long enough | ||
--> $DIR/from-trait-impl.rs:17:1 | ||
| | ||
LL | fn foo<X>(_: Foo<Vec<X>>) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| the parameter type `X` must be valid for the static lifetime... | ||
| ...so that the type `X` will meet its required lifetime bounds | ||
| | ||
help: consider adding an explicit lifetime bound | ||
| | ||
LL | fn foo<X: 'static>(_: Foo<Vec<X>>) {} | ||
| +++++++++ | ||
|
||
error[E0310]: the parameter type `X` may not live long enough | ||
--> $DIR/from-trait-impl.rs:17:14 | ||
| | ||
LL | fn foo<X>(_: Foo<Vec<X>>) {} | ||
| ^^^^^^^^^^^ | ||
| | | ||
| the parameter type `X` must be valid for the static lifetime... | ||
| ...so that the type `X` will meet its required lifetime bounds | ||
| | ||
help: consider adding an explicit lifetime bound | ||
| | ||
LL | fn foo<X: 'static>(_: Foo<Vec<X>>) {} | ||
| +++++++++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0310`. |