diff options
| author | aticu <15schnic@gmail.com> | 2022-06-12 17:46:57 +0200 |
|---|---|---|
| committer | aticu <15schnic@gmail.com> | 2022-07-19 10:16:10 +0200 |
| commit | 1cbacc0c8aa3c4d99a073108d4ec7a535ff79102 (patch) | |
| tree | 757fd4f91afb91217782aebe83c7919919ce407f /src/test/ui/error-codes | |
| parent | 96c2df810b0b681fee63cae11ca63844792b6190 (diff) | |
| download | rust-1cbacc0c8aa3c4d99a073108d4ec7a535ff79102.tar.gz rust-1cbacc0c8aa3c4d99a073108d4ec7a535ff79102.zip | |
Add E0790 as more specific variant of E0283
Diffstat (limited to 'src/test/ui/error-codes')
| -rw-r--r-- | src/test/ui/error-codes/E0283.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0283.stderr | 15 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0790.rs | 53 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0790.stderr | 73 |
4 files changed, 138 insertions, 5 deletions
diff --git a/src/test/ui/error-codes/E0283.rs b/src/test/ui/error-codes/E0283.rs index 4d7c2f2396d..0643af4b7e8 100644 --- a/src/test/ui/error-codes/E0283.rs +++ b/src/test/ui/error-codes/E0283.rs @@ -27,7 +27,7 @@ impl Generator for AnotherImpl { } fn main() { - let cont: u32 = Generator::create(); //~ ERROR E0283 + let cont: u32 = Generator::create(); //~ ERROR E0790 } fn buzz() { diff --git a/src/test/ui/error-codes/E0283.stderr b/src/test/ui/error-codes/E0283.stderr index a107160d11a..90a28874ead 100644 --- a/src/test/ui/error-codes/E0283.stderr +++ b/src/test/ui/error-codes/E0283.stderr @@ -1,10 +1,16 @@ -error[E0283]: type annotations needed +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/E0283.rs:30:21 | +LL | fn create() -> u32; + | ------------------- `Generator::create` defined here +... LL | let cont: u32 = Generator::create(); - | ^^^^^^^^^^^^^^^^^ cannot infer type + | ^^^^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use a fully-qualified path to a specific available implementation (2 found) | - = note: cannot satisfy `_: Generator` +LL | let cont: u32 = <::Impl as Generator>::create(); + | ++++++++++ + error[E0283]: type annotations needed --> $DIR/E0283.rs:35:24 @@ -27,4 +33,5 @@ LL | let bar = <Impl as Into<T>>::into(foo_impl) * 1u32; error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0283`. +Some errors have detailed explanations: E0283, E0790. +For more information about an error, try `rustc --explain E0283`. diff --git a/src/test/ui/error-codes/E0790.rs b/src/test/ui/error-codes/E0790.rs new file mode 100644 index 00000000000..d99006d2df7 --- /dev/null +++ b/src/test/ui/error-codes/E0790.rs @@ -0,0 +1,53 @@ +mod inner { + pub trait MyTrait { + const MY_ASSOC_CONST: (); + + fn my_fn(); + } + + pub struct MyStruct; + + impl MyTrait for MyStruct { + const MY_ASSOC_CONST: () = (); + + fn my_fn() {} + } + + fn call() { + MyTrait::my_fn(); //~ ERROR E0790 + } + + fn use_const() { + let _ = MyTrait::MY_ASSOC_CONST; //~ ERROR E0790 + } +} + +fn call_inner() { + inner::MyTrait::my_fn(); //~ ERROR E0790 +} + +fn use_const_inner() { + let _ = inner::MyTrait::MY_ASSOC_CONST; //~ ERROR E0790 +} + +trait MyTrait2 { + fn my_fn(); +} + +struct Impl1; + +impl MyTrait2 for Impl1 { + fn my_fn() {} +} + +struct Impl2; + +impl MyTrait2 for Impl2 { + fn my_fn() {} +} + +fn call_multiple_impls() { + MyTrait2::my_fn(); //~ ERROR E0790 +} + +fn main() {} diff --git a/src/test/ui/error-codes/E0790.stderr b/src/test/ui/error-codes/E0790.stderr new file mode 100644 index 00000000000..6e173a9682a --- /dev/null +++ b/src/test/ui/error-codes/E0790.stderr @@ -0,0 +1,73 @@ +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:17:9 + | +LL | fn my_fn(); + | ----------- `MyTrait::my_fn` defined here +... +LL | MyTrait::my_fn(); + | ^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use the fully-qualified path to the only available implementation + | +LL | <::inner::MyStruct as MyTrait>::my_fn(); + | +++++++++++++++++++++ + + +error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:21:17 + | +LL | const MY_ASSOC_CONST: (); + | ------------------------- `MyTrait::MY_ASSOC_CONST` defined here +... +LL | let _ = MyTrait::MY_ASSOC_CONST; + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot refer to the associated constant of trait + | +help: use the fully-qualified path to the only available implementation + | +LL | let _ = <::inner::MyStruct as MyTrait>::MY_ASSOC_CONST; + | +++++++++++++++++++++ + + +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:26:5 + | +LL | fn my_fn(); + | ----------- `MyTrait::my_fn` defined here +... +LL | inner::MyTrait::my_fn(); + | ^^^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use the fully-qualified path to the only available implementation + | +LL | inner::<::inner::MyStruct as MyTrait>::my_fn(); + | +++++++++++++++++++++ + + +error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:30:13 + | +LL | const MY_ASSOC_CONST: (); + | ------------------------- `MyTrait::MY_ASSOC_CONST` defined here +... +LL | let _ = inner::MyTrait::MY_ASSOC_CONST; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot refer to the associated constant of trait + | +help: use the fully-qualified path to the only available implementation + | +LL | let _ = inner::<::inner::MyStruct as MyTrait>::MY_ASSOC_CONST; + | +++++++++++++++++++++ + + +error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type + --> $DIR/E0790.rs:50:5 + | +LL | fn my_fn(); + | ----------- `MyTrait2::my_fn` defined here +... +LL | MyTrait2::my_fn(); + | ^^^^^^^^^^^^^^^ cannot call associated function of trait + | +help: use a fully-qualified path to a specific available implementation (2 found) + | +LL | <::Impl1 as MyTrait2>::my_fn(); + | +++++++++++ + + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0790`. |
