about summary refs log tree commit diff
path: root/compiler/rustc_parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-11-10 13:04:51 +0000
committerbors <bors@rust-lang.org>2022-11-10 13:04:51 +0000
commit01a6f30324deb8f9c9ec4a70c53690c5d073a244 (patch)
tree8766879d89fb49dd661fc3fb41847f330f75e908 /compiler/rustc_parse
parent11fa0850f03ae49fe1053a21bcdcf8a301668ad8 (diff)
parent609bea9c50cf4c98dbcfdd647129a0f8cae3b9a1 (diff)
downloadrust-01a6f30324deb8f9c9ec4a70c53690c5d073a244.tar.gz
rust-01a6f30324deb8f9c9ec4a70c53690c5d073a244.zip
Auto merge of #104236 - compiler-errors:rollup-adjshd6, r=compiler-errors
Rollup of 9 pull requests

Successful merges:

 - #102763 (Some diagnostic-related nits)
 - #103443 (Parser: Recover from using colon as path separator in imports)
 - #103675 (remove redundent "<>" for ty::Slice with reference type)
 - #104046 (bootstrap: add support for running Miri on a file)
 - #104115 (Migrate crate-search element to CSS variables)
 - #104190 (Ignore "Change InferCtxtBuilder from enter to build" in git blame)
 - #104201 (Add check in GUI test for file loading failure)
 - #104211 (:arrow_up: rust-analyzer)
 - #104231 (Update mailmap)

Failed merges:

 - #104169 (Migrate `:target` rules to use CSS variables)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse')
-rw-r--r--compiler/rustc_parse/src/parser/item.rs17
-rw-r--r--compiler/rustc_parse/src/parser/ty.rs2
2 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index bda301c52e9..d657a289117 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -971,6 +971,23 @@ impl<'a> Parser<'a> {
             if self.eat(&token::ModSep) {
                 self.parse_use_tree_glob_or_nested()?
             } else {
+                // Recover from using a colon as path separator.
+                while self.eat_noexpect(&token::Colon) {
+                    self.struct_span_err(self.prev_token.span, "expected `::`, found `:`")
+                        .span_suggestion_short(
+                            self.prev_token.span,
+                            "use double colon",
+                            "::",
+                            Applicability::MachineApplicable,
+                        )
+                        .note_once("import paths are delimited using `::`")
+                        .emit();
+
+                    // We parse the rest of the path and append it to the original prefix.
+                    self.parse_path_segments(&mut prefix.segments, PathStyle::Mod, None)?;
+                    prefix.span = lo.to(self.prev_token.span);
+                }
+
                 UseTreeKind::Simple(self.parse_rename()?, DUMMY_NODE_ID, DUMMY_NODE_ID)
             }
         };
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs
index 2a8512acf8c..3a67c032b3b 100644
--- a/compiler/rustc_parse/src/parser/ty.rs
+++ b/compiler/rustc_parse/src/parser/ty.rs
@@ -401,7 +401,7 @@ impl<'a> Parser<'a> {
                 .span_suggestions(
                     span.shrink_to_hi(),
                     "add `mut` or `const` here",
-                    ["mut ".to_string(), "const ".to_string()].into_iter(),
+                    ["mut ".to_string(), "const ".to_string()],
                     Applicability::HasPlaceholders,
                 )
                 .emit();