From 1c571fd17f394fed3c79160721b1bc4510db0dd4 Mon Sep 17 00:00:00 2001 From: toidiu Date: Mon, 2 Jul 2018 22:25:49 -0400 Subject: [PATCH] test to capture that cross crate outlives requirements are not inferred --- .../ui/rfc-2093-infer-outlives/cross-crate.rs | 20 +++++++++++++++++++ .../cross-crate.stderr | 17 ++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/test/ui/rfc-2093-infer-outlives/cross-crate.rs create mode 100644 src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr diff --git a/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs b/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs new file mode 100644 index 000000000000..b05a6e5fee2d --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] + +// #[rustc_outlives] +struct Foo<'a, T> { + bar: std::slice::IterMut<'a, T> //~ ERROR 16:5: 16:36: the parameter type `T` may not live long enough [E0309] +} + +fn main() {} + diff --git a/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr b/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr new file mode 100644 index 000000000000..82690bea64d1 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr @@ -0,0 +1,17 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/cross-crate.rs:16:5 + | +LL | struct Foo<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | bar: std::slice::IterMut<'a, T> //~ ERROR 16:5: 16:36: the parameter type `T` may not live long enough [E0309] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/cross-crate.rs:16:5 + | +LL | bar: std::slice::IterMut<'a, T> //~ ERROR 16:5: 16:36: the parameter type `T` may not live long enough [E0309] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`.