Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add ui test suggest-remove-deref-issue-140166
Signed-off-by: xizheyin <[email protected]>
  • Loading branch information
xizheyin committed May 7, 2025
commit f46806fb14d9ef9ba76b836019f9e2705b213c97
18 changes: 18 additions & 0 deletions tests/ui/traits/suggest-remove-deref-issue-140166.rs
Original file line number Diff line number Diff line change
@@ -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() {}
26 changes: 26 additions & 0 deletions tests/ui/traits/suggest-remove-deref-issue-140166.stderr
Original file line number Diff line number Diff line change
@@ -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`.