about summary refs log tree commit diff
diff options
context:
space:
mode:
authorxizheyin <xizheyin@smail.nju.edu.cn>2025-05-07 17:27:56 +0800
committerxizheyin <xizheyin@smail.nju.edu.cn>2025-05-07 17:32:59 +0800
commitf46806fb14d9ef9ba76b836019f9e2705b213c97 (patch)
tree9052f82708b4a203c239d0903f3f4ef5ab52c2eb
parentd7df5bdf2986e596aeaeec38e732711c69ebbce1 (diff)
downloadrust-f46806fb14d9ef9ba76b836019f9e2705b213c97.tar.gz
rust-f46806fb14d9ef9ba76b836019f9e2705b213c97.zip
Add ui test suggest-remove-deref-issue-140166
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
-rw-r--r--tests/ui/traits/suggest-remove-deref-issue-140166.rs18
-rw-r--r--tests/ui/traits/suggest-remove-deref-issue-140166.stderr26
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/ui/traits/suggest-remove-deref-issue-140166.rs b/tests/ui/traits/suggest-remove-deref-issue-140166.rs
new file mode 100644
index 00000000000..1b832c7eba5
--- /dev/null
+++ b/tests/ui/traits/suggest-remove-deref-issue-140166.rs
@@ -0,0 +1,18 @@
+trait Trait {}
+
+struct Chars;
+impl Trait for Chars {}
+
+struct FlatMap<T>(T);
+impl<T: Trait> std::fmt::Debug for FlatMap<T> {
+    fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        unimplemented!()
+    }
+}
+
+fn lol() {
+    format_args!("{:?}", FlatMap(&Chars));
+    //~^ ERROR the trait bound `&Chars: Trait` is not satisfied [E0277]
+}
+
+fn main() {}
diff --git a/tests/ui/traits/suggest-remove-deref-issue-140166.stderr b/tests/ui/traits/suggest-remove-deref-issue-140166.stderr
new file mode 100644
index 00000000000..8bdcf5981a5
--- /dev/null
+++ b/tests/ui/traits/suggest-remove-deref-issue-140166.stderr
@@ -0,0 +1,26 @@
+error[E0277]: the trait bound `&Chars: Trait` is not satisfied
+  --> $DIR/suggest-remove-deref-issue-140166.rs:14:26
+   |
+LL |     format_args!("{:?}", FlatMap(&Chars));
+   |                   ----   ^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `&Chars`
+   |                   |
+   |                   required by a bound introduced by this call
+   |
+note: required for `FlatMap<&Chars>` to implement `Debug`
+  --> $DIR/suggest-remove-deref-issue-140166.rs:7:16
+   |
+LL | impl<T: Trait> std::fmt::Debug for FlatMap<T> {
+   |         -----  ^^^^^^^^^^^^^^^     ^^^^^^^^^^
+   |         |
+   |         unsatisfied trait bound introduced here
+note: required by a bound in `core::fmt::rt::Argument::<'_>::new_debug`
+  --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
+help: consider removing the leading `&`-reference
+   |
+LL -     format_args!("{:?}", FlatMap(&Chars));
+LL +     format_args!("{:?}", latMap(&Chars));
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.