about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index eb2a87100d3..4a45d9b9bef 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -1367,12 +1367,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
 
                         // Issue #109436, we need to add parentheses properly for method calls
                         // for example, `foo.into()` should be `(&foo).into()`
-                        if let Ok(snippet) = self
-                            .tcx
-                            .sess
-                            .source_map()
-                            .span_to_snippet(self.tcx.sess.source_map().next_point(span))
-                        {
+                        if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(
+                            self.tcx.sess.source_map().span_look_ahead(span, Some("."), Some(50)),
+                        ) {
                             if snippet == "." {
                                 err.multipart_suggestion_verbose(
                                     sugg_msg,