]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generics/bad-mid-path-type-params.rs
Auto merge of #99324 - reez12g:issue-99144, r=jyn514
[rust.git] / src / test / ui / generics / bad-mid-path-type-params.rs
1 struct S<T> {
2     contents: T,
3 }
4
5 impl<T> S<T> {
6     fn new<U>(x: T, _: U) -> S<T> {
7         S {
8             contents: x,
9         }
10     }
11 }
12
13 trait Trait<T> {
14     fn new<U>(x: T, y: U) -> Self;
15 }
16
17 struct S2 {
18     contents: isize,
19 }
20
21 impl Trait<isize> for S2 {
22     fn new<U>(x: isize, _: U) -> S2 {
23         S2 {
24             contents: x,
25         }
26     }
27 }
28
29 fn foo<'a>() {
30     let _ = S::new::<isize,f64>(1, 1.0);
31     //~^ ERROR this associated function takes 1
32
33     let _ = S::<'a,isize>::new::<f64>(1, 1.0);
34     //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
35
36     let _: S2 = Trait::new::<isize,f64>(1, 1.0);
37     //~^ ERROR this associated function takes 1
38
39     let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
40     //~^ ERROR this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
41     //~| ERROR this associated function takes 1
42 }
43
44 fn main() {}