Skip to content

Commit 1c571fd

Browse files
committed
test to capture that cross crate outlives requirements are not inferred
1 parent c8df60a commit 1c571fd

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
#![feature(rustc_attrs)]
12+
#![feature(infer_outlives_requirements)]
13+
14+
// #[rustc_outlives]
15+
struct Foo<'a, T> {
16+
bar: std::slice::IterMut<'a, T> //~ ERROR 16:5: 16:36: the parameter type `T` may not live long enough [E0309]
17+
}
18+
19+
fn main() {}
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0309]: the parameter type `T` may not live long enough
2+
--> $DIR/cross-crate.rs:16:5
3+
|
4+
LL | struct Foo<'a, T> {
5+
| - help: consider adding an explicit lifetime bound `T: 'a`...
6+
LL | bar: std::slice::IterMut<'a, T> //~ ERROR 16:5: 16:36: the parameter type `T` may not live long enough [E0309]
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8+
|
9+
note: ...so that the type `T` will meet its required lifetime bounds
10+
--> $DIR/cross-crate.rs:16:5
11+
|
12+
LL | bar: std::slice::IterMut<'a, T> //~ ERROR 16:5: 16:36: the parameter type `T` may not live long enough [E0309]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0309`.

0 commit comments

Comments
 (0)