@@ -30,8 +30,7 @@ use crate::diagnostics::{DiagMode, Suggestion, import_candidates};
3030use crate :: errors:: {
3131 CannotBeReexportedCratePublic , CannotBeReexportedCratePublicNS , CannotBeReexportedPrivate ,
3232 CannotBeReexportedPrivateNS , CannotDetermineImportResolution , CannotGlobImportAllCrates ,
33- ConsiderAddingMacroExport , ConsiderMarkingAsPub , IsNotDirectlyImportable ,
34- ItemsInTraitsAreNotImportable ,
33+ ConsiderAddingMacroExport , ConsiderMarkingAsPub ,
3534} ;
3635use crate :: {
3736 AmbiguityError , AmbiguityKind , BindingKey , Finalize , ImportSuggestion , Module ,
@@ -835,11 +834,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
835834
836835 let parent = import. parent_scope . module ;
837836 match source_bindings[ ns] . get ( ) {
838- Err ( Undetermined ) => indeterminate_count += 1 ,
839- // Don't update the resolution, because it was never added.
840- Err ( Determined ) if target. name == kw:: Underscore => { }
841- Ok ( binding) if binding. is_importable ( ) => {
842- if binding. is_assoc_const_or_fn ( )
837+ Ok ( binding) => {
838+ if binding. is_assoc_item ( )
843839 && !this. tcx . features ( ) . import_trait_associated_functions ( )
844840 {
845841 feature_err (
@@ -850,21 +846,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
850846 )
851847 . emit ( ) ;
852848 }
849+
853850 let imported_binding = this. import ( binding, import) ;
854851 target_bindings[ ns] . set ( Some ( imported_binding) ) ;
855852 this. define ( parent, target, ns, imported_binding) ;
856853 }
857- source_binding @ ( Ok ( ..) | Err ( Determined ) ) => {
858- if source_binding. is_ok ( ) {
859- this. dcx ( )
860- . create_err ( IsNotDirectlyImportable { span : import. span , target } )
861- . emit ( ) ;
854+ Err ( Determined ) => {
855+ // Don't update the resolution for underscores, because it was never added.
856+ if target. name != kw:: Underscore {
857+ let key = BindingKey :: new ( target, ns) ;
858+ this. update_resolution ( parent, key, false , |_, resolution| {
859+ resolution. single_imports . remove ( & import) ;
860+ } ) ;
862861 }
863- let key = BindingKey :: new ( target, ns) ;
864- this. update_resolution ( parent, key, false , |_, resolution| {
865- resolution. single_imports . remove ( & import) ;
866- } ) ;
867862 }
863+ Err ( Undetermined ) => indeterminate_count += 1 ,
868864 }
869865 }
870866 } ) ;
@@ -1428,10 +1424,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14281424 return ;
14291425 } ;
14301426
1431- if module. is_trait ( ) {
1432- self . dcx ( ) . emit_err ( ItemsInTraitsAreNotImportable { span : import. span } ) ;
1433- return ;
1434- } else if module == import. parent_scope . module {
1427+ if module. is_trait ( ) && !self . tcx . features ( ) . import_trait_associated_functions ( ) {
1428+ feature_err (
1429+ self . tcx . sess ,
1430+ sym:: import_trait_associated_functions,
1431+ import. span ,
1432+ "`use` associated items of traits is unstable" ,
1433+ )
1434+ . emit ( ) ;
1435+ }
1436+
1437+ if module == import. parent_scope . module {
14351438 return ;
14361439 } else if is_prelude {
14371440 self . prelude = Some ( module) ;
0 commit comments