Skip to content

Commit a0fa522

Browse files
bors[bot]Veykril
andauthored
Merge #6733
6733: Update attributes completion list r=jonas-schievink a=Veykril Might be nice to have them grouped for readability/maintainability similar to how the [reference](https://doc.rust-lang.org/reference/attributes.html#built-in-attributes-index) does it but that would require the use of a `OnceCell` for sorting the entries back after construction. Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 parents 1403ddf + 2ff1ebe commit a0fa522

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

crates/completion/src/completions/attribute.rs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,30 +87,48 @@ const fn attr(
8787
AttrCompletion { label, lookup, snippet, prefer_inner: false }
8888
}
8989

90+
/// https://doc.rust-lang.org/reference/attributes.html#built-in-attributes-index
9091
const ATTRIBUTES: &[AttrCompletion] = &[
9192
attr("allow(…)", Some("allow"), Some("allow(${0:lint})")),
93+
attr("automatically_derived", None, None),
9294
attr("cfg_attr(…)", Some("cfg_attr"), Some("cfg_attr(${1:predicate}, ${0:attr})")),
9395
attr("cfg(…)", Some("cfg"), Some("cfg(${0:predicate})")),
96+
attr("cold", None, None),
97+
attr(r#"crate_name = """#, Some("crate_name"), Some(r#"crate_name = "${0:crate_name}""#))
98+
.prefer_inner(),
9499
attr("deny(…)", Some("deny"), Some("deny(${0:lint})")),
95100
attr(r#"deprecated = "…""#, Some("deprecated"), Some(r#"deprecated = "${0:reason}""#)),
96101
attr("derive(…)", Some("derive"), Some(r#"derive(${0:Debug})"#)),
102+
attr(
103+
r#"export_name = "…""#,
104+
Some("export_name"),
105+
Some(r#"export_name = "${0:exported_symbol_name}""#),
106+
),
97107
attr(r#"doc = "…""#, Some("doc"), Some(r#"doc = "${0:docs}""#)),
98108
attr("feature(…)", Some("feature"), Some("feature(${0:flag})")).prefer_inner(),
99109
attr("forbid(…)", Some("forbid"), Some("forbid(${0:lint})")),
100110
// FIXME: resolve through macro resolution?
101111
attr("global_allocator", None, None).prefer_inner(),
102112
attr(r#"ignore = "…""#, Some("ignore"), Some(r#"ignore = "${0:reason}""#)),
103113
attr("inline(…)", Some("inline"), Some("inline(${0:lint})")),
104-
attr(r#"link_name = "…""#, Some("link_name"), Some(r#"link_name = "${0:symbol_name}""#)),
105114
attr("link", None, None),
115+
attr(r#"link_name = "…""#, Some("link_name"), Some(r#"link_name = "${0:symbol_name}""#)),
116+
attr(
117+
r#"link_section = "…""#,
118+
Some("link_section"),
119+
Some(r#"link_section = "${0:section_name}""#),
120+
),
106121
attr("macro_export", None, None),
107122
attr("macro_use", None, None),
108123
attr(r#"must_use = "…""#, Some("must_use"), Some(r#"must_use = "${0:reason}""#)),
124+
attr("no_link", None, None).prefer_inner(),
125+
attr("no_implicit_prelude", None, None).prefer_inner(),
126+
attr("no_main", None, None).prefer_inner(),
109127
attr("no_mangle", None, None),
110128
attr("no_std", None, None).prefer_inner(),
111129
attr("non_exhaustive", None, None),
112130
attr("panic_handler", None, None).prefer_inner(),
113-
attr("path = \"\"", Some("path"), Some("path =\"${0:path}\"")),
131+
attr(r#"path = "…""#, Some("path"), Some(r#"path ="${0:path}""#)),
114132
attr("proc_macro", None, None),
115133
attr("proc_macro_attribute", None, None),
116134
attr("proc_macro_derive(…)", Some("proc_macro_derive"), Some("proc_macro_derive(${0:Trait})")),
@@ -125,9 +143,12 @@ const ATTRIBUTES: &[AttrCompletion] = &[
125143
attr(
126144
r#"target_feature = "…""#,
127145
Some("target_feature"),
128-
Some("target_feature = \"${0:feature}\""),
146+
Some(r#"target_feature = "${0:feature}""#),
129147
),
130148
attr("test", None, None),
149+
attr("track_caller", None, None),
150+
attr("type_length_limit = …", Some("type_length_limit"), Some("type_length_limit = ${0:128}"))
151+
.prefer_inner(),
131152
attr("used", None, None),
132153
attr("warn(…)", Some("warn"), Some("warn(${0:lint})")),
133154
attr(
@@ -449,17 +470,21 @@ struct Test {}
449470
r#"#[<|>]"#,
450471
expect![[r#"
451472
at allow(…)
473+
at automatically_derived
452474
at cfg(…)
453475
at cfg_attr(…)
476+
at cold
454477
at deny(…)
455478
at deprecated = "…"
456479
at derive(…)
457480
at doc = "…"
481+
at export_name = "…"
458482
at forbid(…)
459483
at ignore = "…"
460484
at inline(…)
461485
at link
462486
at link_name = "…"
487+
at link_section = "…"
463488
at macro_export
464489
at macro_use
465490
at must_use = "…"
@@ -473,6 +498,7 @@ struct Test {}
473498
at should_panic(…)
474499
at target_feature = "…"
475500
at test
501+
at track_caller
476502
at used
477503
at warn(…)
478504
"#]],
@@ -490,22 +516,30 @@ struct Test {}
490516
r"#![<|>]",
491517
expect![[r#"
492518
at allow(…)
519+
at automatically_derived
493520
at cfg(…)
494521
at cfg_attr(…)
522+
at cold
523+
at crate_name = ""
495524
at deny(…)
496525
at deprecated = "…"
497526
at derive(…)
498527
at doc = "…"
528+
at export_name = "…"
499529
at feature(…)
500530
at forbid(…)
501531
at global_allocator
502532
at ignore = "…"
503533
at inline(…)
504534
at link
505535
at link_name = "…"
536+
at link_section = "…"
506537
at macro_export
507538
at macro_use
508539
at must_use = "…"
540+
at no_implicit_prelude
541+
at no_link
542+
at no_main
509543
at no_mangle
510544
at no_std
511545
at non_exhaustive
@@ -519,6 +553,8 @@ struct Test {}
519553
at should_panic(…)
520554
at target_feature = "…"
521555
at test
556+
at track_caller
557+
at type_length_limit = …
522558
at used
523559
at warn(…)
524560
at windows_subsystem = "…"

0 commit comments

Comments
 (0)