Skip to content

Commit

Permalink
show self suggestion when items are in the block
Browse files Browse the repository at this point in the history
  • Loading branch information
euclio committed Sep 6, 2016
1 parent 41ee2e9 commit 288e7ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,18 +588,16 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
Success(module) => module,
Indeterminate => return Indeterminate,
Failed(err) => {
let self_module = self.current_module.clone();
let self_module = self.module_map[&self.current_module.normal_ancestor_id.unwrap()];

let resolve_from_self_result = self.resolve_module_path_from_root(
&self_module, &module_path, 0, Some(span));

return match resolve_from_self_result {
Success(_) => {
let msg = format!("Did you mean `self::{}`?",
&names_to_string(module_path));
Failed(Some((span, msg)))
},
_ => Failed(err),
return if let Success(_) = resolve_from_self_result {
let msg = format!("Did you mean `self::{}`?", &names_to_string(module_path));
Failed(Some((span, msg)))
} else {
Failed(err)
};
},
};
Expand Down
11 changes: 11 additions & 0 deletions src/test/compile-fail/unresolved-import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ mod m {
use MyEnum::*; //~ ERROR unresolved import `MyEnum::*` [E0432]
//~^ Did you mean `self::MyEnum`?
}

mod items {
enum Enum {
Variant
}

use Enum::*; //~ ERROR unresolved import `Enum::*` [E0432]
//~^ Did you mean `self::Enum`?

fn item() {}
}

0 comments on commit 288e7ca

Please sign in to comment.