about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-06-02 23:39:05 +0200
committerGitHub <noreply@github.com>2022-06-02 23:39:05 +0200
commit0e33e97fc742315bf8dd6a3bc2f3616935f73e68 (patch)
treeae3766f09b503d1e9e6169bc542b7fefcc8bc752 /src
parent992ca9b601c7ebc895c1fe3698077fafaa946548 (diff)
parent28988902a2d1410ff2f8f13bb146420a128c5754 (diff)
downloadrust-0e33e97fc742315bf8dd6a3bc2f3616935f73e68.tar.gz
rust-0e33e97fc742315bf8dd6a3bc2f3616935f73e68.zip
Rollup merge of #97640 - TaKO8Ki:fix-wrong-suggestion-for-adding-where-clauses, r=lcnr
Fix wrong suggestion for adding where clauses

closes #97576
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/traits/issue-97576.rs13
-rw-r--r--src/test/ui/traits/issue-97576.stderr11
2 files changed, 24 insertions, 0 deletions
diff --git a/src/test/ui/traits/issue-97576.rs b/src/test/ui/traits/issue-97576.rs
new file mode 100644
index 00000000000..fdc85e9fa89
--- /dev/null
+++ b/src/test/ui/traits/issue-97576.rs
@@ -0,0 +1,13 @@
+struct Foo {
+    bar: String,
+}
+
+impl Foo {
+    pub fn new(bar: impl ToString) -> Self {
+        Self {
+            bar: bar.into(), //~ ERROR the trait bound `String: From<impl ToString>` is not satisfied
+        }
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/issue-97576.stderr b/src/test/ui/traits/issue-97576.stderr
new file mode 100644
index 00000000000..bdee073d6e3
--- /dev/null
+++ b/src/test/ui/traits/issue-97576.stderr
@@ -0,0 +1,11 @@
+error[E0277]: the trait bound `String: From<impl ToString>` is not satisfied
+  --> $DIR/issue-97576.rs:8:22
+   |
+LL |             bar: bar.into(),
+   |                      ^^^^ the trait `From<impl ToString>` is not implemented for `String`
+   |
+   = note: required because of the requirements on the impl of `Into<String>` for `impl ToString`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.