@@ -30,8 +30,7 @@ use crate::diagnostics::{DiagMode, Suggestion, import_candidates};
30
30
use crate :: errors:: {
31
31
CannotBeReexportedCratePublic , CannotBeReexportedCratePublicNS , CannotBeReexportedPrivate ,
32
32
CannotBeReexportedPrivateNS , CannotDetermineImportResolution , CannotGlobImportAllCrates ,
33
- ConsiderAddingMacroExport , ConsiderMarkingAsPub , IsNotDirectlyImportable ,
34
- ItemsInTraitsAreNotImportable ,
33
+ ConsiderAddingMacroExport , ConsiderMarkingAsPub ,
35
34
} ;
36
35
use crate :: {
37
36
AmbiguityError , AmbiguityKind , BindingKey , Finalize , ImportSuggestion , Module ,
@@ -835,11 +834,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
835
834
836
835
let parent = import. parent_scope . module ;
837
836
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 ( )
843
839
&& !this. tcx . features ( ) . import_trait_associated_functions ( )
844
840
{
845
841
feature_err (
@@ -850,21 +846,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
850
846
)
851
847
. emit ( ) ;
852
848
}
849
+
853
850
let imported_binding = this. import ( binding, import) ;
854
851
target_bindings[ ns] . set ( Some ( imported_binding) ) ;
855
852
this. define ( parent, target, ns, imported_binding) ;
856
853
}
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
+ } ) ;
862
861
}
863
- let key = BindingKey :: new ( target, ns) ;
864
- this. update_resolution ( parent, key, false , |_, resolution| {
865
- resolution. single_imports . remove ( & import) ;
866
- } ) ;
867
862
}
863
+ Err ( Undetermined ) => indeterminate_count += 1 ,
868
864
}
869
865
}
870
866
} ) ;
@@ -1428,10 +1424,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1428
1424
return ;
1429
1425
} ;
1430
1426
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 {
1435
1438
return ;
1436
1439
} else if is_prelude {
1437
1440
self . prelude = Some ( module) ;
0 commit comments