diff options
| author | Eric Huss <eric@huss.org> | 2020-09-13 08:47:24 -0700 |
|---|---|---|
| committer | Eric Huss <eric@huss.org> | 2020-09-13 08:48:03 -0700 |
| commit | c04973585df518edaa3bce547fe00793fa34d360 (patch) | |
| tree | e621ea03cbc34a16b5a4fe0b3a2943ecfdae6906 /compiler/rustc_session/src | |
| parent | ce014be0b9d0325ad9e6ecb8c93b3c8186b18089 (diff) | |
| download | rust-c04973585df518edaa3bce547fe00793fa34d360.tar.gz rust-c04973585df518edaa3bce547fe00793fa34d360.zip | |
Support `ignore` for lint examples.
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/lint.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_session/src/lint/builtin.rs | 20 |
2 files changed, 20 insertions, 6 deletions
diff --git a/compiler/rustc_session/src/lint.rs b/compiler/rustc_session/src/lint.rs index 4a3e59f18e5..62e021d5e45 100644 --- a/compiler/rustc_session/src/lint.rs +++ b/compiler/rustc_session/src/lint.rs @@ -319,8 +319,10 @@ impl LintBuffer { /// /// The `{{produces}}` tag will be automatically replaced with the output from /// the example by the build system. You can build and view the rustc book -/// with `x.py doc --stage=1 src/doc/rustc --open` (use --stage=0 if just -/// changing the wording of an existing lint). +/// with `x.py doc --stage=1 src/doc/rustc --open`. If the lint example is too +/// complex to run as a simple example (for example, it needs an extern +/// crate), mark it with `ignore` and manually paste the expected output below +/// the example. #[macro_export] macro_rules! declare_lint { ($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr) => ( diff --git a/compiler/rustc_session/src/lint/builtin.rs b/compiler/rustc_session/src/lint/builtin.rs index 22030a842db..935e910c1e2 100644 --- a/compiler/rustc_session/src/lint/builtin.rs +++ b/compiler/rustc_session/src/lint/builtin.rs @@ -128,7 +128,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail + /// ```rust,ignore (needs separate file) /// fn main() { /// include!("foo.txt"); /// } @@ -344,7 +344,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail + /// ```rust,ignore (needs extern crate) /// #![deny(unused_crate_dependencies)] /// ``` /// @@ -1984,7 +1984,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail + /// ```rust,ignore (needs extern crate) /// #![deny(macro_use_extern_crate)] /// /// #[macro_use] @@ -2378,7 +2378,19 @@ declare_lint! { /// } /// ``` /// - /// {{produces}} + /// This will produce: + /// + /// ```text + /// warning: formatting may not be suitable for sub-register argument + /// --> src/main.rs:6:19 + /// | + /// 6 | asm!("mov {0}, {0}", in(reg) 0i16); + /// | ^^^ ^^^ ---- for this argument + /// | + /// = note: `#[warn(asm_sub_register)]` on by default + /// = help: use the `x` modifier to have the register formatted as `ax` + /// = help: or use the `r` modifier to keep the default formatting of `rax` + /// ``` /// /// ### Explanation /// |
