]> git.lizzy.rs Git - rust.git/blob - crates/ide_completion/src/completions/attribute.rs
Merge #9062
[rust.git] / crates / ide_completion / src / completions / attribute.rs
1 //! Completion for attributes
2 //!
3 //! This module uses a bit of static metadata to provide completions
4 //! for built-in attributes.
5
6 use once_cell::sync::Lazy;
7 use rustc_hash::{FxHashMap, FxHashSet};
8 use syntax::{ast, AstNode, NodeOrToken, SyntaxKind, T};
9
10 use crate::{
11     context::CompletionContext,
12     generated_lint_completions::{CLIPPY_LINTS, FEATURES},
13     item::{CompletionItem, CompletionItemKind, CompletionKind},
14     Completions,
15 };
16
17 mod derive;
18 mod lint;
19 pub(crate) use self::lint::LintCompletion;
20
21 pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
22     let attribute = ctx.attribute_under_caret.as_ref()?;
23     match (attribute.path().and_then(|p| p.as_single_name_ref()), attribute.token_tree()) {
24         (Some(path), Some(token_tree)) => match path.text().as_str() {
25             "derive" => derive::complete_derive(acc, ctx, token_tree),
26             "feature" => lint::complete_lint(acc, ctx, token_tree, FEATURES),
27             "allow" | "warn" | "deny" | "forbid" => {
28                 lint::complete_lint(acc, ctx, token_tree.clone(), lint::DEFAULT_LINT_COMPLETIONS);
29                 lint::complete_lint(acc, ctx, token_tree, CLIPPY_LINTS);
30             }
31             _ => (),
32         },
33         (None, Some(_)) => (),
34         _ => complete_new_attribute(acc, ctx, attribute),
35     }
36     Some(())
37 }
38
39 fn complete_new_attribute(acc: &mut Completions, ctx: &CompletionContext, attribute: &ast::Attr) {
40     let attribute_annotated_item_kind = attribute.syntax().parent().map(|it| it.kind());
41     let attributes = attribute_annotated_item_kind.and_then(|kind| {
42         if ast::Expr::can_cast(kind) {
43             Some(EXPR_ATTRIBUTES)
44         } else {
45             KIND_TO_ATTRIBUTES.get(&kind).copied()
46         }
47     });
48     let is_inner = attribute.kind() == ast::AttrKind::Inner;
49
50     let add_completion = |attr_completion: &AttrCompletion| {
51         let mut item = CompletionItem::new(
52             CompletionKind::Attribute,
53             ctx.source_range(),
54             attr_completion.label,
55         );
56         item.kind(CompletionItemKind::Attribute);
57
58         if let Some(lookup) = attr_completion.lookup {
59             item.lookup_by(lookup);
60         }
61
62         if let Some((snippet, cap)) = attr_completion.snippet.zip(ctx.config.snippet_cap) {
63             item.insert_snippet(cap, snippet);
64         }
65
66         if is_inner || !attr_completion.prefer_inner {
67             acc.add(item.build());
68         }
69     };
70
71     match attributes {
72         Some(applicable) => applicable
73             .iter()
74             .flat_map(|name| ATTRIBUTES.binary_search_by(|attr| attr.key().cmp(name)).ok())
75             .flat_map(|idx| ATTRIBUTES.get(idx))
76             .for_each(add_completion),
77         None if is_inner => ATTRIBUTES.iter().for_each(add_completion),
78         None => ATTRIBUTES.iter().filter(|compl| !compl.prefer_inner).for_each(add_completion),
79     }
80 }
81
82 struct AttrCompletion {
83     label: &'static str,
84     lookup: Option<&'static str>,
85     snippet: Option<&'static str>,
86     prefer_inner: bool,
87 }
88
89 impl AttrCompletion {
90     fn key(&self) -> &'static str {
91         self.lookup.unwrap_or(self.label)
92     }
93
94     const fn prefer_inner(self) -> AttrCompletion {
95         AttrCompletion { prefer_inner: true, ..self }
96     }
97 }
98
99 const fn attr(
100     label: &'static str,
101     lookup: Option<&'static str>,
102     snippet: Option<&'static str>,
103 ) -> AttrCompletion {
104     AttrCompletion { label, lookup, snippet, prefer_inner: false }
105 }
106
107 macro_rules! attrs {
108     // attributes applicable to all items
109     [@ { item $($tt:tt)* } {$($acc:tt)*}] => {
110         attrs!(@ { $($tt)* } { $($acc)*, "deprecated", "doc", "dochidden", "docalias", "must_use", "no_mangle" })
111     };
112     // attributes applicable to all adts
113     [@ { adt $($tt:tt)* } {$($acc:tt)*}] => {
114         attrs!(@ { $($tt)* } { $($acc)*, "derive", "repr" })
115     };
116     // attributes applicable to all linkable things aka functions/statics
117     [@ { linkable $($tt:tt)* } {$($acc:tt)*}] => {
118         attrs!(@ { $($tt)* } { $($acc)*, "export_name", "link_name", "link_section" })
119     };
120     // error fallback for nicer error message
121     [@ { $ty:ident $($tt:tt)* } {$($acc:tt)*}] => {
122         compile_error!(concat!("unknown attr subtype ", stringify!($ty)))
123     };
124     // general push down accumulation
125     [@ { $lit:literal $($tt:tt)*} {$($acc:tt)*}] => {
126         attrs!(@ { $($tt)* } { $($acc)*, $lit })
127     };
128     [@ {$($tt:tt)+} {$($tt2:tt)*}] => {
129         compile_error!(concat!("Unexpected input ", stringify!($($tt)+)))
130     };
131     // final output construction
132     [@ {} {$($tt:tt)*}] => { &[$($tt)*] as _ };
133     // starting matcher
134     [$($tt:tt),*] => {
135         attrs!(@ { $($tt)* } { "allow", "cfg", "cfg_attr", "deny", "forbid", "warn" })
136     };
137 }
138
139 #[rustfmt::skip]
140 static KIND_TO_ATTRIBUTES: Lazy<FxHashMap<SyntaxKind, &[&str]>> = Lazy::new(|| {
141     use SyntaxKind::*;
142     std::array::IntoIter::new([
143         (
144             SOURCE_FILE,
145             attrs!(
146                 item,
147                 "crate_name", "feature", "no_implicit_prelude", "no_main", "no_std",
148                 "recursion_limit", "type_length_limit", "windows_subsystem"
149             ),
150         ),
151         (MODULE, attrs!(item, "no_implicit_prelude", "path")),
152         (ITEM_LIST, attrs!(item, "no_implicit_prelude")),
153         (MACRO_RULES, attrs!(item, "macro_export", "macro_use")),
154         (MACRO_DEF, attrs!(item)),
155         (EXTERN_CRATE, attrs!(item, "macro_use", "no_link")),
156         (USE, attrs!(item)),
157         (TYPE_ALIAS, attrs!(item)),
158         (STRUCT, attrs!(item, adt, "non_exhaustive")),
159         (ENUM, attrs!(item, adt, "non_exhaustive")),
160         (UNION, attrs!(item, adt)),
161         (CONST, attrs!(item)),
162         (
163             FN,
164             attrs!(
165                 item, linkable,
166                 "cold", "ignore", "inline", "must_use", "panic_handler", "proc_macro",
167                 "proc_macro_derive", "proc_macro_attribute", "should_panic", "target_feature",
168                 "test", "track_caller"
169             ),
170         ),
171         (STATIC, attrs!(item, linkable, "global_allocator", "used")),
172         (TRAIT, attrs!(item, "must_use")),
173         (IMPL, attrs!(item, "automatically_derived")),
174         (ASSOC_ITEM_LIST, attrs!(item)),
175         (EXTERN_BLOCK, attrs!(item, "link")),
176         (EXTERN_ITEM_LIST, attrs!(item, "link")),
177         (MACRO_CALL, attrs!()),
178         (SELF_PARAM, attrs!()),
179         (PARAM, attrs!()),
180         (RECORD_FIELD, attrs!()),
181         (VARIANT, attrs!("non_exhaustive")),
182         (TYPE_PARAM, attrs!()),
183         (CONST_PARAM, attrs!()),
184         (LIFETIME_PARAM, attrs!()),
185         (LET_STMT, attrs!()),
186         (EXPR_STMT, attrs!()),
187         (LITERAL, attrs!()),
188         (RECORD_EXPR_FIELD_LIST, attrs!()),
189         (RECORD_EXPR_FIELD, attrs!()),
190         (MATCH_ARM_LIST, attrs!()),
191         (MATCH_ARM, attrs!()),
192         (IDENT_PAT, attrs!()),
193         (RECORD_PAT_FIELD, attrs!()),
194     ])
195     .collect()
196 });
197 const EXPR_ATTRIBUTES: &[&str] = attrs!();
198
199 /// https://doc.rust-lang.org/reference/attributes.html#built-in-attributes-index
200 // Keep these sorted for the binary search!
201 const ATTRIBUTES: &[AttrCompletion] = &[
202     attr("allow(…)", Some("allow"), Some("allow(${0:lint})")),
203     attr("automatically_derived", None, None),
204     attr("cfg(…)", Some("cfg"), Some("cfg(${0:predicate})")),
205     attr("cfg_attr(…)", Some("cfg_attr"), Some("cfg_attr(${1:predicate}, ${0:attr})")),
206     attr("cold", None, None),
207     attr(r#"crate_name = """#, Some("crate_name"), Some(r#"crate_name = "${0:crate_name}""#))
208         .prefer_inner(),
209     attr("deny(…)", Some("deny"), Some("deny(${0:lint})")),
210     attr(r#"deprecated"#, Some("deprecated"), Some(r#"deprecated"#)),
211     attr("derive(…)", Some("derive"), Some(r#"derive(${0:Debug})"#)),
212     attr(r#"doc = "…""#, Some("doc"), Some(r#"doc = "${0:docs}""#)),
213     attr(r#"doc(alias = "…")"#, Some("docalias"), Some(r#"doc(alias = "${0:docs}")"#)),
214     attr(r#"doc(hidden)"#, Some("dochidden"), Some(r#"doc(hidden)"#)),
215     attr(
216         r#"export_name = "…""#,
217         Some("export_name"),
218         Some(r#"export_name = "${0:exported_symbol_name}""#),
219     ),
220     attr("feature(…)", Some("feature"), Some("feature(${0:flag})")).prefer_inner(),
221     attr("forbid(…)", Some("forbid"), Some("forbid(${0:lint})")),
222     // FIXME: resolve through macro resolution?
223     attr("global_allocator", None, None).prefer_inner(),
224     attr(r#"ignore = "…""#, Some("ignore"), Some(r#"ignore = "${0:reason}""#)),
225     attr("inline", Some("inline"), Some("inline")),
226     attr("link", None, None),
227     attr(r#"link_name = "…""#, Some("link_name"), Some(r#"link_name = "${0:symbol_name}""#)),
228     attr(
229         r#"link_section = "…""#,
230         Some("link_section"),
231         Some(r#"link_section = "${0:section_name}""#),
232     ),
233     attr("macro_export", None, None),
234     attr("macro_use", None, None),
235     attr(r#"must_use"#, Some("must_use"), Some(r#"must_use"#)),
236     attr("no_implicit_prelude", None, None).prefer_inner(),
237     attr("no_link", None, None).prefer_inner(),
238     attr("no_main", None, None).prefer_inner(),
239     attr("no_mangle", None, None),
240     attr("no_std", None, None).prefer_inner(),
241     attr("non_exhaustive", None, None),
242     attr("panic_handler", None, None).prefer_inner(),
243     attr(r#"path = "…""#, Some("path"), Some(r#"path ="${0:path}""#)),
244     attr("proc_macro", None, None),
245     attr("proc_macro_attribute", None, None),
246     attr("proc_macro_derive(…)", Some("proc_macro_derive"), Some("proc_macro_derive(${0:Trait})")),
247     attr("recursion_limit = …", Some("recursion_limit"), Some("recursion_limit = ${0:128}"))
248         .prefer_inner(),
249     attr("repr(…)", Some("repr"), Some("repr(${0:C})")),
250     attr("should_panic", Some("should_panic"), Some(r#"should_panic"#)),
251     attr(
252         r#"target_feature = "…""#,
253         Some("target_feature"),
254         Some(r#"target_feature = "${0:feature}""#),
255     ),
256     attr("test", None, None),
257     attr("track_caller", None, None),
258     attr("type_length_limit = …", Some("type_length_limit"), Some("type_length_limit = ${0:128}"))
259         .prefer_inner(),
260     attr("used", None, None),
261     attr("warn(…)", Some("warn"), Some("warn(${0:lint})")),
262     attr(
263         r#"windows_subsystem = "…""#,
264         Some("windows_subsystem"),
265         Some(r#"windows_subsystem = "${0:subsystem}""#),
266     )
267     .prefer_inner(),
268 ];
269
270 fn parse_comma_sep_input(derive_input: ast::TokenTree) -> Option<FxHashSet<String>> {
271     let (l_paren, r_paren) = derive_input.l_paren_token().zip(derive_input.r_paren_token())?;
272     let mut input_derives = FxHashSet::default();
273     let mut tokens = derive_input
274         .syntax()
275         .children_with_tokens()
276         .filter_map(NodeOrToken::into_token)
277         .skip_while(|token| token != &l_paren)
278         .skip(1)
279         .take_while(|token| token != &r_paren)
280         .peekable();
281     let mut input = String::new();
282     while tokens.peek().is_some() {
283         for token in tokens.by_ref().take_while(|t| t.kind() != T![,]) {
284             input.push_str(token.text());
285         }
286
287         if !input.is_empty() {
288             input_derives.insert(input.trim().to_owned());
289         }
290
291         input.clear();
292     }
293
294     Some(input_derives)
295 }
296
297 #[cfg(test)]
298 mod tests {
299     use super::*;
300
301     use expect_test::{expect, Expect};
302
303     use crate::{test_utils::completion_list, CompletionKind};
304
305     #[test]
306     fn attributes_are_sorted() {
307         let mut attrs = ATTRIBUTES.iter().map(|attr| attr.key());
308         let mut prev = attrs.next().unwrap();
309
310         attrs.for_each(|next| {
311             assert!(
312                 prev < next,
313                 r#"ATTRIBUTES array is not sorted, "{}" should come after "{}""#,
314                 prev,
315                 next
316             );
317             prev = next;
318         });
319     }
320
321     fn check(ra_fixture: &str, expect: Expect) {
322         let actual = completion_list(ra_fixture, CompletionKind::Attribute);
323         expect.assert_eq(&actual);
324     }
325
326     #[test]
327     fn test_attribute_completion_inside_nested_attr() {
328         check(r#"#[cfg($0)]"#, expect![[]])
329     }
330
331     #[test]
332     fn test_attribute_completion_with_existing_attr() {
333         check(
334             r#"#[no_mangle] #[$0] mcall!();"#,
335             expect![[r#"
336                 at allow(…)
337                 at cfg(…)
338                 at cfg_attr(…)
339                 at deny(…)
340                 at forbid(…)
341                 at warn(…)
342             "#]],
343         )
344     }
345
346     #[test]
347     fn complete_attribute_on_source_file() {
348         check(
349             r#"#![$0]"#,
350             expect![[r#"
351                 at allow(…)
352                 at cfg(…)
353                 at cfg_attr(…)
354                 at deny(…)
355                 at forbid(…)
356                 at warn(…)
357                 at deprecated
358                 at doc = "…"
359                 at doc(hidden)
360                 at doc(alias = "…")
361                 at must_use
362                 at no_mangle
363                 at crate_name = ""
364                 at feature(…)
365                 at no_implicit_prelude
366                 at no_main
367                 at no_std
368                 at recursion_limit = …
369                 at type_length_limit = …
370                 at windows_subsystem = "…"
371             "#]],
372         );
373     }
374
375     #[test]
376     fn complete_attribute_on_module() {
377         check(
378             r#"#[$0] mod foo;"#,
379             expect![[r#"
380             at allow(…)
381             at cfg(…)
382             at cfg_attr(…)
383             at deny(…)
384             at forbid(…)
385             at warn(…)
386             at deprecated
387             at doc = "…"
388             at doc(hidden)
389             at doc(alias = "…")
390             at must_use
391             at no_mangle
392             at path = "…"
393         "#]],
394         );
395         check(
396             r#"mod foo {#![$0]}"#,
397             expect![[r#"
398                 at allow(…)
399                 at cfg(…)
400                 at cfg_attr(…)
401                 at deny(…)
402                 at forbid(…)
403                 at warn(…)
404                 at deprecated
405                 at doc = "…"
406                 at doc(hidden)
407                 at doc(alias = "…")
408                 at must_use
409                 at no_mangle
410                 at no_implicit_prelude
411             "#]],
412         );
413     }
414
415     #[test]
416     fn complete_attribute_on_macro_rules() {
417         check(
418             r#"#[$0] macro_rules! foo {}"#,
419             expect![[r#"
420                 at allow(…)
421                 at cfg(…)
422                 at cfg_attr(…)
423                 at deny(…)
424                 at forbid(…)
425                 at warn(…)
426                 at deprecated
427                 at doc = "…"
428                 at doc(hidden)
429                 at doc(alias = "…")
430                 at must_use
431                 at no_mangle
432                 at macro_export
433                 at macro_use
434             "#]],
435         );
436     }
437
438     #[test]
439     fn complete_attribute_on_macro_def() {
440         check(
441             r#"#[$0] macro foo {}"#,
442             expect![[r#"
443                 at allow(…)
444                 at cfg(…)
445                 at cfg_attr(…)
446                 at deny(…)
447                 at forbid(…)
448                 at warn(…)
449                 at deprecated
450                 at doc = "…"
451                 at doc(hidden)
452                 at doc(alias = "…")
453                 at must_use
454                 at no_mangle
455             "#]],
456         );
457     }
458
459     #[test]
460     fn complete_attribute_on_extern_crate() {
461         check(
462             r#"#[$0] extern crate foo;"#,
463             expect![[r#"
464                 at allow(…)
465                 at cfg(…)
466                 at cfg_attr(…)
467                 at deny(…)
468                 at forbid(…)
469                 at warn(…)
470                 at deprecated
471                 at doc = "…"
472                 at doc(hidden)
473                 at doc(alias = "…")
474                 at must_use
475                 at no_mangle
476                 at macro_use
477             "#]],
478         );
479     }
480
481     #[test]
482     fn complete_attribute_on_use() {
483         check(
484             r#"#[$0] use foo;"#,
485             expect![[r#"
486                 at allow(…)
487                 at cfg(…)
488                 at cfg_attr(…)
489                 at deny(…)
490                 at forbid(…)
491                 at warn(…)
492                 at deprecated
493                 at doc = "…"
494                 at doc(hidden)
495                 at doc(alias = "…")
496                 at must_use
497                 at no_mangle
498             "#]],
499         );
500     }
501
502     #[test]
503     fn complete_attribute_on_type_alias() {
504         check(
505             r#"#[$0] type foo = ();"#,
506             expect![[r#"
507                 at allow(…)
508                 at cfg(…)
509                 at cfg_attr(…)
510                 at deny(…)
511                 at forbid(…)
512                 at warn(…)
513                 at deprecated
514                 at doc = "…"
515                 at doc(hidden)
516                 at doc(alias = "…")
517                 at must_use
518                 at no_mangle
519             "#]],
520         );
521     }
522
523     #[test]
524     fn complete_attribute_on_struct() {
525         check(
526             r#"#[$0] struct Foo;"#,
527             expect![[r#"
528                 at allow(…)
529                 at cfg(…)
530                 at cfg_attr(…)
531                 at deny(…)
532                 at forbid(…)
533                 at warn(…)
534                 at deprecated
535                 at doc = "…"
536                 at doc(hidden)
537                 at doc(alias = "…")
538                 at must_use
539                 at no_mangle
540                 at derive(…)
541                 at repr(…)
542                 at non_exhaustive
543             "#]],
544         );
545     }
546
547     #[test]
548     fn complete_attribute_on_enum() {
549         check(
550             r#"#[$0] enum Foo {}"#,
551             expect![[r#"
552                 at allow(…)
553                 at cfg(…)
554                 at cfg_attr(…)
555                 at deny(…)
556                 at forbid(…)
557                 at warn(…)
558                 at deprecated
559                 at doc = "…"
560                 at doc(hidden)
561                 at doc(alias = "…")
562                 at must_use
563                 at no_mangle
564                 at derive(…)
565                 at repr(…)
566                 at non_exhaustive
567             "#]],
568         );
569     }
570
571     #[test]
572     fn complete_attribute_on_const() {
573         check(
574             r#"#[$0] const FOO: () = ();"#,
575             expect![[r#"
576                 at allow(…)
577                 at cfg(…)
578                 at cfg_attr(…)
579                 at deny(…)
580                 at forbid(…)
581                 at warn(…)
582                 at deprecated
583                 at doc = "…"
584                 at doc(hidden)
585                 at doc(alias = "…")
586                 at must_use
587                 at no_mangle
588             "#]],
589         );
590     }
591
592     #[test]
593     fn complete_attribute_on_static() {
594         check(
595             r#"#[$0] static FOO: () = ()"#,
596             expect![[r#"
597                 at allow(…)
598                 at cfg(…)
599                 at cfg_attr(…)
600                 at deny(…)
601                 at forbid(…)
602                 at warn(…)
603                 at deprecated
604                 at doc = "…"
605                 at doc(hidden)
606                 at doc(alias = "…")
607                 at must_use
608                 at no_mangle
609                 at export_name = "…"
610                 at link_name = "…"
611                 at link_section = "…"
612                 at used
613             "#]],
614         );
615     }
616
617     #[test]
618     fn complete_attribute_on_trait() {
619         check(
620             r#"#[$0] trait Foo {}"#,
621             expect![[r#"
622                 at allow(…)
623                 at cfg(…)
624                 at cfg_attr(…)
625                 at deny(…)
626                 at forbid(…)
627                 at warn(…)
628                 at deprecated
629                 at doc = "…"
630                 at doc(hidden)
631                 at doc(alias = "…")
632                 at must_use
633                 at no_mangle
634                 at must_use
635             "#]],
636         );
637     }
638
639     #[test]
640     fn complete_attribute_on_impl() {
641         check(
642             r#"#[$0] impl () {}"#,
643             expect![[r#"
644                 at allow(…)
645                 at cfg(…)
646                 at cfg_attr(…)
647                 at deny(…)
648                 at forbid(…)
649                 at warn(…)
650                 at deprecated
651                 at doc = "…"
652                 at doc(hidden)
653                 at doc(alias = "…")
654                 at must_use
655                 at no_mangle
656                 at automatically_derived
657             "#]],
658         );
659         check(
660             r#"impl () {#![$0]}"#,
661             expect![[r#"
662                 at allow(…)
663                 at cfg(…)
664                 at cfg_attr(…)
665                 at deny(…)
666                 at forbid(…)
667                 at warn(…)
668                 at deprecated
669                 at doc = "…"
670                 at doc(hidden)
671                 at doc(alias = "…")
672                 at must_use
673                 at no_mangle
674             "#]],
675         );
676     }
677
678     #[test]
679     fn complete_attribute_on_extern_block() {
680         check(
681             r#"#[$0] extern {}"#,
682             expect![[r#"
683                 at allow(…)
684                 at cfg(…)
685                 at cfg_attr(…)
686                 at deny(…)
687                 at forbid(…)
688                 at warn(…)
689                 at deprecated
690                 at doc = "…"
691                 at doc(hidden)
692                 at doc(alias = "…")
693                 at must_use
694                 at no_mangle
695                 at link
696             "#]],
697         );
698         check(
699             r#"extern {#![$0]}"#,
700             expect![[r#"
701                 at allow(…)
702                 at cfg(…)
703                 at cfg_attr(…)
704                 at deny(…)
705                 at forbid(…)
706                 at warn(…)
707                 at deprecated
708                 at doc = "…"
709                 at doc(hidden)
710                 at doc(alias = "…")
711                 at must_use
712                 at no_mangle
713                 at link
714             "#]],
715         );
716     }
717
718     #[test]
719     fn complete_attribute_on_variant() {
720         check(
721             r#"enum Foo { #[$0] Bar }"#,
722             expect![[r#"
723                 at allow(…)
724                 at cfg(…)
725                 at cfg_attr(…)
726                 at deny(…)
727                 at forbid(…)
728                 at warn(…)
729                 at non_exhaustive
730             "#]],
731         );
732     }
733
734     #[test]
735     fn complete_attribute_on_expr() {
736         check(
737             r#"fn main() { #[$0] foo() }"#,
738             expect![[r#"
739                 at allow(…)
740                 at cfg(…)
741                 at cfg_attr(…)
742                 at deny(…)
743                 at forbid(…)
744                 at warn(…)
745             "#]],
746         );
747         check(
748             r#"fn main() { #[$0] foo(); }"#,
749             expect![[r#"
750                 at allow(…)
751                 at cfg(…)
752                 at cfg_attr(…)
753                 at deny(…)
754                 at forbid(…)
755                 at warn(…)
756             "#]],
757         );
758     }
759 }