File tree Expand file tree Collapse file tree 2 files changed +51
-5
lines changed Expand file tree Collapse file tree 2 files changed +51
-5
lines changed Original file line number Diff line number Diff line change @@ -1141,20 +1141,22 @@ impl HirDisplay for Path {
1141
1141
write ! ( f, ">" ) ?;
1142
1142
}
1143
1143
( _, PathKind :: Plain ) => { }
1144
- ( _, PathKind :: Abs ) => write ! ( f , "::" ) ? ,
1144
+ ( _, PathKind :: Abs ) => { }
1145
1145
( _, PathKind :: Crate ) => write ! ( f, "crate" ) ?,
1146
1146
( _, PathKind :: Super ( 0 ) ) => write ! ( f, "self" ) ?,
1147
1147
( _, PathKind :: Super ( n) ) => {
1148
- write ! ( f, "super" ) ?;
1149
- for _ in 0 ..* n {
1150
- write ! ( f, "::super" ) ?;
1148
+ for i in 0 ..* n {
1149
+ if i > 0 {
1150
+ write ! ( f, "::" ) ?;
1151
+ }
1152
+ write ! ( f, "super" ) ?;
1151
1153
}
1152
1154
}
1153
1155
( _, PathKind :: DollarCrate ( _) ) => write ! ( f, "{{extern_crate}}" ) ?,
1154
1156
}
1155
1157
1156
1158
for ( seg_idx, segment) in self . segments ( ) . iter ( ) . enumerate ( ) {
1157
- if seg_idx != 0 {
1159
+ if ! matches ! ( self . kind ( ) , PathKind :: Plain ) || seg_idx > 0 {
1158
1160
write ! ( f, "::" ) ?;
1159
1161
}
1160
1162
write ! ( f, "{}" , segment. name) ?;
Original file line number Diff line number Diff line change @@ -962,6 +962,50 @@ fn main() { let foo_test = fo$0o(); }
962
962
```
963
963
"# ] ] ,
964
964
) ;
965
+
966
+ // Use literal `crate` in path
967
+ check (
968
+ r#"
969
+ pub struct X;
970
+
971
+ fn foo() -> crate::X { X }
972
+
973
+ fn main() { f$0oo(); }
974
+ "# ,
975
+ expect ! [ [ r#"
976
+ *foo*
977
+
978
+ ```rust
979
+ test
980
+ ```
981
+
982
+ ```rust
983
+ fn foo() -> crate::X
984
+ ```
985
+ "# ] ] ,
986
+ ) ;
987
+
988
+ // Check `super` in path
989
+ check (
990
+ r#"
991
+ pub struct X;
992
+
993
+ mod m { pub fn foo() -> super::X { super::X } }
994
+
995
+ fn main() { m::f$0oo(); }
996
+ "# ,
997
+ expect ! [ [ r#"
998
+ *foo*
999
+
1000
+ ```rust
1001
+ test::m
1002
+ ```
1003
+
1004
+ ```rust
1005
+ pub fn foo() -> super::X
1006
+ ```
1007
+ "# ] ] ,
1008
+ ) ;
965
1009
}
966
1010
967
1011
#[ test]
You can’t perform that action at this time.
0 commit comments