Skip to content

Commit 2d3438d

Browse files
committed
Add basic Unstable Book entry for attr_literals.
1 parent d1f4993 commit 2d3438d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/doc/unstable-book/src/language-features/attr-literals.md

+20
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,25 @@ The tracking issue for this feature is: [#34981]
66

77
------------------------
88

9+
At present, literals are only accepted as the value of a key-value pair in
10+
attributes. What's more, only _string_ literals are accepted. This means that
11+
literals can only appear in forms of `#[attr(name = "value")]` or
12+
`#[attr = "value"]`.
913

14+
The `attr_literals` unstable feature allows other types of literals to be used
15+
in attributes. Here are some examples of attributes that can now be used with
16+
this feature enabled:
17+
18+
+```rust,ignore
19+
+#[attr]
20+
+#[attr(true)]
21+
+#[attr(ident)]
22+
+#[attr(ident, 100, true, "true", ident = 100, ident = "hello", ident(100))]
23+
+#[attr(100)]
24+
+#[attr(enabled = true)]
25+
+#[enabled(true)]
26+
+#[attr("hello")]
27+
+#[repr(C, align = 4)]
28+
+#[repr(C, align(4))]
29+
+```
1030

0 commit comments

Comments
 (0)