Customize error messages for self glob imports.

This commit is contained in:
Victor Berger 2015-08-07 12:00:46 +02:00
parent 3d041bd46d
commit 5847ea7619
2 changed files with 16 additions and 2 deletions

View file

@ -785,7 +785,11 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
// In this case, target_module == module_
// This means we are trying to glob import a module into itself,
// and it is a no-go
return ResolveResult::Indeterminate;
debug!("(resolving glob imports) target module is current module; giving up");
return ResolveResult::Failed(Some((
import_directive.span,
"Cannot glob-import a module into itself.".into()
)));
}
for (ident, target_import_resolution) in import_resolutions.iter() {

View file

@ -8,7 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use self::*; //~ ERROR: unresolved import
use self::*; //~ ERROR: unresolved import `self::*`. Cannot glob-import a module into itself.
mod foo {
use foo::*; //~ ERROR: unresolved import `foo::*`. Cannot glob-import a module into itself.
mod bar {
use super::bar::*;
//~^ ERROR: unresolved import `super::bar::*`. Cannot glob-import a module into itself.
}
}
fn main() {
}