]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/dyn-trait-elided-two-inputs-ref-assoc.rs
Rollup merge of #95504 - jyn514:library-alias, r=Mark-Simulacrum
[rust.git] / src / test / ui / impl-trait / dyn-trait-elided-two-inputs-ref-assoc.rs
1 // Test that we don't get an error with `dyn Bar` in an impl Trait
2 // when there are multiple inputs.  The `dyn Bar` should default to `+
3 // 'static`. This used to erroneously generate an error (cc #62517).
4 //
5 // check-pass
6
7 trait Foo {
8     type Item: ?Sized;
9
10     fn item(&self) -> Box<Self::Item> { panic!() }
11 }
12
13 trait Bar { }
14
15 impl<T> Foo for T {
16     type Item = dyn Bar;
17 }
18
19 fn is_static<T>(_: T) where T: 'static { }
20
21 fn bar(x: &str) -> &impl Foo<Item = dyn Bar> { &() }
22
23 fn main() {
24     let s = format!("foo");
25     let r = bar(&s);
26     is_static(r.item());
27 }