From c832579fb7cd809d506a7d6e63bf50b36435563d Mon Sep 17 00:00:00 2001 From: David Wood Date: Fri, 28 Sep 2018 11:30:55 +0200 Subject: [PATCH] Removed hardcoded crate. 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 | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/librustc_resolve/error_reporting.rs b/src/librustc_resolve/error_reporting.rs index 3ca0a11c1bb5..7a66750d700b 100644 --- a/src/librustc_resolve/error_reporting.rs +++ b/src/librustc_resolve/error_reporting.rs @@ -121,7 +121,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { /// ``` /// | /// 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 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { 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) + } } }