about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorxizheyin <xizheyin@smail.nju.edu.cn>2025-05-07 17:31:42 +0800
committerxizheyin <xizheyin@smail.nju.edu.cn>2025-05-07 23:23:25 +0800
commitbd88f3e3e3eefd781d5cc1f4fbc0630f50e70882 (patch)
tree58d2c0ddfc9cb0b39eb3cbe41d4f6ba867e49612 /compiler/rustc_trait_selection/src
parentf46806fb14d9ef9ba76b836019f9e2705b213c97 (diff)
downloadrust-bd88f3e3e3eefd781d5cc1f4fbc0630f50e70882.tar.gz
rust-bd88f3e3e3eefd781d5cc1f4fbc0630f50e70882.zip
Check `&` before suggest remove deref when trait_selection
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
index de251ae2893..8801397b775 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
@@ -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 {