mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-07 20:43:03 +00:00
add new test for dyn<Trait + '_>
used in a struct
`'_` is illegal in structs; this currently gets a duplicate error
This commit is contained in:
parent
f07ebc5df8
commit
d913af8691
@ -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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<dyn Debug + '_>, //~ ERROR missing lifetime specifier
|
||||
//~^ ERROR E0228
|
||||
}
|
||||
|
||||
fn main() { }
|
@ -0,0 +1,16 @@
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/dyn-trait-underscore-in-struct.rs:22:24
|
||||
|
|
||||
LL | x: Box<dyn Debug + '_>, //~ 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<dyn Debug + '_>, //~ 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`.
|
Loading…
Reference in New Issue
Block a user