about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-07-11 22:03:08 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-07-12 03:02:58 +0000
commitb5f94c61f72cc85151dbd9bb1081fde2ab78f806 (patch)
treede02a6c64db5a42539228ceba8a051f3b9eda361 /compiler/rustc_parse/src
parentdd40e0b4eeef38d62e7053733ac7c2a327b135de (diff)
downloadrust-b5f94c61f72cc85151dbd9bb1081fde2ab78f806.tar.gz
rust-b5f94c61f72cc85151dbd9bb1081fde2ab78f806.zip
Use more accurate span for `:` to `::` suggestion
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/errors.rs4
-rw-r--r--compiler/rustc_parse/src/parser/path.rs2
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs
index d2a765247ad..18a3153bcd4 100644
--- a/compiler/rustc_parse/src/errors.rs
+++ b/compiler/rustc_parse/src/errors.rs
@@ -1562,9 +1562,11 @@ pub(crate) struct ExpectedFnPathFoundFnKeyword {
 #[diag(parse_path_single_colon)]
 pub(crate) struct PathSingleColon {
     #[primary_span]
-    #[suggestion(applicability = "machine-applicable", code = "::", style = "verbose")]
     pub span: Span,
 
+    #[suggestion(applicability = "machine-applicable", code = ":", style = "verbose")]
+    pub suggestion: Span,
+
     #[note(parse_type_ascription_removed)]
     pub type_ascription: Option<()>,
 }
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs
index 03c647dd527..b9014dea726 100644
--- a/compiler/rustc_parse/src/parser/path.rs
+++ b/compiler/rustc_parse/src/parser/path.rs
@@ -258,6 +258,7 @@ impl<'a> Parser<'a> {
                         self.bump(); // bump past the colon
                         self.dcx().emit_err(PathSingleColon {
                             span: self.prev_token.span,
+                            suggestion: self.prev_token.span.shrink_to_hi(),
                             type_ascription: self
                                 .psess
                                 .unstable_features
@@ -329,6 +330,7 @@ impl<'a> Parser<'a> {
                             err.cancel();
                             err = self.dcx().create_err(PathSingleColon {
                                 span: self.token.span,
+                                suggestion: self.prev_token.span.shrink_to_hi(),
                                 type_ascription: self
                                     .psess
                                     .unstable_features