Skip to content

Commit 07fa633

Browse files
Merge pull request #20755 from A4-Tacks/doc-include
Add `doc = include_str!("…")` completion
2 parents 9fd6be3 + b9faa7f commit 07fa633

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

crates/ide-completion/src/completions/attribute.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ const fn attr(
231231
macro_rules! attrs {
232232
// attributes applicable to all items
233233
[@ { item $($tt:tt)* } {$($acc:tt)*}] => {
234-
attrs!(@ { $($tt)* } { $($acc)*, "deprecated", "doc", "dochidden", "docalias", "must_use", "no_mangle" })
234+
attrs!(@ { $($tt)* } { $($acc)*, "deprecated", "doc", "dochidden", "docalias", "docinclude", "must_use", "no_mangle" })
235235
};
236236
// attributes applicable to all adts
237237
[@ { adt $($tt:tt)* } {$($acc:tt)*}] => {
@@ -345,6 +345,7 @@ const ATTRIBUTES: &[AttrCompletion] = &[
345345
attr(r#"doc = "…""#, Some("doc"), Some(r#"doc = "${0:docs}""#)),
346346
attr(r#"doc(alias = "…")"#, Some("docalias"), Some(r#"doc(alias = "${0:docs}")"#)),
347347
attr(r#"doc(hidden)"#, Some("dochidden"), Some(r#"doc(hidden)"#)),
348+
attr(r#"doc = include_str!("…")"#, Some("docinclude"), Some(r#"doc = include_str!("$0")"#)),
348349
attr("expect(…)", Some("expect"), Some("expect(${0:lint})")),
349350
attr(
350351
r#"export_name = "…""#,

crates/ide-completion/src/tests/attribute.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct Foo(#[m$0] i32);
3333
at diagnostic::do_not_recommend
3434
at diagnostic::on_unimplemented
3535
at doc = "…"
36+
at doc = include_str!("…")
3637
at doc(alias = "…")
3738
at doc(hidden)
3839
at expect(…)
@@ -85,6 +86,7 @@ struct Foo;
8586
at deprecated
8687
at derive(…)
8788
at doc = "…"
89+
at doc = include_str!("…")
8890
at doc(alias = "…")
8991
at doc(hidden)
9092
at expect(…)
@@ -158,6 +160,7 @@ fn attr_on_source_file() {
158160
at deny(…)
159161
at deprecated
160162
at doc = "…"
163+
at doc = include_str!("…")
161164
at doc(alias = "…")
162165
at doc(hidden)
163166
at expect(…)
@@ -189,6 +192,7 @@ fn attr_on_module() {
189192
at deny(…)
190193
at deprecated
191194
at doc = "…"
195+
at doc = include_str!("…")
192196
at doc(alias = "…")
193197
at doc(hidden)
194198
at expect(…)
@@ -212,6 +216,7 @@ fn attr_on_module() {
212216
at deny(…)
213217
at deprecated
214218
at doc = "…"
219+
at doc = include_str!("…")
215220
at doc(alias = "…")
216221
at doc(hidden)
217222
at expect(…)
@@ -238,6 +243,7 @@ fn attr_on_macro_rules() {
238243
at deny(…)
239244
at deprecated
240245
at doc = "…"
246+
at doc = include_str!("…")
241247
at doc(alias = "…")
242248
at doc(hidden)
243249
at expect(…)
@@ -264,6 +270,7 @@ fn attr_on_macro_def() {
264270
at deny(…)
265271
at deprecated
266272
at doc = "…"
273+
at doc = include_str!("…")
267274
at doc(alias = "…")
268275
at doc(hidden)
269276
at expect(…)
@@ -288,6 +295,7 @@ fn attr_on_extern_crate() {
288295
at deny(…)
289296
at deprecated
290297
at doc = "…"
298+
at doc = include_str!("…")
291299
at doc(alias = "…")
292300
at doc(hidden)
293301
at expect(…)
@@ -313,6 +321,7 @@ fn attr_on_use() {
313321
at deny(…)
314322
at deprecated
315323
at doc = "…"
324+
at doc = include_str!("…")
316325
at doc(alias = "…")
317326
at doc(hidden)
318327
at expect(…)
@@ -337,6 +346,7 @@ fn attr_on_type_alias() {
337346
at deny(…)
338347
at deprecated
339348
at doc = "…"
349+
at doc = include_str!("…")
340350
at doc(alias = "…")
341351
at doc(hidden)
342352
at expect(…)
@@ -368,6 +378,7 @@ struct Foo;
368378
at derive(…)
369379
at derive_const macro derive_const
370380
at doc = "…"
381+
at doc = include_str!("…")
371382
at doc(alias = "…")
372383
at doc(hidden)
373384
at expect(…)
@@ -396,6 +407,7 @@ fn attr_on_enum() {
396407
at deprecated
397408
at derive(…)
398409
at doc = "…"
410+
at doc = include_str!("…")
399411
at doc(alias = "…")
400412
at doc(hidden)
401413
at expect(…)
@@ -422,6 +434,7 @@ fn attr_on_const() {
422434
at deny(…)
423435
at deprecated
424436
at doc = "…"
437+
at doc = include_str!("…")
425438
at doc(alias = "…")
426439
at doc(hidden)
427440
at expect(…)
@@ -446,6 +459,7 @@ fn attr_on_static() {
446459
at deny(…)
447460
at deprecated
448461
at doc = "…"
462+
at doc = include_str!("…")
449463
at doc(alias = "…")
450464
at doc(hidden)
451465
at expect(…)
@@ -476,6 +490,7 @@ fn attr_on_trait() {
476490
at deprecated
477491
at diagnostic::on_unimplemented
478492
at doc = "…"
493+
at doc = include_str!("…")
479494
at doc(alias = "…")
480495
at doc(hidden)
481496
at expect(…)
@@ -502,6 +517,7 @@ fn attr_on_impl() {
502517
at deprecated
503518
at diagnostic::do_not_recommend
504519
at doc = "…"
520+
at doc = include_str!("…")
505521
at doc(alias = "…")
506522
at doc(hidden)
507523
at expect(…)
@@ -522,6 +538,7 @@ fn attr_on_impl() {
522538
at deny(…)
523539
at deprecated
524540
at doc = "…"
541+
at doc = include_str!("…")
525542
at doc(alias = "…")
526543
at doc(hidden)
527544
at expect(…)
@@ -548,6 +565,7 @@ fn attr_with_qualifier() {
548565
at deprecated
549566
at do_not_recommend
550567
at doc = "…"
568+
at doc = include_str!("…")
551569
at doc(alias = "…")
552570
at doc(hidden)
553571
at expect(…)
@@ -566,6 +584,7 @@ fn attr_with_qualifier() {
566584
at deny(…)
567585
at deprecated
568586
at doc = "…"
587+
at doc = include_str!("…")
569588
at doc(alias = "…")
570589
at doc(hidden)
571590
at expect(…)
@@ -616,6 +635,7 @@ fn attr_on_extern_block() {
616635
at deny(…)
617636
at deprecated
618637
at doc = "…"
638+
at doc = include_str!("…")
619639
at doc(alias = "…")
620640
at doc(hidden)
621641
at expect(…)
@@ -637,6 +657,7 @@ fn attr_on_extern_block() {
637657
at deny(…)
638658
at deprecated
639659
at doc = "…"
660+
at doc = include_str!("…")
640661
at doc(alias = "…")
641662
at doc(hidden)
642663
at expect(…)
@@ -682,6 +703,7 @@ fn attr_on_fn() {
682703
at deny(…)
683704
at deprecated
684705
at doc = "…"
706+
at doc = include_str!("…")
685707
at doc(alias = "…")
686708
at doc(hidden)
687709
at expect(…)
@@ -724,6 +746,7 @@ fn attr_in_source_file_end() {
724746
at diagnostic::do_not_recommend
725747
at diagnostic::on_unimplemented
726748
at doc = "…"
749+
at doc = include_str!("…")
727750
at doc(alias = "…")
728751
at doc(hidden)
729752
at expect(…)

0 commit comments

Comments
 (0)