Skip to content

Commit 0fd7fee

Browse files
committed
fix test and add feature gate test
1 parent 429ae93 commit 0fd7fee

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Needs an explicit where clause stating outlives condition. (RFC 2093)
12+
13+
// Type T needs to outlive lifetime 'static.
14+
struct Foo<U> {
15+
bar: Bar<U> //~ ERROR 15:5: 15:16: the parameter type `U` may not live long enough [E0310]
16+
}
17+
struct Bar<T: 'static> {
18+
x: T,
19+
}
20+
21+
22+
fn main() { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0310]: the parameter type `U` may not live long enough
2+
--> $DIR/feature-gate-infer_static_outlives_requirements.rs:15:5
3+
|
4+
LL | struct Foo<U> {
5+
| - help: consider adding an explicit lifetime bound `U: 'static`...
6+
LL | bar: Bar<U> //~ ERROR 15:5: 15:16: the parameter type `U` may not live long enough [E0310]
7+
| ^^^^^^^^^^^
8+
|
9+
note: ...so that the type `U` will meet its required lifetime bounds
10+
--> $DIR/feature-gate-infer_static_outlives_requirements.rs:15:5
11+
|
12+
LL | bar: Bar<U> //~ ERROR 15:5: 15:16: the parameter type `U` may not live long enough [E0310]
13+
| ^^^^^^^^^^^
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0310`.

src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
error[E0310]: the parameter type `U` may not live long enough
2-
--> $DIR/dont-infer-static.rs:16:5
2+
--> $DIR/dont-infer-static.rs:22:5
33
|
44
LL | struct Foo<U> {
55
| - help: consider adding an explicit lifetime bound `U: 'static`...
6-
LL | bar: Bar<U> //~ ERROR 16:5: 16:16: the parameter type `U` may not live long enough [E0310]
6+
LL | bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310]
77
| ^^^^^^^^^^^
88
|
99
note: ...so that the type `U` will meet its required lifetime bounds
10-
--> $DIR/dont-infer-static.rs:16:5
10+
--> $DIR/dont-infer-static.rs:22:5
1111
|
12-
LL | bar: Bar<U> //~ ERROR 16:5: 16:16: the parameter type `U` may not live long enough [E0310]
12+
LL | bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310]
1313
| ^^^^^^^^^^^
1414

1515
error: aborting due to previous error

0 commit comments

Comments
 (0)