Check & before suggest remove deref when trait_selection
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
parent
f46806fb14
commit
bd88f3e3e3
2 changed files with 7 additions and 5 deletions
|
|
@ -1516,6 +1516,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
} else {
|
||||
expr.span.with_hi(expr.span.lo() + BytePos(1))
|
||||
};
|
||||
|
||||
match self.tcx.sess.source_map().span_to_snippet(span) {
|
||||
Ok(snippet) if snippet.starts_with("&") => {}
|
||||
_ => break 'outer,
|
||||
}
|
||||
|
||||
suggestions.push((span, String::new()));
|
||||
|
||||
let ty::Ref(_, inner_ty, _) = suggested_ty.kind() else {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ LL | format_args!("{:?}", FlatMap(&Chars));
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= help: the trait `Trait` is implemented for `Chars`
|
||||
note: required for `FlatMap<&Chars>` to implement `Debug`
|
||||
--> $DIR/suggest-remove-deref-issue-140166.rs:7:16
|
||||
|
|
||||
|
|
@ -15,11 +16,6 @@ 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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue