File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Foo<Vec<X>> shouldn't imply X: 'static.
2
+ // We don't use region constraints from trait impls in implied bounds.
3
+
4
+ trait Trait {
5
+ type Assoc ;
6
+ }
7
+
8
+ impl < X : ' static > Trait for Vec < X > {
9
+ type Assoc = ( ) ;
10
+ }
11
+
12
+ struct Foo < T : Trait > ( T )
13
+ where
14
+ T :: Assoc : ' static , // any predicate naming T::Assoc
15
+ ;
16
+
17
+ fn foo < X > ( _: Foo < Vec < X > > ) { }
18
+ //~^ ERROR `X` may not live long enough
19
+ //~| ERROR `X` may not live long enough
20
+
21
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0310]: the parameter type `X` may not live long enough
2
+ --> $DIR/from-trait-impl.rs:17:1
3
+ |
4
+ LL | fn foo<X>(_: Foo<Vec<X>>) {}
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `X` will meet its required lifetime bounds
6
+ |
7
+ help: consider adding an explicit lifetime bound...
8
+ |
9
+ LL | fn foo<X: 'static>(_: Foo<Vec<X>>) {}
10
+ | +++++++++
11
+
12
+ error[E0310]: the parameter type `X` may not live long enough
13
+ --> $DIR/from-trait-impl.rs:17:14
14
+ |
15
+ LL | fn foo<X>(_: Foo<Vec<X>>) {}
16
+ | ^^^^^^^^^^^ ...so that the type `X` will meet its required lifetime bounds
17
+ |
18
+ help: consider adding an explicit lifetime bound...
19
+ |
20
+ LL | fn foo<X: 'static>(_: Foo<Vec<X>>) {}
21
+ | +++++++++
22
+
23
+ error: aborting due to 2 previous errors
24
+
25
+ For more information about this error, try `rustc --explain E0310`.
You can’t perform that action at this time.
0 commit comments