diff --git a/tests/ui/methods/opaque_param_in_ufc.rs b/tests/ui/methods/opaque_param_in_ufc.rs new file mode 100644 index 00000000000..a4b27a0131f --- /dev/null +++ b/tests/ui/methods/opaque_param_in_ufc.rs @@ -0,0 +1,30 @@ +#![feature(type_alias_impl_trait)] +struct Foo(T); + +impl Foo { + fn method() {} + fn method2(self) {} +} + +type Bar = impl Sized; + +fn bar() -> Bar { + 42_u32 +} + +impl Foo { + fn foo() -> Bar { + Self::method(); + //~^ ERROR: no function or associated item named `method` found for struct `Foo` + Foo::::method(); + //~^ ERROR: no function or associated item named `method` found for struct `Foo` + 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` + todo!() + } +} + +fn main() {} diff --git a/tests/ui/methods/opaque_param_in_ufc.stderr b/tests/ui/methods/opaque_param_in_ufc.stderr new file mode 100644 index 00000000000..7e5bbbac8a9 --- /dev/null +++ b/tests/ui/methods/opaque_param_in_ufc.stderr @@ -0,0 +1,36 @@ +error[E0599]: no function or associated item named `method` found for struct `Foo` in the current scope + --> $DIR/opaque_param_in_ufc.rs:17:15 + | +LL | struct Foo(T); + | ------------- function or associated item `method` not found for this struct +... +LL | Self::method(); + | ^^^^^^ function or associated item not found in `Foo` + | + = note: the function or associated item was found for + - `Foo` + +error[E0599]: no function or associated item named `method` found for struct `Foo` in the current scope + --> $DIR/opaque_param_in_ufc.rs:19:21 + | +LL | struct Foo(T); + | ------------- function or associated item `method` not found for this struct +... +LL | Foo::::method(); + | ^^^^^^ function or associated item not found in `Foo` + | + = note: the function or associated item was found for + - `Foo` + +error[E0599]: no function or associated item named `method2` found for struct `Foo` in the current scope + --> $DIR/opaque_param_in_ufc.rs:24:15 + | +LL | struct Foo(T); + | ------------- function or associated item `method2` not found for this struct +... +LL | Self::method2(x); + | ^^^^^^^ function or associated item not found in `Foo` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0599`.