Skip to content

Commit 4e8d2f0

Browse files
committed
Add regression test
1 parent ede0556 commit 4e8d2f0

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

Diff for: tests/ui/methods/opaque_param_in_ufc.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![feature(type_alias_impl_trait)]
2+
struct Foo<T>(T);
3+
4+
impl Foo<u32> {
5+
fn method() {}
6+
fn method2(self) {}
7+
}
8+
9+
type Bar = impl Sized;
10+
11+
fn bar() -> Bar {
12+
42_u32
13+
}
14+
15+
impl Foo<Bar> {
16+
fn foo() -> Bar {
17+
Self::method();
18+
//~^ ERROR: no function or associated item named `method` found for struct `Foo<Bar>`
19+
Foo::<Bar>::method();
20+
//~^ ERROR: no function or associated item named `method` found for struct `Foo<Bar>`
21+
let x = Foo(bar());
22+
Foo::method2(x);
23+
let x = Self(bar());
24+
Self::method2(x);
25+
//~^ ERROR: no function or associated item named `method2` found for struct `Foo<Bar>`
26+
todo!()
27+
}
28+
}
29+
30+
fn main() {}

Diff for: tests/ui/methods/opaque_param_in_ufc.stderr

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error[E0599]: no function or associated item named `method` found for struct `Foo<Bar>` in the current scope
2+
--> $DIR/opaque_param_in_ufc.rs:17:15
3+
|
4+
LL | struct Foo<T>(T);
5+
| ------------- function or associated item `method` not found for this struct
6+
...
7+
LL | Self::method();
8+
| ^^^^^^ function or associated item not found in `Foo<Bar>`
9+
|
10+
= note: the function or associated item was found for
11+
- `Foo<u32>`
12+
13+
error[E0599]: no function or associated item named `method` found for struct `Foo<Bar>` in the current scope
14+
--> $DIR/opaque_param_in_ufc.rs:19:21
15+
|
16+
LL | struct Foo<T>(T);
17+
| ------------- function or associated item `method` not found for this struct
18+
...
19+
LL | Foo::<Bar>::method();
20+
| ^^^^^^ function or associated item not found in `Foo<Bar>`
21+
|
22+
= note: the function or associated item was found for
23+
- `Foo<u32>`
24+
25+
error[E0599]: no function or associated item named `method2` found for struct `Foo<Bar>` in the current scope
26+
--> $DIR/opaque_param_in_ufc.rs:24:15
27+
|
28+
LL | struct Foo<T>(T);
29+
| ------------- function or associated item `method2` not found for this struct
30+
...
31+
LL | Self::method2(x);
32+
| ^^^^^^^ function or associated item not found in `Foo<Bar>`
33+
34+
error: aborting due to 3 previous errors
35+
36+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)