]> git.proxmox.com Git - rustc.git/blob - src/test/ui/traits/trait-static-method-generic-inference.rs
New upstream version 1.40.0+dfsg1
[rustc.git] / src / test / ui / traits / trait-static-method-generic-inference.rs
1 // Issue #3902. We are (at least currently) unable to infer `Self`
2 // based on `T`, even though there is only a single impl, because of
3 // the possibility of associated types and other things (basically: no
4 // constraints on `Self` here at all).
5
6 mod base {
7 pub trait HasNew<T> {
8 fn new() -> T;
9 fn dummy(&self) { }
10 }
11
12 pub struct Foo {
13 dummy: (),
14 }
15
16 impl HasNew<Foo> for Foo {
17 fn new() -> Foo {
18 Foo { dummy: () }
19 }
20 }
21 }
22
23 pub fn foo() {
24 let _f: base::Foo = base::HasNew::new();
25 //~^ ERROR type annotations needed
26 }
27
28 fn main() { }