about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaiki Ihara <sasurau4@gmail.com>2021-01-15 22:33:51 +0900
committerDaiki Ihara <sasurau4@gmail.com>2021-01-18 21:57:15 +0900
commit8b041cd8f99ba27393d857623f4e9ee502fed29d (patch)
treecda0c2f1550fb9e0ed04ebebb4c2559b93f1350e
parentdb95b5ca9bb0631108ea85ee80caf9abb11dee6e (diff)
downloadrust-8b041cd8f99ba27393d857623f4e9ee502fed29d.tar.gz
rust-8b041cd8f99ba27393d857623f4e9ee502fed29d.zip
Add test case for suggestion E0283
-rw-r--r--src/test/ui/error-codes/E0283.rs18
-rw-r--r--src/test/ui/error-codes/E0283.stderr16
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`.