Skip to content

Commit 539172f

Browse files
committed
Recommend rust-toolchain.toml file
1 parent 3622a83 commit 539172f

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,23 @@ to catch. If the compiler changes something that makes error messages that we
224224
care about substantially worse, it is also important to catch and report as a
225225
compiler issue.
226226

227-
## CI
227+
<br>
228+
229+
## Troubleshooting
228230

229-
Make sure `rust-src` component is installed on CI, otherwise error messages
230-
on CI will not include snippets of code from the standard library. This will
231-
make sure the output on CI is the same as on your local machine.
231+
The Rust compiler's diagnostic output can vary as a function of whether the
232+
`rust-src` Rustup component is installed. The compiler will render source
233+
snippets from the standard library if the standard library source is available
234+
locally, and will simply omit snippets if not. This can account for differences
235+
between CI and local development.
232236

233-
```bash
234-
rustup component add rust-src
237+
If you have compile_fail tests pertaining to standard library traits or types,
238+
you can ensure a consistent environment by adding a rust-toolchain.toml file
239+
with the following content.
240+
241+
```toml
242+
[toolchain]
243+
components = ["rust-src"]
235244
```
236245

237246
<br>

src/lib.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,23 @@
208208
//! makes error messages that we care about substantially worse, it is also
209209
//! important to catch and report as a compiler issue.
210210
//!
211-
//! # CI
211+
//! <br>
212+
//!
213+
//! # Troubleshooting
214+
//!
215+
//! The Rust compiler's diagnostic output can vary as a function of whether the
216+
//! `rust-src` Rustup component is installed. The compiler will render source
217+
//! snippets from the standard library if the standard library source is
218+
//! available locally, and will simply omit snippets if not. This can account
219+
//! for differences between CI and local development.
212220
//!
213-
//! Make sure `rust-src` component is installed on CI, otherwise error messages
214-
//! on CI will not include snippets of code from the standard library. This will
215-
//! make sure the output on CI is the same as on your local machine.
221+
//! If you have compile_fail tests pertaining to standard library traits or
222+
//! types, you can ensure a consistent environment by adding a
223+
//! rust-toolchain.toml file with the following content.
216224
//!
217-
//! ```bash
218-
//! rustup component add rust-src
225+
//! ```toml
226+
//! [toolchain]
227+
//! components = ["rust-src"]
219228
//! ```
220229
221230
#![doc(html_root_url = "https://docs.rs/trybuild/1.0.99")]

0 commit comments

Comments
 (0)