@@ -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
@@ -828,16 +829,33 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
828829 Err ( Undetermined ) => indeterminate_count += 1 ,
829830 // Don't update the resolution, because it was never added.
830831 Err ( Determined ) if target. name == kw:: Underscore => { }
831- Ok ( binding) if binding. is_importable ( ) => {
832+ Ok ( binding)
833+ if binding. is_importable ( )
834+ || binding. is_assoc_const_or_fn ( )
835+ && this. tcx . features ( ) . import_trait_associated_functions ( ) =>
836+ {
832837 let imported_binding = this. import ( binding, import) ;
833838 target_bindings[ ns] . set ( Some ( imported_binding) ) ;
834839 this. define ( parent, target, ns, imported_binding) ;
835840 }
836841 source_binding @ ( Ok ( ..) | Err ( Determined ) ) => {
837- if source_binding. is_ok ( ) {
838- this. dcx ( )
839- . create_err ( IsNotDirectlyImportable { span : import. span , target } )
842+ if let Ok ( binding) = source_binding {
843+ if binding. is_assoc_const_or_fn ( ) {
844+ feature_err (
845+ this. tcx . sess ,
846+ sym:: import_trait_associated_functions,
847+ import. span ,
848+ "`use` associated items of traits is unstable" ,
849+ )
840850 . emit ( ) ;
851+ } else {
852+ this. dcx ( )
853+ . create_err ( IsNotDirectlyImportable {
854+ span : import. span ,
855+ target,
856+ } )
857+ . emit ( ) ;
858+ }
841859 }
842860 let key = BindingKey :: new ( target, ns) ;
843861 this. update_resolution ( parent, key, false , |_, resolution| {
0 commit comments