Skip to content

Commit c832579

Browse files
committed
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.
1 parent 29e2376 commit c832579

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/librustc_resolve/error_reporting.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
121121
/// ```
122122
/// |
123123
/// LL | use foobar::Baz;
124-
/// | ^^^ Did you mean `baz::foobar`?
124+
/// | ^^^^^^ Did you mean `baz::foobar`?
125125
/// ```
126126
///
127127
/// 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> {
139139
path.insert(1, new_path_segment);
140140

141141
for name in &external_crate_names {
142-
// Don't suggest meta as it will error in `resolve_path`.
143-
if name.as_str() == "meta" {
144-
continue;
145-
}
146-
147-
// Replace the first after root (a placeholder we inserted) with a crate name
148-
// and check if that is valid.
149-
path[1].name = *name;
150-
let result = self.resolve_path(None, &path, None, false, span, CrateLint::No);
151-
debug!("make_external_crate_suggestion: name={:?} path={:?} result={:?}",
152-
name, path, result);
153-
if let PathResult::Module(..) = result {
154-
return Some(path)
142+
let ident = Ident::with_empty_ctxt(*name);
143+
// Calling `maybe_process_path_extern` ensures that we're only running `resolve_path`
144+
// on a crate name that won't ICE.
145+
if let Some(_) = self.crate_loader.maybe_process_path_extern(*name, ident.span) {
146+
// Replace the first after root (a placeholder we inserted) with a crate name
147+
// and check if that is valid.
148+
path[1].name = *name;
149+
let result = self.resolve_path(None, &path, None, false, span, CrateLint::No);
150+
debug!("make_external_crate_suggestion: name={:?} path={:?} result={:?}",
151+
name, path, result);
152+
if let PathResult::Module(..) = result {
153+
return Some(path)
154+
}
155155
}
156156
}
157157

0 commit comments

Comments
 (0)