File tree Expand file tree Collapse file tree 3 files changed +68
-2
lines changed
rust-analyzer/tests/slow-tests Expand file tree Collapse file tree 3 files changed +68
-2
lines changed Original file line number Diff line number Diff line change @@ -295,9 +295,12 @@ impl Completions {
295
295
Visible :: Editable => true ,
296
296
Visible :: No => return ,
297
297
} ;
298
+ let doc_aliases = ctx. doc_aliases ( & func) ;
298
299
self . add (
299
300
render_fn (
300
- RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
301
+ RenderContext :: new ( ctx)
302
+ . private_editable ( is_private_editable)
303
+ . doc_aliases ( doc_aliases) ,
301
304
path_ctx,
302
305
local_name,
303
306
func,
@@ -322,9 +325,12 @@ impl Completions {
322
325
Visible :: Editable => true ,
323
326
Visible :: No => return ,
324
327
} ;
328
+ let doc_aliases = ctx. doc_aliases ( & func) ;
325
329
self . add (
326
330
render_method (
327
- RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
331
+ RenderContext :: new ( ctx)
332
+ . private_editable ( is_private_editable)
333
+ . doc_aliases ( doc_aliases) ,
328
334
dot_access,
329
335
receiver,
330
336
local_name,
@@ -349,10 +355,12 @@ impl Completions {
349
355
Visible :: Editable => true ,
350
356
Visible :: No => return ,
351
357
} ;
358
+ let doc_aliases = ctx. doc_aliases ( & func) ;
352
359
self . add (
353
360
render_method (
354
361
RenderContext :: new ( ctx)
355
362
. private_editable ( is_private_editable)
363
+ . doc_aliases ( doc_aliases)
356
364
. import_to_add ( Some ( import) ) ,
357
365
dot_access,
358
366
None ,
Original file line number Diff line number Diff line change @@ -1106,6 +1106,62 @@ fn here_we_go() {
1106
1106
) ;
1107
1107
}
1108
1108
1109
+ #[ test]
1110
+ fn completes_struct_fn_name_via_doc_alias_in_fn_body ( ) {
1111
+ check (
1112
+ r#"
1113
+ struct Foo;
1114
+ impl Foo {
1115
+ #[doc(alias = "qux")]
1116
+ fn bar() -> u8 { 1 }
1117
+ }
1118
+
1119
+ fn here_we_go() {
1120
+ Foo::q$0
1121
+ }
1122
+ "# ,
1123
+ expect ! [ [ r#"
1124
+ fn bar() (alias qux) fn() -> u8
1125
+ "# ] ] ,
1126
+ ) ;
1127
+ }
1128
+
1129
+ #[ test]
1130
+ fn completes_method_name_via_doc_alias_in_fn_body ( ) {
1131
+ check (
1132
+ r#"
1133
+ struct Foo {
1134
+ bar: u8
1135
+ }
1136
+ impl Foo {
1137
+ #[doc(alias = "qux")]
1138
+ fn baz(&self) -> u8 {
1139
+ self.bar
1140
+ }
1141
+ }
1142
+
1143
+ fn here_we_go() {
1144
+ let foo = Foo { field: 42 };
1145
+ foo.q$0
1146
+ }
1147
+ "# ,
1148
+ expect ! [ [ r#"
1149
+ fd bar u8
1150
+ me baz() (alias qux) fn(&self) -> u8
1151
+ sn box Box::new(expr)
1152
+ sn call function(expr)
1153
+ sn dbg dbg!(expr)
1154
+ sn dbgr dbg!(&expr)
1155
+ sn let let
1156
+ sn letm let mut
1157
+ sn match match expr {}
1158
+ sn ref &expr
1159
+ sn refm &mut expr
1160
+ sn unsafe unsafe {}
1161
+ "# ] ] ,
1162
+ ) ;
1163
+ }
1164
+
1109
1165
#[ test]
1110
1166
fn completes_fn_name_via_doc_alias_in_fn_body ( ) {
1111
1167
check (
Original file line number Diff line number Diff line change @@ -257,6 +257,8 @@ fn check_dbg(path: &Path, text: &str) {
257
257
"ide-db/src/generated/lints.rs" ,
258
258
// test for doc test for remove_dbg
259
259
"src/tests/generated.rs" ,
260
+ // `expect!` string can contain `dbg!` (due to .dbg postfix)
261
+ "ide-completion/src/tests/special.rs" ,
260
262
] ;
261
263
if need_dbg. iter ( ) . any ( |p| path. ends_with ( p) ) {
262
264
return ;
You can’t perform that action at this time.
0 commit comments