mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-14 17:07:26 +00:00
Merge #7237
7237: Use T! for bool keywords r=matklad a=lnicola Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
e1430d822e
2 changed files with 22 additions and 1 deletions
|
@ -55,7 +55,7 @@ fn generic_arg(p: &mut Parser) {
|
|||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
TRUE_KW | FALSE_KW => {
|
||||
T![true] | T![false] => {
|
||||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue