diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-05-27 13:10:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-27 13:10:34 +0200 |
| commit | ad37f403553ef7e2250b5bae66767a9af2c9412a (patch) | |
| tree | 0dcc0eea041e798483325a56900979748aed52f6 | |
| parent | 86f2fa35a2289e4af5b5859d9762c431840a4655 (diff) | |
| parent | 41d4a95fcaa49560a8b6cd2048ed5ef4bfdfa7c1 (diff) | |
| download | rust-ad37f403553ef7e2250b5bae66767a9af2c9412a.tar.gz rust-ad37f403553ef7e2250b5bae66767a9af2c9412a.zip | |
Rollup merge of #125522 - spastorino:fix-lint-docs-edition-handling, r=Urgau,michaelwoerister
Add "better" edition handling on lint-docs tool r? `@Urgau`
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 4 | ||||
| -rw-r--r-- | src/tools/lint-docs/src/lib.rs | 13 |
2 files changed, 13 insertions, 4 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 42e12a88fa5..13867319e5c 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -3757,7 +3757,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail + /// ```rust,edition2018,compile_fail /// #![deny(rust_2021_incompatible_or_patterns)] /// /// macro_rules! match_any { @@ -3797,7 +3797,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail + /// ```rust,edition2018,compile_fail /// #![deny(rust_2021_prelude_collisions)] /// /// trait Foo { diff --git a/src/tools/lint-docs/src/lib.rs b/src/tools/lint-docs/src/lib.rs index 22ab576b077..c79b377727a 100644 --- a/src/tools/lint-docs/src/lib.rs +++ b/src/tools/lint-docs/src/lib.rs @@ -441,10 +441,19 @@ impl<'a> LintExtractor<'a> { fs::write(&tempfile, source) .map_err(|e| format!("failed to write {}: {}", tempfile.display(), e))?; let mut cmd = Command::new(self.rustc_path); - if options.contains(&"edition2015") { + if options.contains(&"edition2024") { + cmd.arg("--edition=2024"); + } else if options.contains(&"edition2021") { + cmd.arg("--edition=2021"); + } else if options.contains(&"edition2018") { + cmd.arg("--edition=2018"); + } else if options.contains(&"edition2015") { cmd.arg("--edition=2015"); + } else if options.contains(&"edition") { + panic!("lint-docs: unknown edition"); } else { - cmd.arg("--edition=2018"); + // defaults to latest edition + cmd.arg("--edition=2021"); } cmd.arg("--error-format=json"); cmd.arg("--target").arg(self.rustc_target); |
