]> git.lizzy.rs Git - rust.git/commitdiff
Add basic Unstable Book entry for `attr_literals`.
authorCorey Farwell <coreyf@rwell.org>
Sat, 20 May 2017 16:08:28 +0000 (12:08 -0400)
committerCorey Farwell <coreyf@rwell.org>
Sat, 20 May 2017 16:08:28 +0000 (12:08 -0400)
src/doc/unstable-book/src/language-features/attr-literals.md

index 67eee214a4f247e4f012fe59dd0e5574d0b60519..60741a74400d2e50007610ab1ed27b291d56ee0a 100644 (file)
@@ -6,5 +6,25 @@ The tracking issue for this feature is: [#34981]
 
 ------------------------
 
+At present, literals are only accepted as the value of a key-value pair in
+attributes. What's more, only _string_ literals are accepted. This means that
+literals can only appear in forms of `#[attr(name = "value")]` or
+`#[attr = "value"]`.
 
+The `attr_literals` unstable feature allows other types of literals to be used
+in attributes. Here are some examples of attributes that can now be used with
+this feature enabled:
+
++```rust,ignore
++#[attr]
++#[attr(true)]
++#[attr(ident)]
++#[attr(ident, 100, true, "true", ident = 100, ident = "hello", ident(100))]
++#[attr(100)]
++#[attr(enabled = true)]
++#[enabled(true)]
++#[attr("hello")]
++#[repr(C, align = 4)]
++#[repr(C, align(4))]
++```