Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f46806f

Browse files
committed
Add ui test suggest-remove-deref-issue-140166
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
1 parent d7df5bd commit f46806f

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
trait Trait {}
2+
3+
struct Chars;
4+
impl Trait for Chars {}
5+
6+
struct FlatMap<T>(T);
7+
impl<T: Trait> std::fmt::Debug for FlatMap<T> {
8+
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9+
unimplemented!()
10+
}
11+
}
12+
13+
fn lol() {
14+
format_args!("{:?}", FlatMap(&Chars));
15+
//~^ ERROR the trait bound `&Chars: Trait` is not satisfied [E0277]
16+
}
17+
18+
fn main() {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0277]: the trait bound `&Chars: Trait` is not satisfied
2+
--> $DIR/suggest-remove-deref-issue-140166.rs:14:26
3+
|
4+
LL | format_args!("{:?}", FlatMap(&Chars));
5+
| ---- ^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `&Chars`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
note: required for `FlatMap<&Chars>` to implement `Debug`
10+
--> $DIR/suggest-remove-deref-issue-140166.rs:7:16
11+
|
12+
LL | impl<T: Trait> std::fmt::Debug for FlatMap<T> {
13+
| ----- ^^^^^^^^^^^^^^^ ^^^^^^^^^^
14+
| |
15+
| unsatisfied trait bound introduced here
16+
note: required by a bound in `core::fmt::rt::Argument::<'_>::new_debug`
17+
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
18+
help: consider removing the leading `&`-reference
19+
|
20+
LL - format_args!("{:?}", FlatMap(&Chars));
21+
LL + format_args!("{:?}", latMap(&Chars));
22+
|
23+
24+
error: aborting due to 1 previous error
25+
26+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)