]> git.lizzy.rs Git - rust.git/commitdiff
Removed hardcoded crate.
authorDavid Wood <david@davidtw.co>
Fri, 28 Sep 2018 09:30:55 +0000 (11:30 +0200)
committerDavid Wood <david@davidtw.co>
Wed, 3 Oct 2018 12:43:57 +0000 (14:43 +0200)
Previously, `meta` crate was hardcoded as attempting to resolve a path
with it would ICE. Now, we attempt to load each extern crate first so
that resolving a path involving that crate doesn't error.

src/librustc_resolve/error_reporting.rs

index 3ca0a11c1bb5664eddff534033b00fa5b4f83d8d..7a66750d700ba502da3c7fd9154303346c6a1a7e 100644 (file)
@@ -121,7 +121,7 @@ fn make_missing_super_suggestion(
     /// ```
     ///    |
     /// LL | use foobar::Baz;
-    ///    |     ^^^ Did you mean `baz::foobar`?
+    ///    |     ^^^^^^ Did you mean `baz::foobar`?
     /// ```
     ///
     /// Used when importing a submodule of an external crate but missing that crate's
@@ -139,19 +139,19 @@ fn make_external_crate_suggestion(
         path.insert(1, new_path_segment);
 
         for name in &external_crate_names {
-            // Don't suggest meta as it will error in `resolve_path`.
-            if name.as_str() == "meta" {
-                continue;
-            }
-
-            // Replace the first after root (a placeholder we inserted) with a crate name
-            // and check if that is valid.
-            path[1].name = *name;
-            let result = self.resolve_path(None, &path, None, false, span, CrateLint::No);
-            debug!("make_external_crate_suggestion: name={:?} path={:?} result={:?}",
-                   name, path, result);
-            if let PathResult::Module(..) = result {
-                return Some(path)
+            let ident = Ident::with_empty_ctxt(*name);
+            // Calling `maybe_process_path_extern` ensures that we're only running `resolve_path`
+            // on a crate name that won't ICE.
+            if let Some(_) = self.crate_loader.maybe_process_path_extern(*name, ident.span) {
+                // Replace the first after root (a placeholder we inserted) with a crate name
+                // and check if that is valid.
+                path[1].name = *name;
+                let result = self.resolve_path(None, &path, None, false, span, CrateLint::No);
+                debug!("make_external_crate_suggestion: name={:?} path={:?} result={:?}",
+                       name, path, result);
+                if let PathResult::Module(..) = result {
+                    return Some(path)
+                }
             }
         }