From d913af8691d4002166c9a6e1b60e51407cf82c9c Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 21 Mar 2018 06:31:39 -0400 Subject: [PATCH] add new test for `dyn` used in a struct `'_` is illegal in structs; this currently gets a duplicate error --- .../dyn-trait-underscore-in-struct.rs | 26 +++++++++++++++++++ .../dyn-trait-underscore-in-struct.stderr | 16 ++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.rs create mode 100644 src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.rs b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.rs new file mode 100644 index 00000000000..d10541ad33b --- /dev/null +++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.rs @@ -0,0 +1,26 @@ +// 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. + +// Check that the `'_` in `dyn Trait + '_` acts like ordinary elision, +// and not like an object lifetime default. +// +// cc #48468 + +#![feature(dyn_trait)] +#![feature(underscore_lifetimes)] + +use std::fmt::Debug; + +struct Foo { + x: Box, //~ ERROR missing lifetime specifier + //~^ ERROR E0228 +} + +fn main() { } diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr new file mode 100644 index 00000000000..a88ecb18dd6 --- /dev/null +++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr @@ -0,0 +1,16 @@ +error[E0106]: missing lifetime specifier + --> $DIR/dyn-trait-underscore-in-struct.rs:22:24 + | +LL | x: Box, //~ ERROR missing lifetime specifier + | ^^ expected lifetime parameter + +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound + --> $DIR/dyn-trait-underscore-in-struct.rs:22:12 + | +LL | x: Box, //~ ERROR missing lifetime specifier + | ^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0106, E0228. +For more information about an error, try `rustc --explain E0106`.