about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev+love@gmail.com>2022-12-03 12:51:29 +0900
committerGitHub <noreply@github.com>2022-12-03 12:51:29 +0900
commit8f368666b55e4573f1399eb71ac4ee024234dfbb (patch)
tree499a0a3cfec1e157af85ec1c473903cc341dbf9e /src
parent019795b162901ea50af357b04a2a5eab325f4bfb (diff)
parent715d4a89499f9788f88baf2ec399a62698cd10e6 (diff)
downloadrust-8f368666b55e4573f1399eb71ac4ee024234dfbb.tar.gz
rust-8f368666b55e4573f1399eb71ac4ee024234dfbb.zip
Rollup merge of #105181 - bhbs:skip-note, r=estebank
Don't add a note for implementing a trait if its inner type is erroneous

Fix #105138
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/trait-bounds/impl-bound-with-references-error.rs20
-rw-r--r--src/test/ui/trait-bounds/impl-bound-with-references-error.stderr24
2 files changed, 44 insertions, 0 deletions
diff --git a/src/test/ui/trait-bounds/impl-bound-with-references-error.rs b/src/test/ui/trait-bounds/impl-bound-with-references-error.rs
new file mode 100644
index 00000000000..e5d0a1aaed0
--- /dev/null
+++ b/src/test/ui/trait-bounds/impl-bound-with-references-error.rs
@@ -0,0 +1,20 @@
+// Regression test for #105138.
+// This test ensures that the compiler does not add note
+// for implementation of trait whose inner type is erroneous.
+
+pub enum LabelText {
+    Plain,
+}
+
+impl<T> From<T> for LabelText
+//~^ ERROR conflicting implementations of trait `From<LabelText>` for type `LabelText` [E0119]
+where
+    T: Into<Cow<'static, str>>,
+    //~^ ERROR cannot find type `Cow` in this scope [E0412]
+{
+    fn from(text: T) -> Self {
+        LabelText::Plain(text.into())
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/trait-bounds/impl-bound-with-references-error.stderr b/src/test/ui/trait-bounds/impl-bound-with-references-error.stderr
new file mode 100644
index 00000000000..95fd6bd504c
--- /dev/null
+++ b/src/test/ui/trait-bounds/impl-bound-with-references-error.stderr
@@ -0,0 +1,24 @@
+error[E0412]: cannot find type `Cow` in this scope
+  --> $DIR/impl-bound-with-references-error.rs:12:13
+   |
+LL |     T: Into<Cow<'static, str>>,
+   |             ^^^ not found in this scope
+   |
+help: consider importing this enum
+   |
+LL | use std::borrow::Cow;
+   |
+
+error[E0119]: conflicting implementations of trait `From<LabelText>` for type `LabelText`
+  --> $DIR/impl-bound-with-references-error.rs:9:1
+   |
+LL | impl<T> From<T> for LabelText
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `core`:
+           - impl<T> From<T> for T;
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0119, E0412.
+For more information about an error, try `rustc --explain E0119`.