Skip to content

Commit 6929bb9

Browse files
Merge pull request #1 from Tiger0202/TC/precise-capturing
Tc/precise capturing
2 parents 87f8276 + 3c6405b commit 6929bb9

File tree

108 files changed

+6434
-1441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+6434
-1441
lines changed

.github/workflows/main.yml

+88-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
name: CI
2-
on: [push, pull_request]
2+
on:
3+
pull_request:
4+
merge_group:
5+
6+
env:
7+
MDBOOK_VERSION: 0.4.40
38

49
jobs:
5-
test:
6-
name: Test
10+
code-tests:
711
runs-on: ubuntu-latest
812
steps:
913
- uses: actions/checkout@master
@@ -12,12 +16,12 @@ jobs:
1216
- name: Install Rust
1317
run: |
1418
rustup set profile minimal
15-
rustup toolchain install nightly -c rust-docs
19+
rustup toolchain install nightly
1620
rustup default nightly
1721
- name: Install mdbook
1822
run: |
1923
mkdir bin
20-
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
24+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
2125
echo "$(pwd)/bin" >> $GITHUB_PATH
2226
- name: Report versions
2327
run: |
@@ -26,10 +30,88 @@ jobs:
2630
mdbook --version
2731
- name: Run tests
2832
run: mdbook test
33+
34+
style-tests:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@master
38+
- name: Update rustup
39+
run: rustup self update
40+
- name: Install Rust
41+
run: |
42+
rustup set profile minimal
43+
rustup toolchain install nightly -c rust-docs,rustfmt
44+
rustup default nightly
45+
- name: Install mdbook
46+
run: |
47+
mkdir bin
48+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
49+
echo "$(pwd)/bin" >> $GITHUB_PATH
50+
- name: Report versions
51+
run: |
52+
rustup --version
53+
rustc -Vv
54+
mdbook --version
55+
- name: Verify the book builds
56+
env:
57+
SPEC_DENY_WARNINGS: 1
58+
run: mdbook build
2959
- name: Style checks
30-
run: (cd style-check && cargo run -- ../src)
60+
working-directory: style-check
61+
run: cargo run --locked -- ../src
62+
- name: Style fmt
63+
working-directory: style-check
64+
run: cargo fmt --check
3165
- name: Check for broken links
3266
run: |
3367
curl -sSLo linkcheck.sh \
3468
https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
3569
sh linkcheck.sh --all reference
70+
71+
mdbook-spec:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@master
75+
- name: Update rustup
76+
run: rustup self update
77+
- name: Install Rust
78+
run: |
79+
rustup set profile minimal
80+
rustup toolchain install nightly -c rustfmt
81+
rustup default nightly
82+
- name: Install mdbook
83+
run: |
84+
mkdir bin
85+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
86+
echo "$(pwd)/bin" >> $GITHUB_PATH
87+
- name: Report versions
88+
run: |
89+
rustup --version
90+
rustc -Vv
91+
- name: Verify mdbook-spec lockfile is current
92+
working-directory: ./mdbook-spec
93+
run: cargo update -p mdbook-spec --locked
94+
- name: Test mdbook-spec
95+
working-directory: ./mdbook-spec
96+
run: cargo test
97+
- name: Rustfmt check
98+
working-directory: ./mdbook-spec
99+
run: cargo fmt --check
100+
101+
# The success job is here to consolidate the total success/failure state of
102+
# all other jobs. This job is then included in the GitHub branch protection
103+
# rule which prevents merges unless all other jobs are passing. This makes
104+
# it easier to manage the list of jobs via this yml file and to prevent
105+
# accidentally adding new jobs without also updating the branch protections.
106+
success:
107+
name: Success gate
108+
if: always()
109+
needs:
110+
- code-tests
111+
- style-tests
112+
- mdbook-spec
113+
runs-on: ubuntu-latest
114+
steps:
115+
- run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
116+
- name: Done
117+
run: exit 0

CONTRIBUTING.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ for the Reference. As such, we have the warning saying there's work that needs
1414
to be done. Eventually, we plan to make sure everything is well documented
1515
enough that we can remove the warning.
1616

17-
It is encouraged for you to read the [introduction] to familiarize yourself
18-
with the kind of content the reference is expected to contain and the
19-
conventions it uses. Also, the [style guide] provides more detailed guidelines
20-
for formatting and content.
17+
It is encouraged for you to read the [introduction] to familiarize yourself with
18+
the kind of content the reference is expected to contain and the conventions it
19+
uses. Also, the [Authoring Guide] provides more detailed guidelines for
20+
formatting and content.
2121

2222
## Critiquing the Reference
2323

@@ -68,9 +68,9 @@ This should include links to any relevant information, such as the
6868
stabilization PR, the RFC, the tracking issue, and anything else that would be
6969
helpful for writing the documentation.
7070

71+
[Authoring Guide]: docs/authoring.md
7172
[introduction]: src/introduction.md
7273
[issue tracker]: https://github.com/rust-lang/reference/issues
7374
[playpen]: https://play.rust-lang.org/
7475
[rust-lang/rust]: https://github.com/rust-lang/rust/
75-
[style guide]: STYLE.md
7676
[unstable]: https://doc.rust-lang.org/nightly/unstable-book/

README.md

+38-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# The Rust Language Reference
22

3-
This document is the primary reference for the Rust programming language.
3+
This document is the primary reference for the Rust programming
4+
language.
45

56
This document is not normative. It may include details that are specific
67
to `rustc` itself, and should not be taken as a specification for the
@@ -9,52 +10,64 @@ what we have for now.
910

1011
## Dependencies
1112

12-
- rustc (the Rust compiler).
13-
- [mdbook](https://rust-lang.github.io/mdBook/) (use `cargo install mdbook` to install it).
14-
- rust nightly (you would be required to set your Rust version to the nightly version to make sure all tests pass)
13+
- Nightly Rust
14+
- [mdbook](https://rust-lang.github.io/mdBook/)
1515

16-
## Build steps
16+
## Installing dependencies
1717

18-
To build the project, follow the steps given below :
18+
First, ensure that you have a recent copy of the nightly Rust compiler
19+
installed, as this is needed in order to run the tests:
1920

20-
Clone the project by downloading the ZIP from the [GitHub page](https://github.com/rust-lang/reference) or
21-
run the following command:
22-
23-
```
24-
git clone https://github.com/rust-lang/reference
21+
```sh
22+
rustup toolchain install nightly
2523
```
2624

27-
Change the directory to the downloaded repository:
25+
Now, ensure you have `mdbook` installed, as this is needed in order to
26+
build the Reference:
2827

2928
```sh
30-
cd reference
29+
cargo install --locked mdbook
3130
```
3231

33-
To run the tests, you would need to set the Rust version to the nightly release. You can do this by executing the following command:
32+
## Building
3433

35-
```shell
36-
rustup override set nightly
34+
To build the Reference, first clone the project:
35+
36+
```sh
37+
git clone https://github.com/rust-lang/reference.git
3738
```
3839

39-
This will set the nightly version only for your the current project.
40+
(Alternatively, if you don't want to use `git`, [download][] a ZIP file
41+
of the project, extract it using your preferred tool, and rename the
42+
top-level directory to `reference`.)
43+
44+
[download]: https://github.com/rust-lang/reference/archive/refs/heads/master.zip
4045

41-
If you wish to set Rust nightly for all your projects, you can run the command:
46+
Now change your current directory to the working directory:
4247

43-
```shell
44-
rustup default nightly
48+
```sh
49+
cd reference
4550
```
4651

47-
Now, run the following command to test the code snippets to catch compilation errors:
52+
To test all of the code examples in the Reference, run:
4853

49-
```shell
54+
```sh
5055
mdbook test
5156
```
5257

58+
For authors, consider using the server functionality which supports automatic reload.
5359

54-
To generate a local instance of the book, run:
60+
To build the Reference locally (in `build/`) and open it in a web
61+
browser, run:
5562

5663
```sh
57-
mdbook build
64+
mdbook build --open
5865
```
5966

60-
The generated HTML will be in the `book` folder.
67+
This will open a browser with a websocket live-link to automatically reload whenever the source is updated.
68+
69+
You can also open any current build of the reference by running:
70+
71+
```sh
72+
mdbook serve --open
73+
```

STYLE.md

+2-68
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,5 @@
11
# Rust reference style guide
22

3-
Some conventions and content guidelines are specified in the [introduction].
4-
This document serves as a guide for editors and reviewers.
3+
See the [Authoring Guide] for details on the style used in the reference.
54

6-
There is a [`style-check`](style-check/) tool which is run in CI to check some of these. To use it locally, run `cargo run --manifest-path=style-check/Cargo.toml src`.
7-
8-
## Markdown formatting
9-
10-
* Use ATX-style heading with sentence case.
11-
* Use one line per sentence to make diffs nicer.
12-
Do not wrap long lines.
13-
* Use reference links, with shortcuts if appropriate.
14-
Place the sorted link reference definitions at the bottom of the file, or at the bottom of a section if there is an unusually large number of links that are specific to the section.
15-
16-
```
17-
Example of shortcut link: [enumerations]
18-
Example of reference link with label: [block expression][block]
19-
20-
[block]: expressions/block-expr.md
21-
[enumerations]: types/enum.md
22-
```
23-
24-
* Links should be relative with the `.md` extension.
25-
Links to other rust-lang books that are published with the reference or the standard library API should also be relative so that the linkchecker can validate them.
26-
* See the [Conventions] section for formatting callouts such as notes, edition differences, and warnings.
27-
* Formatting to avoid:
28-
* Avoid trailing spaces.
29-
* Avoid double blank lines.
30-
31-
### Code examples
32-
33-
Code examples should use code blocks with triple backticks.
34-
The language should always be specified (such as `rust`).
35-
36-
```rust
37-
println!("Hello!");
38-
```
39-
40-
See https://highlightjs.org/ for a list of supported languages.
41-
42-
Rust examples are tested via rustdoc, and should include the appropriate annotations when tests are expected to fail:
43-
44-
* `edition2015` or `edition2018` — If it is edition-specific (see `book.toml` for the default).
45-
* `no_run` — The example should compile successfully, but should not be executed.
46-
* `should_panic` — The example should compile and run, but produce a panic.
47-
* `compile_fail` — The example is expected to fail to compile.
48-
* `ignore` — The example shouldn't be built or tested.
49-
This should be avoided if possible.
50-
Usually this is only necessary when the testing framework does not support it (such as external crates or modules, or a proc-macro), or it contains pseudo-code which is not valid Rust.
51-
An HTML comment such as `<!-- ignore: requires extern crate -->` should be placed before the example to explain why it is ignored.
52-
53-
See the [rustdoc documentation] for more detail.
54-
55-
## Language and grammar
56-
57-
* Use American English spelling.
58-
* Use Oxford commas.
59-
* Idioms and styling to avoid:
60-
* Avoid slashes for alternatives ("program/binary"), use conjunctions or rewrite it ("program or binary").
61-
* Avoid qualifying something as "in Rust", the entire reference is about Rust.
62-
63-
## Content
64-
65-
* Whenever there is a difference between editions, the differences should be called out with an "Edition Differences" block.
66-
The main text should stick to what is common between the editions.
67-
However, for large differences (such as "async"), the main text may contain edition-specific content as long as it is made clear which editions it applies to.
68-
69-
[conventions]: src/introduction.md#conventions
70-
[introduction]: src/introduction.md
71-
[rustdoc documentation]: https://doc.rust-lang.org/rustdoc/documentation-tests.html
5+
[Authoring Guide]: docs/authoring.md

book.toml

+10
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ author = "The Rust Project Developers"
66
[output.html]
77
additional-css = ["theme/reference.css"]
88
git-repository-url = "https://github.com/rust-lang/reference/"
9+
edit-url-template = "https://github.com/rust-lang/reference/edit/master/{path}"
10+
smart-punctuation = true
911

1012
[output.html.redirect]
1113
"/expressions/enum-variant-expr.html" = "struct-expr.html"
14+
"/unsafe-blocks.html" = "unsafe-keyword.html"
15+
"/unsafe-functions.html" = "unsafe-keyword.html"
1216

1317
[rust]
1418
edition = "2021"
19+
20+
[preprocessor.spec]
21+
command = "cargo run --manifest-path mdbook-spec/Cargo.toml"
22+
23+
[build]
24+
extra-watch-dirs = ["mdbook-spec/src"]

0 commit comments

Comments
 (0)