File tree Expand file tree Collapse file tree 2 files changed +53
-6
lines changed Expand file tree Collapse file tree 2 files changed +53
-6
lines changed Original file line number Diff line number Diff line change @@ -790,14 +790,26 @@ impl UseTree {
790
790
}
791
791
Some ( ( prefix, ImportKind :: Plain ) )
792
792
}
793
- ( Some ( prefix) , PathKind :: Super ( 0 ) ) => {
794
- // `some::path::self` == `some::path`
795
- if path. segments ( ) . is_empty ( ) {
796
- Some ( ( prefix, ImportKind :: TypeOnly ) )
797
- } else {
798
- None
793
+ ( Some ( mut prefix) , PathKind :: Super ( n) )
794
+ if * n > 0 && prefix. segments ( ) . is_empty ( ) =>
795
+ {
796
+ // `super::super` + `super::rest`
797
+ match & mut prefix. kind {
798
+ PathKind :: Super ( m) => {
799
+ cov_mark:: hit!( concat_super_mod_paths) ;
800
+ * m += * n;
801
+ for segment in path. segments ( ) {
802
+ prefix. push_segment ( segment. clone ( ) ) ;
803
+ }
804
+ Some ( ( prefix, ImportKind :: Plain ) )
805
+ }
806
+ _ => None ,
799
807
}
800
808
}
809
+ ( Some ( prefix) , PathKind :: Super ( 0 ) ) if path. segments ( ) . is_empty ( ) => {
810
+ // `some::path::self` == `some::path`
811
+ Some ( ( prefix, ImportKind :: TypeOnly ) )
812
+ }
801
813
( Some ( _) , _) => None ,
802
814
}
803
815
}
Original file line number Diff line number Diff line change @@ -890,3 +890,38 @@ pub struct Struct;
890
890
"# ] ] ,
891
891
) ;
892
892
}
893
+
894
+ #[ test]
895
+ fn braced_supers_in_use_tree ( ) {
896
+ cov_mark:: check!( concat_super_mod_paths) ;
897
+ check (
898
+ r#"
899
+ mod some_module {
900
+ pub fn unknown_func() {}
901
+ }
902
+
903
+ mod other_module {
904
+ mod some_submodule {
905
+ use { super::{ super::unknown_func, }, };
906
+ }
907
+ }
908
+
909
+ use some_module::unknown_func;
910
+ "# ,
911
+ expect ! [ [ r#"
912
+ crate
913
+ other_module: t
914
+ some_module: t
915
+ unknown_func: v
916
+
917
+ crate::some_module
918
+ unknown_func: v
919
+
920
+ crate::other_module
921
+ some_submodule: t
922
+
923
+ crate::other_module::some_submodule
924
+ unknown_func: v
925
+ "# ] ] ,
926
+ )
927
+ }
You can’t perform that action at this time.
0 commit comments