@@ -664,6 +664,14 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
664664
665665 self . per_ns ( |_, ns| {
666666 if let Some ( result) = result[ ns] . get ( ) . ok ( ) {
667+ if let NameBindingKind :: Import { directive, .. } = result. kind {
668+ // Skip canaries that resolve to the import itself.
669+ // These come from `use crate_name;`, which isn't really
670+ // ambiguous, as the import can't actually shadow itself.
671+ if directive. id == import. id {
672+ return ;
673+ }
674+ }
667675 if has_explicit_self {
668676 // There should only be one `self::x` (module-scoped) canary.
669677 assert_eq ! ( canary_results[ ns] . module_scope, None ) ;
@@ -718,22 +726,6 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
718726
719727 errors = true ;
720728
721- // Special-case the error when `self::x` finds its own `use x;`.
722- if has_external_crate &&
723- results. module_scope == Some ( span) &&
724- results. block_scopes . is_empty ( ) {
725- let msg = format ! ( "`{}` import is redundant" , name) ;
726- this. session . struct_span_err ( span, & msg)
727- . span_label ( span,
728- format ! ( "refers to external crate `::{}`" , name) )
729- . span_label ( span,
730- format ! ( "defines `self::{}`, shadowing itself" , name) )
731- . help ( & format ! ( "remove or write `::{}` explicitly instead" , name) )
732- . note ( "relative `use` paths enabled by `#![feature(uniform_paths)]`" )
733- . emit ( ) ;
734- return ;
735- }
736-
737729 let msg = format ! ( "`{}` import is ambiguous" , name) ;
738730 let mut err = this. session . struct_span_err ( span, & msg) ;
739731 let mut suggestion_choices = String :: new ( ) ;
0 commit comments