diff options
| author | bors <bors@rust-lang.org> | 2021-01-19 00:00:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-19 00:00:21 +0000 |
| commit | 4ba1aaf35f1ad55ddd094ab751f62dcf227a3185 (patch) | |
| tree | 70d41777f7e19862c7155fd31a05315340ab634a /src/test | |
| parent | d98d2f57d9b98325ff075c343d2c7695b66dfa7d (diff) | |
| parent | 8b041cd8f99ba27393d857623f4e9ee502fed29d (diff) | |
| download | rust-4ba1aaf35f1ad55ddd094ab751f62dcf227a3185.tar.gz rust-4ba1aaf35f1ad55ddd094ab751f62dcf227a3185.zip | |
Auto merge of #81042 - sasurau4:fix/unclear-error-with-trait, r=estebank
Add suggestion for impl_candidates with E0283 Fix #42226
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/error-codes/E0283.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0283.stderr | 16 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/test/ui/error-codes/E0283.rs b/src/test/ui/error-codes/E0283.rs index 9bdcc9ac42a..4d7c2f2396d 100644 --- a/src/test/ui/error-codes/E0283.rs +++ b/src/test/ui/error-codes/E0283.rs @@ -8,6 +8,18 @@ impl Generator for Impl { fn create() -> u32 { 1 } } +impl Impl { + fn new() -> Self { + Impl{} + } +} + +impl Into<u32> for Impl { + fn into(self) -> u32 { 1 } +} + +fn foo(bar: u32) {} + struct AnotherImpl; impl Generator for AnotherImpl { @@ -17,3 +29,9 @@ impl Generator for AnotherImpl { fn main() { let cont: u32 = Generator::create(); //~ ERROR E0283 } + +fn buzz() { + let foo_impl = Impl::new(); + let bar = foo_impl.into() * 1u32; //~ ERROR E0283 + foo(bar); +} diff --git a/src/test/ui/error-codes/E0283.stderr b/src/test/ui/error-codes/E0283.stderr index e95583c91a7..2f0dfb6dd82 100644 --- a/src/test/ui/error-codes/E0283.stderr +++ b/src/test/ui/error-codes/E0283.stderr @@ -1,5 +1,5 @@ error[E0283]: type annotations needed - --> $DIR/E0283.rs:18:21 + --> $DIR/E0283.rs:30:21 | LL | fn create() -> u32; | ------------------- required by `Generator::create` @@ -9,6 +9,18 @@ LL | let cont: u32 = Generator::create(); | = note: cannot satisfy `_: Generator` -error: aborting due to previous error +error[E0283]: type annotations needed + --> $DIR/E0283.rs:35:24 + | +LL | let bar = foo_impl.into() * 1u32; + | ---------^^^^-- + | | | + | | cannot infer type for type parameter `T` declared on the trait `Into` + | this method call resolves to `T` + | help: use the fully qualified path for the potential candidate: `<Impl as Into<u32>>::into(foo_impl)` + | + = note: cannot satisfy `Impl: Into<_>` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0283`. |
