Skip to content

Commit 2a6a5ad

Browse files
authored
Merge pull request #886 from ehuss/style-check
Add style checks.
2 parents 0f6b234 + dd1b9c3 commit 2a6a5ad

22 files changed

+253
-101
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
mdbook --version
2727
- name: Run tests
2828
run: mdbook test
29-
- name: Check for unstable features
30-
run: (cd stable-check && cargo run -- ../src)
29+
- name: Style checks
30+
run: (cd style-check && cargo run -- ../src)
3131
- name: Check for broken links
3232
run: |
3333
curl -sSLo linkcheck.sh \

STYLE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Some conventions and content guidelines are specified in the [introduction].
44
This document serves as a guide for editors and reviewers.
55

6+
There is a [`style-check`](style-check/) tool which is run in CI to check some
7+
of these. To use it locally, run
8+
`cargo run --manifest-path=style-check/Cargo.toml src`.
9+
610
## Markdown formatting
711

812
* Use ATX-style heading with sentence case.

src/attributes/codegen.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ otherwise undefined behavior results.
157157

158158
### Behavior
159159

160-
Applying the attribute to a function `f` allows code within `f` to get a hint of the [`Location`] of
161-
the "topmost" tracked call that led to `f`'s invocation. At the point of observation, an
162-
implementation behaves as if it walks up the stack from `f`'s frame to find the nearest frame of an
160+
Applying the attribute to a function `f` allows code within `f` to get a hint of the [`Location`] of
161+
the "topmost" tracked call that led to `f`'s invocation. At the point of observation, an
162+
implementation behaves as if it walks up the stack from `f`'s frame to find the nearest frame of an
163163
*unattributed* function `outer`, and it returns the [`Location`] of the tracked call in `outer`.
164164

165165
```rust
@@ -190,7 +190,7 @@ fn calls_f() {
190190
```
191191

192192
When `f` is called by another attributed function `g` which is in turn called by `calls_g`, code in
193-
both `f` and `g` observes `g`'s callsite within `calls_g`:
193+
both `f` and `g` observes `g`'s callsite within `calls_g`:
194194

195195
```rust
196196
# #[track_caller]

src/comments.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
> **<sup>Lexer</sup>**\
44
> LINE_COMMENT :\
5-
> &nbsp;&nbsp; &nbsp;&nbsp; `//` (~[`/` `!`] | `//`) ~`\n`<sup>\*</sup>\
5+
> &nbsp;&nbsp; &nbsp;&nbsp; `//` (~\[`/` `!`] | `//`) ~`\n`<sup>\*</sup>\
66
> &nbsp;&nbsp; | `//`
77
>
88
> BLOCK_COMMENT :\
9-
> &nbsp;&nbsp; &nbsp;&nbsp; `/*` (~[`*` `!`] | `**` | _BlockCommentOrDoc_)
9+
> &nbsp;&nbsp; &nbsp;&nbsp; `/*` (~\[`*` `!`] | `**` | _BlockCommentOrDoc_)
1010
> (_BlockCommentOrDoc_ | ~`*/`)<sup>\*</sup> `*/`\
1111
> &nbsp;&nbsp; | `/**/`\
1212
> &nbsp;&nbsp; | `/***/`
1313
>
1414
> INNER_LINE_DOC :\
15-
> &nbsp;&nbsp; `//!` ~[`\n` _IsolatedCR_]<sup>\*</sup>
15+
> &nbsp;&nbsp; `//!` ~\[`\n` _IsolatedCR_]<sup>\*</sup>
1616
>
1717
> INNER_BLOCK_DOC :\
18-
> &nbsp;&nbsp; `/*!` ( _BlockCommentOrDoc_ | ~[`*/` _IsolatedCR_] )<sup>\*</sup> `*/`
18+
> &nbsp;&nbsp; `/*!` ( _BlockCommentOrDoc_ | ~\[`*/` _IsolatedCR_] )<sup>\*</sup> `*/`
1919
>
2020
> OUTER_LINE_DOC :\
21-
> &nbsp;&nbsp; `///` (~`/` ~[`\n` _IsolatedCR_]<sup>\*</sup>)<sup>?</sup>
21+
> &nbsp;&nbsp; `///` (~`/` ~\[`\n` _IsolatedCR_]<sup>\*</sup>)<sup>?</sup>
2222
>
2323
> OUTER_BLOCK_DOC :\
2424
> &nbsp;&nbsp; `/**` (~`*` | _BlockCommentOrDoc_ )
25-
> (_BlockCommentOrDoc_ | ~[`*/` _IsolatedCR_])<sup>\*</sup> `*/`
25+
> (_BlockCommentOrDoc_ | ~\[`*/` _IsolatedCR_])<sup>\*</sup> `*/`
2626
>
2727
> _BlockCommentOrDoc_ :\
2828
> &nbsp;&nbsp; &nbsp;&nbsp; BLOCK_COMMENT\

src/destructors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ smallest scope that contains the expression and is for one of the following:
166166
* The second operand of a [lazy boolean expression].
167167

168168
> **Notes**:
169-
>
169+
>
170170
> Temporaries that are created in the final expression of a function
171171
> body are dropped *after* any named variables bound in the function body, as
172172
> there is no smaller enclosing temporary scope.

src/expressions/closure-expr.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
> _ClosureParam_ :\
1313
> &nbsp;&nbsp; [_OuterAttribute_]<sup>\*</sup> [_Pattern_]&nbsp;( `:` [_Type_] )<sup>?</sup>
1414
15-
A _closure expression_, also know as a lambda expression or a lambda, defines a
16-
closure and denotes it as a value, in a single expression. A closure expression
17-
is a pipe-symbol-delimited (`|`) list of irrefutable [patterns] followed by an
18-
expression. Type annotations may optionally be added for the type of the
15+
A _closure expression_, also know as a lambda expression or a lambda, defines a
16+
closure and denotes it as a value, in a single expression. A closure expression
17+
is a pipe-symbol-delimited (`|`) list of irrefutable [patterns] followed by an
18+
expression. Type annotations may optionally be added for the type of the
1919
parameters or for the return type. If there is a return type, the expression
2020
used for the body of the closure must be a normal [block]. A closure expression
2121
also may begin with the `move` keyword before the initial `|`.

src/glossary.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ function* or a *free const*. Contrast to an [associated item].
7575

7676
### Fundamental traits
7777

78-
A fundamental trait is one where adding an impl of it for an existing type is a breaking change.
78+
A fundamental trait is one where adding an impl of it for an existing type is a breaking change.
7979
The `Fn` traits and `Sized` are fundamental.
8080

8181
### Fundamental type constructors
8282

83-
A fundamental type constructor is a type where implementing a [blanket implementation](#blanket-implementation) over it
84-
is a breaking change. `&`, `&mut`, `Box`, and `Pin` are fundamental.
83+
A fundamental type constructor is a type where implementing a [blanket implementation](#blanket-implementation) over it
84+
is a breaking change. `&`, `&mut`, `Box`, and `Pin` are fundamental.
8585

86-
Any time a type `T` is considered [local](#local-type), `&T`, `&mut T`, `Box<T>`, and `Pin<T>`
87-
are also considered local. Fundamental type constructors cannot [cover](#uncovered-type) other types.
88-
Any time the term "covered type" is used,
86+
Any time a type `T` is considered [local](#local-type), `&T`, `&mut T`, `Box<T>`, and `Pin<T>`
87+
are also considered local. Fundamental type constructors cannot [cover](#uncovered-type) other types.
88+
Any time the term "covered type" is used,
8989
the `T` in `&T`, `&mut T`, `Box<T>`, and `Pin<T>` is not considered covered.
9090

9191
### Inhabited
@@ -120,7 +120,7 @@ or not independent of applied type arguments. Given `trait Foo<T, U>`,
120120

121121
A `struct`, `enum`, or `union` which was defined in the current crate.
122122
This is not affected by applied type arguments. `struct Foo` is considered local, but
123-
`Vec<Foo>` is not. `LocalType<ForeignType>` is local. Type aliases do not
123+
`Vec<Foo>` is not. `LocalType<ForeignType>` is local. Type aliases do not
124124
affect locality.
125125

126126
### Nominal types

src/identifiers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
> **<sup>Lexer:<sup>**\
44
> IDENTIFIER_OR_KEYWORD :\
5-
> &nbsp;&nbsp; &nbsp;&nbsp; [`a`-`z` `A`-`Z`]&nbsp;[`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>\*</sup>\
6-
> &nbsp;&nbsp; | `_` [`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>+</sup>
5+
> &nbsp;&nbsp; &nbsp;&nbsp; \[`a`-`z` `A`-`Z`]&nbsp;\[`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>\*</sup>\
6+
> &nbsp;&nbsp; | `_` \[`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>+</sup>
77
>
88
> RAW_IDENTIFIER : `r#` IDENTIFIER_OR_KEYWORD <sub>*Except `crate`, `self`, `super`, `Self`*</sub>
99
>

src/items/functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ attributes][attributes] are allowed directly after the `{` inside its [block].
293293
This example shows an inner attribute on a function. The function will only be
294294
available while running tests.
295295

296-
```
296+
```rust
297297
fn test_only() {
298298
#![test]
299299
}

src/items/implementations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ least one of the following is true:
174174

175175
Only the appearance of *uncovered* type parameters is restricted.
176176
Note that for the purposes of coherence, [fundamental types] are
177-
special. The `T` in `Box<T>` is not considered covered, and `Box<LocalType>`
177+
special. The `T` in `Box<T>` is not considered covered, and `Box<LocalType>`
178178
is considered local.
179179

180180

0 commit comments

Comments
 (0)