Forbid use Trait::*

This commit is contained in:
Jeffrey Seyfried 2016-03-08 22:27:12 +00:00
parent e2171bff75
commit 1a6092e05c
2 changed files with 7 additions and 0 deletions

View File

@ -586,6 +586,10 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
target_module: Module<'b>,
directive: &'b ImportDirective)
-> ResolveResult<()> {
if let Some(Def::Trait(_)) = target_module.def {
self.resolver.session.span_err(directive.span, "items in traits are not importable.");
}
if module_.def_id() == target_module.def_id() {
// This means we are trying to glob import a module into itself, and it is a no-go
let msg = "Cannot glob-import a module into itself.".into();

View File

@ -12,4 +12,7 @@ type Alias = ();
use Alias::*; //~ ERROR Not a module
use std::io::Result::*; //~ ERROR Not a module
trait T {}
use T::*; //~ ERROR items in traits are not importable
fn main() {}