]> git.lizzy.rs Git - rust.git/blob - src/test/ui/type-alias-impl-trait/bounds-are-checked.rs
Rollup merge of #92917 - jackh726:issue-91762-2, r=nikomatsakis
[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
8 fn f<'a: 'static>(t: &'a str) -> X<'a> {
9     //~^ WARNING unnecessary lifetime parameter
10     t
11     //~^ ERROR non-defining opaque type use
12 }
13
14 fn extend_lt<'a>(o: &'a str) -> &'static str {
15     X::<'_>::from(o).into()
16 }
17
18 fn main() {
19     let r = {
20         let s = "abcdef".to_string();
21         extend_lt(&s)
22     };
23     println!("{}", r);
24 }