]> git.lizzy.rs Git - rust.git/blob - src/test/ui/type-alias-impl-trait/bounds-are-checked.rs
Make the error for opaque types that have no hidden types a bit informative
[rust.git] / src / test / ui / type-alias-impl-trait / bounds-are-checked.rs
1 // Make sure that we check that impl trait types implement the traits that they
2 // claim to.
3
4 #![feature(type_alias_impl_trait)]
5
6 type X<'a> = impl Into<&'static str> + From<&'a str>;
7 //~^ ERROR unconstrained opaque type
8
9 fn f<'a: 'static>(t: &'a str) -> X<'a> {
10     //~^ WARNING unnecessary lifetime parameter
11     t
12     //~^ ERROR non-defining opaque type use
13 }
14
15 fn extend_lt<'a>(o: &'a str) -> &'static str {
16     X::<'_>::from(o).into()
17 }
18
19 fn main() {
20     let r = {
21         let s = "abcdef".to_string();
22         extend_lt(&s)
23     };
24     println!("{}", r);
25 }