From 8b041cd8f99ba27393d857623f4e9ee502fed29d Mon Sep 17 00:00:00 2001 From: Daiki Ihara Date: Fri, 15 Jan 2021 22:33:51 +0900 Subject: [PATCH] Add test case for suggestion E0283 --- src/test/ui/error-codes/E0283.rs | 18 ++++++++++++++++++ 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 for Impl { + fn into(self) -> u32 { 1 } +} + +fn foo(bar: u32) {} + struct AnotherImpl; impl Generator for AnotherImpl { @@ -17,3 +29,9 @@ fn create() -> u32 { 2 } 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: `>::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`.