Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Apr 4, 2024
1 parent ede0556 commit 4e8d2f0
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/ui/methods/opaque_param_in_ufc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#![feature(type_alias_impl_trait)]
struct Foo<T>(T);

impl Foo<u32> {
fn method() {}
fn method2(self) {}
}

type Bar = impl Sized;

fn bar() -> Bar {
42_u32
}

impl Foo<Bar> {
fn foo() -> Bar {
Self::method();
//~^ ERROR: no function or associated item named `method` found for struct `Foo<Bar>`
Foo::<Bar>::method();
//~^ ERROR: no function or associated item named `method` found for struct `Foo<Bar>`
let x = Foo(bar());
Foo::method2(x);
let x = Self(bar());
Self::method2(x);
//~^ ERROR: no function or associated item named `method2` found for struct `Foo<Bar>`
todo!()
}
}

fn main() {}
36 changes: 36 additions & 0 deletions tests/ui/methods/opaque_param_in_ufc.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
error[E0599]: no function or associated item named `method` found for struct `Foo<Bar>` in the current scope
--> $DIR/opaque_param_in_ufc.rs:17:15
|
LL | struct Foo<T>(T);
| ------------- function or associated item `method` not found for this struct
...
LL | Self::method();
| ^^^^^^ function or associated item not found in `Foo<Bar>`
|
= note: the function or associated item was found for
- `Foo<u32>`

error[E0599]: no function or associated item named `method` found for struct `Foo<Bar>` in the current scope
--> $DIR/opaque_param_in_ufc.rs:19:21
|
LL | struct Foo<T>(T);
| ------------- function or associated item `method` not found for this struct
...
LL | Foo::<Bar>::method();
| ^^^^^^ function or associated item not found in `Foo<Bar>`
|
= note: the function or associated item was found for
- `Foo<u32>`

error[E0599]: no function or associated item named `method2` found for struct `Foo<Bar>` in the current scope
--> $DIR/opaque_param_in_ufc.rs:24:15
|
LL | struct Foo<T>(T);
| ------------- function or associated item `method2` not found for this struct
...
LL | Self::method2(x);
| ^^^^^^^ function or associated item not found in `Foo<Bar>`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0599`.

0 comments on commit 4e8d2f0

Please sign in to comment.