File tree 2 files changed +52
-0
lines changed
2 files changed +52
-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
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
6
+ | |
7
+ | the parameter type `X` must be valid for the static lifetime...
8
+ | ...so that the type `X` will meet its required lifetime bounds
9
+ |
10
+ help: consider adding an explicit lifetime bound
11
+ |
12
+ LL | fn foo<X: 'static>(_: Foo<Vec<X>>) {}
13
+ | +++++++++
14
+
15
+ error[E0310]: the parameter type `X` may not live long enough
16
+ --> $DIR/from-trait-impl.rs:17:14
17
+ |
18
+ LL | fn foo<X>(_: Foo<Vec<X>>) {}
19
+ | ^^^^^^^^^^^
20
+ | |
21
+ | the parameter type `X` must be valid for the static lifetime...
22
+ | ...so that the type `X` will meet its required lifetime bounds
23
+ |
24
+ help: consider adding an explicit lifetime bound
25
+ |
26
+ LL | fn foo<X: 'static>(_: Foo<Vec<X>>) {}
27
+ | +++++++++
28
+
29
+ error: aborting due to 2 previous errors
30
+
31
+ For more information about this error, try `rustc --explain E0310`.
You can’t perform that action at this time.
0 commit comments