@@ -17,9 +17,10 @@ use rustc_session::lint::builtin::{
1717 AMBIGUOUS_GLOB_REEXPORTS , HIDDEN_GLOB_REEXPORTS , PUB_USE_OF_PRIVATE_EXTERN_CRATE ,
1818 REDUNDANT_IMPORTS , UNUSED_IMPORTS ,
1919} ;
20+ use rustc_session:: parse:: feature_err;
2021use rustc_span:: edit_distance:: find_best_match_for_name;
2122use rustc_span:: hygiene:: LocalExpnId ;
22- use rustc_span:: { Ident , Span , Symbol , kw} ;
23+ use rustc_span:: { Ident , Span , Symbol , kw, sym } ;
2324use smallvec:: SmallVec ;
2425use tracing:: debug;
2526
@@ -29,8 +30,7 @@ use crate::diagnostics::{DiagMode, Suggestion, import_candidates};
2930use crate :: errors:: {
3031 CannotBeReexportedCratePublic , CannotBeReexportedCratePublicNS , CannotBeReexportedPrivate ,
3132 CannotBeReexportedPrivateNS , CannotDetermineImportResolution , CannotGlobImportAllCrates ,
32- ConsiderAddingMacroExport , ConsiderMarkingAsPub , IsNotDirectlyImportable ,
33- ItemsInTraitsAreNotImportable ,
33+ ConsiderAddingMacroExport , ConsiderMarkingAsPub , ItemsInTraitsAreNotImportable ,
3434} ;
3535use crate :: {
3636 AmbiguityError , AmbiguityKind , BindingKey , Finalize , ImportSuggestion , Module ,
@@ -828,16 +828,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
828828 Err ( Undetermined ) => indeterminate_count += 1 ,
829829 // Don't update the resolution, because it was never added.
830830 Err ( Determined ) if target. name == kw:: Underscore => { }
831- Ok ( binding) if binding. is_importable ( ) => {
831+ Ok ( binding)
832+ if binding. is_importable ( )
833+ || this. tcx . features ( ) . import_trait_associated_functions ( ) =>
834+ {
832835 let imported_binding = this. import ( binding, import) ;
833836 target_bindings[ ns] . set ( Some ( imported_binding) ) ;
834837 this. define ( parent, target, ns, imported_binding) ;
835838 }
836839 source_binding @ ( Ok ( ..) | Err ( Determined ) ) => {
837840 if source_binding. is_ok ( ) {
838- this. dcx ( )
839- . create_err ( IsNotDirectlyImportable { span : import. span , target } )
840- . emit ( ) ;
841+ feature_err (
842+ this. tcx . sess ,
843+ sym:: import_trait_associated_functions,
844+ import. span ,
845+ "`use` associated items of traits is unstable" ,
846+ )
847+ . emit ( ) ;
841848 }
842849 let key = BindingKey :: new ( target, ns) ;
843850 this. update_resolution ( parent, key, false , |_, resolution| {
0 commit comments