Skip to content

Commit d373bca

Browse files
hbinamark-i-m
authored andcommitted
Couple of changes to code so that its safe
Specifically, `> $1` causes it to write into the file $1 if it exist And `> ./x.py` is particularly bad because it overwrite the script with empty spaces...
1 parent 55e5a8a commit d373bca

File tree

5 files changed

+52
-52
lines changed

5 files changed

+52
-52
lines changed

src/building/how-to-build-and-run.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Once you've created a config.toml, you are now ready to run
145145
probably the best "go to" command for building a local rust:
146146

147147
```bash
148-
> ./x.py build -i --stage 1 src/libstd
148+
./x.py build -i --stage 1 src/libstd
149149
```
150150

151151
This may *look* like it only builds libstd, but that is not the case.
@@ -190,19 +190,19 @@ build`) has quite a few more steps:
190190
Build only the libcore library
191191

192192
```bash
193-
> ./x.py build src/libcore
193+
./x.py build src/libcore
194194
```
195195

196196
Build the libcore and libproc_macro library only
197197

198198
```bash
199-
> ./x.py build src/libcore src/libproc_macro
199+
./x.py build src/libcore src/libproc_macro
200200
```
201201

202202
Build only libcore up to Stage 1
203203

204204
```bash
205-
> ./x.py build src/libcore --stage 1
205+
./x.py build src/libcore --stage 1
206206
```
207207

208208
Sometimes you might just want to test if the part you’re working on can
@@ -221,8 +221,8 @@ you will likely need to build at some point; for example, if you want
221221
to run the entire test suite).
222222

223223
```bash
224-
> rustup toolchain link stage1 build/<host-triple>/stage1
225-
> rustup toolchain link stage2 build/<host-triple>/stage2
224+
rustup toolchain link stage1 build/<host-triple>/stage1
225+
rustup toolchain link stage2 build/<host-triple>/stage2
226226
```
227227

228228
The `<host-triple>` would typically be one of the following:
@@ -236,7 +236,7 @@ should see a version number ending in `-dev`, indicating a build from
236236
your local environment:
237237

238238
```bash
239-
> rustc +stage1 -vV
239+
$ rustc +stage1 -vV
240240
rustc 1.25.0-dev
241241
binary: rustc
242242
commit-hash: unknown
@@ -272,6 +272,6 @@ If you need to run this then rustbuild is most likely not acting right and
272272
you should file a bug as to what is going wrong. If you do need to clean
273273
everything up then you only need to run one command!
274274

275-
```bash
276-
> ./x.py clean
277-
```
275+
```bash
276+
./x.py clean
277+
```

src/diagnostics.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,11 @@ Lints can be turned on in groups. These groups are declared in the
291291
For example,
292292

293293
```rust,ignore
294-
add_lint_group!(sess,
295-
"nonstandard_style",
296-
NON_CAMEL_CASE_TYPES,
297-
NON_SNAKE_CASE,
298-
NON_UPPER_CASE_GLOBALS);
294+
add_lint_group!(sess,
295+
"nonstandard_style",
296+
NON_CAMEL_CASE_TYPES,
297+
NON_SNAKE_CASE,
298+
NON_UPPER_CASE_GLOBALS);
299299
```
300300

301301
This defines the `nonstandard_style` group which turns on the listed lints. A

src/hir.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You can view the HIR representation of your code by passing the
1515
`-Zunpretty=hir-tree` flag to rustc:
1616

1717
```bash
18-
> cargo rustc -- -Zunpretty=hir-tree
18+
cargo rustc -- -Zunpretty=hir-tree
1919
```
2020

2121
### Out-of-band storage and the `Crate` type

src/profiling/with_perf.md

+24-24
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ of events, though, like cache misses and so forth.
2828
The basic `perf` command is this:
2929

3030
```bash
31-
> perf record -F99 --call-graph dwarf XXX
31+
perf record -F99 --call-graph dwarf XXX
3232
```
3333

3434
The `-F99` tells perf to sample at 99 Hz, which avoids generating too
@@ -39,7 +39,7 @@ information from debuginfo, which is accurate. The `XXX` is the
3939
command you want to profile. So, for example, you might do:
4040

4141
```bash
42-
> perf record -F99 --call-graph dwarf cargo +<toolchain> rustc
42+
perf record -F99 --call-graph dwarf cargo +<toolchain> rustc
4343
```
4444

4545
to run `cargo` -- here `<toolchain>` should be the name of the toolchain
@@ -59,7 +59,7 @@ do that, the first step is to clone
5959
[the rustc-perf repository][rustc-perf-gh]:
6060

6161
```bash
62-
> git clone https://github.com/rust-lang-nursery/rustc-perf
62+
git clone https://github.com/rust-lang-nursery/rustc-perf
6363
```
6464

6565
[rustc-perf-gh]: https://github.com/rust-lang-nursery/rustc-perf
@@ -75,13 +75,13 @@ do profiling for you! You can find
7575
For example, to measure the clap-rs test, you might do:
7676

7777
```bash
78-
> ./target/release/collector
79-
--output-repo /path/to/place/output
80-
profile perf-record
81-
--rustc /path/to/rustc/executable/from/your/build/directory
82-
--cargo `which cargo`
83-
--filter clap-rs
84-
--builds Check
78+
./target/release/collector \
79+
--output-repo /path/to/place/output \
80+
profile perf-record \
81+
--rustc /path/to/rustc/executable/from/your/build/directory \
82+
--cargo `which cargo` \
83+
--filter clap-rs \
84+
--builds Check \
8585
```
8686

8787
You can also use that same command to use cachegrind or other profiling tools.
@@ -97,7 +97,7 @@ example:
9797
[dir]: https://github.com/rust-lang-nursery/rustc-perf/tree/master/collector/benchmarks
9898

9999
```bash
100-
> cd collector/benchmarks/clap-rs
100+
cd collector/benchmarks/clap-rs
101101
```
102102

103103
In this case, let's say we want to profile the `cargo check`
@@ -106,8 +106,8 @@ build the dependencies:
106106

107107
```bash
108108
# Setup: first clean out any old results and build the dependencies:
109-
> cargo +<toolchain> clean
110-
> CARGO_INCREMENTAL=0 cargo +<toolchain> check
109+
cargo +<toolchain> clean
110+
CARGO_INCREMENTAL=0 cargo +<toolchain> check
111111
```
112112

113113
(Again, `<toolchain>` should be replaced with the name of the
@@ -118,8 +118,8 @@ running cargo check. I tend to use `cargo rustc` for this, since it
118118
also allows me to add explicit flags, which we'll do later on.
119119

120120
```bash
121-
> touch src/lib.rs
122-
> CARGO_INCREMENTAL=0 perf record -F99 --call-graph dwarf cargo rustc --profile check --lib
121+
touch src/lib.rs
122+
CARGO_INCREMENTAL=0 perf record -F99 --call-graph dwarf cargo rustc --profile check --lib
123123
```
124124

125125
Note that final command: it's a doozy! It uses the `cargo rustc`
@@ -130,7 +130,7 @@ the `--profile check` and `--lib` options specify that we are doing a
130130
At this point, we can use `perf` tooling to analyze the results. For example:
131131

132132
```bash
133-
> perf report
133+
perf report
134134
```
135135

136136
will open up an interactive TUI program. In simple cases, that can be
@@ -149,8 +149,8 @@ If you want to profile an NLL run, you can just pass extra options to
149149
the `cargo rustc` command, like so:
150150

151151
```bash
152-
> touch src/lib.rs
153-
> CARGO_INCREMENTAL=0 perf record -F99 --call-graph dwarf cargo rustc --profile check --lib -- -Zborrowck=mir
152+
touch src/lib.rs
153+
CARGO_INCREMENTAL=0 perf record -F99 --call-graph dwarf cargo rustc --profile check --lib -- -Zborrowck=mir
154154
```
155155

156156
[pf]: https://github.com/nikomatsakis/perf-focus
@@ -180,7 +180,7 @@ would analyze NLL performance.
180180
You can install perf-focus using `cargo install`:
181181

182182
```bash
183-
> cargo install perf-focus
183+
cargo install perf-focus
184184
```
185185

186186
### Example: How much time is spent in MIR borrowck?
@@ -191,7 +191,7 @@ function of the MIR borrowck is called `do_mir_borrowck`, so we can do
191191
this command:
192192

193193
```bash
194-
> perf focus '{do_mir_borrowck}'
194+
$ perf focus '{do_mir_borrowck}'
195195
Matcher : {do_mir_borrowck}
196196
Matches : 228
197197
Not Matches: 542
@@ -216,7 +216,7 @@ samples where `do_mir_borrowck` was on the stack: in this case, 29%.
216216
by doing:
217217

218218
```bash
219-
> perf script | c++filt | perf focus --from-stdin ...
219+
perf script | c++filt | perf focus --from-stdin ...
220220
```
221221

222222
This will pipe the output from `perf script` through `c++filt` and
@@ -232,7 +232,7 @@ Perhaps we'd like to know how much time MIR borrowck spends in the
232232
trait checker. We can ask this using a more complex regex:
233233

234234
```bash
235-
> perf focus '{do_mir_borrowck}..{^rustc::traits}'
235+
$ perf focus '{do_mir_borrowck}..{^rustc::traits}'
236236
Matcher : {do_mir_borrowck},..{^rustc::traits}
237237
Matches : 12
238238
Not Matches: 1311
@@ -260,7 +260,7 @@ usually also want to give `--tree-min-percent` or
260260
`--tree-max-depth`. The result looks like this:
261261

262262
```bash
263-
> perf focus '{do_mir_borrowck}' --tree-callees --tree-min-percent 3
263+
$ perf focus '{do_mir_borrowck}' --tree-callees --tree-min-percent 3
264264
Matcher : {do_mir_borrowck}
265265
Matches : 577
266266
Not Matches: 746
@@ -311,7 +311,7 @@ could get our percentages relative to the borrowck itself
311311
like so:
312312

313313
```bash
314-
> perf focus '{do_mir_borrowck}' --tree-callees --relative --tree-max-depth 1 --tree-min-percent 5
314+
$ perf focus '{do_mir_borrowck}' --tree-callees --relative --tree-max-depth 1 --tree-min-percent 5
315315
Matcher : {do_mir_borrowck}
316316
Matches : 577
317317
Not Matches: 746

src/tests/running.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ You can run the tests using `x.py`. The most basic command – which
44
you will almost never want to use! – is as follows:
55

66
```bash
7-
> ./x.py test
7+
./x.py test
88
```
99

1010
This will build the full stage 2 compiler and then run the whole test
@@ -34,7 +34,7 @@ test" that can be used after modifying rustc to see if things are
3434
generally working correctly would be the following:
3535

3636
```bash
37-
> ./x.py test --stage 1 src/test/{ui,compile-fail}
37+
./x.py test --stage 1 src/test/{ui,compile-fail}
3838
```
3939

4040
This will run the `ui` and `compile-fail` test suites,
@@ -44,38 +44,38 @@ example, if you are hacking on debuginfo, you may be better off with
4444
the debuginfo test suite:
4545

4646
```bash
47-
> ./x.py test --stage 1 src/test/debuginfo
47+
./x.py test --stage 1 src/test/debuginfo
4848
```
4949

5050
If you only need to test a specific subdirectory of tests for any
5151
given test suite, you can pass that directory to `x.py test`:
5252

5353
```bash
54-
> ./x.py test --stage 1 src/test/ui/const-generics
54+
./x.py test --stage 1 src/test/ui/const-generics
5555
```
5656

5757
Likewise, you can test a single file by passing its path:
5858

5959
```bash
60-
> ./x.py test --stage 1 src/test/ui/const-generics/const-test.rs
60+
./x.py test --stage 1 src/test/ui/const-generics/const-test.rs
6161
```
6262

6363
### Run only the tidy script
6464

6565
```bash
66-
> ./x.py test src/tools/tidy
66+
./x.py test src/tools/tidy
6767
```
6868

6969
### Run tests on the standard library
7070

7171
```bash
72-
> ./x.py test src/libstd
72+
./x.py test src/libstd
7373
```
7474

7575
### Run tests on the standard library and run the tidy script
7676

7777
```bash
78-
> ./x.py test src/libstd src/tools/tidy
78+
./x.py test src/libstd src/tools/tidy
7979
```
8080

8181
### Run tests on the standard library using a stage 1 compiler
@@ -100,7 +100,7 @@ you may pass the full file path to achieve this, or alternatively one
100100
may invoke `x.py` with the `--test-args` option:
101101

102102
```bash
103-
> ./x.py test --stage 1 src/test/ui --test-args issue-1234
103+
./x.py test --stage 1 src/test/ui --test-args issue-1234
104104
```
105105

106106
Under the hood, the test runner invokes the standard rust test runner
@@ -117,7 +117,7 @@ exists in the test file. For example, you can run all the tests in
117117
`src/test/ui` as `check-pass`:
118118

119119
```bash
120-
> ./x.py test --stage 1 src/test/ui --pass check
120+
./x.py test --stage 1 src/test/ui --pass check
121121
```
122122

123123
By passing `--pass $mode`, you can reduce the testing time. For each
@@ -131,7 +131,7 @@ You can further enable the `--incremental` flag to save additional
131131
time in subsequent rebuilds:
132132

133133
```bash
134-
> ./x.py test --stage 1 src/test/ui --incremental --test-args issue-1234
134+
./x.py test --stage 1 src/test/ui --incremental --test-args issue-1234
135135
```
136136

137137
If you don't want to include the flag with every command, you can
@@ -152,7 +152,7 @@ Sometimes it's easier and faster to just run the test by hand. Most tests are
152152
just `rs` files, so you can do something like
153153

154154
```bash
155-
> rustc +stage1 src/test/ui/issue-1234.rs
155+
rustc +stage1 src/test/ui/issue-1234.rs
156156
```
157157

158158
This is much faster, but doesn't always work. For example, some tests

0 commit comments

Comments
 (0)