Add ui test suggest-remove-deref-issue-140166
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
parent
d7df5bdf29
commit
f46806fb14
2 changed files with 44 additions and 0 deletions
18
tests/ui/traits/suggest-remove-deref-issue-140166.rs
Normal file
18
tests/ui/traits/suggest-remove-deref-issue-140166.rs
Normal file
|
|
@ -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
tests/ui/traits/suggest-remove-deref-issue-140166.stderr
Normal file
26
tests/ui/traits/suggest-remove-deref-issue-140166.stderr
Normal file
|
|
@ -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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue