about summary refs log tree commit diff
path: root/docs/dev
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-10 15:53:39 +0000
committerGitHub <noreply@github.com>2021-01-10 15:53:39 +0000
commite1430d822e20635170c8da92b928d4d89dd1f680 (patch)
treeb74085aa9e933c790fe221fb1e02da8cfa20f28e /docs/dev
parent035fed5f9f7c062da7d23190dab1a7021fd48a5d (diff)
parenta7db8abab7ff04f3e9b7cb7013107dcf37de8687 (diff)
downloadrust-e1430d822e20635170c8da92b928d4d89dd1f680.tar.gz
rust-e1430d822e20635170c8da92b928d4d89dd1f680.zip
Merge #7237
7237: Use T! for bool keywords r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/style.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md
index 67cbc674488..7481f800826 100644
--- a/docs/dev/style.md
+++ b/docs/dev/style.md
@@ -643,6 +643,27 @@ assert!(x >= lo && x <= hi>);
 **Rationale:** Less-then comparisons are more intuitive, they correspond spatially to [real line](https://en.wikipedia.org/wiki/Real_line).
 
 
+## Token names
+
+Use `T![foo]` instead of `SyntaxKind::FOO_KW`.
+
+```rust
+// GOOD
+match p.current() {
+    T![true] | T![false] => true,
+    _ => false,
+}
+
+// BAD
+
+match p.current() {
+    SyntaxKind::TRUE_KW | SyntaxKind::FALSE_KW => true,
+    _ => false,
+}
+```
+
+**Rationale:** The macro uses the familiar Rust syntax, avoiding ambiguities like "is this a brace or bracket?".
+
 ## Documentation
 
 For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines.