@@ -17,9 +17,10 @@ use rustc_session::lint::builtin::{
17
17
AMBIGUOUS_GLOB_REEXPORTS , HIDDEN_GLOB_REEXPORTS , PUB_USE_OF_PRIVATE_EXTERN_CRATE ,
18
18
REDUNDANT_IMPORTS , UNUSED_IMPORTS ,
19
19
} ;
20
+ use rustc_session:: parse:: feature_err;
20
21
use rustc_span:: edit_distance:: find_best_match_for_name;
21
22
use rustc_span:: hygiene:: LocalExpnId ;
22
- use rustc_span:: { Ident , Span , Symbol , kw} ;
23
+ use rustc_span:: { Ident , Span , Symbol , kw, sym } ;
23
24
use smallvec:: SmallVec ;
24
25
use tracing:: debug;
25
26
@@ -29,8 +30,7 @@ use crate::diagnostics::{DiagMode, Suggestion, import_candidates};
29
30
use crate :: errors:: {
30
31
CannotBeReexportedCratePublic , CannotBeReexportedCratePublicNS , CannotBeReexportedPrivate ,
31
32
CannotBeReexportedPrivateNS , CannotDetermineImportResolution , CannotGlobImportAllCrates ,
32
- ConsiderAddingMacroExport , ConsiderMarkingAsPub , IsNotDirectlyImportable ,
33
- ItemsInTraitsAreNotImportable ,
33
+ ConsiderAddingMacroExport , ConsiderMarkingAsPub , ItemsInTraitsAreNotImportable ,
34
34
} ;
35
35
use crate :: {
36
36
AmbiguityError , AmbiguityKind , BindingKey , Finalize , ImportSuggestion , Module ,
@@ -828,16 +828,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
828
828
Err ( Undetermined ) => indeterminate_count += 1 ,
829
829
// Don't update the resolution, because it was never added.
830
830
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
+ {
832
835
let imported_binding = this. import ( binding, import) ;
833
836
target_bindings[ ns] . set ( Some ( imported_binding) ) ;
834
837
this. define ( parent, target, ns, imported_binding) ;
835
838
}
836
839
source_binding @ ( Ok ( ..) | Err ( Determined ) ) => {
837
840
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 ( ) ;
841
848
}
842
849
let key = BindingKey :: new ( target, ns) ;
843
850
this. update_resolution ( parent, key, false , |_, resolution| {
0 commit comments