diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2024-05-24 23:58:00 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2024-05-24 23:58:27 -0300 |
| commit | 41d4a95fcaa49560a8b6cd2048ed5ef4bfdfa7c1 (patch) | |
| tree | 9a729fcb514d8dd87a18742cd4e87542dee74a8f | |
| parent | 698293518de49ac79eb7874e97557f8e2eabda06 (diff) | |
| download | rust-41d4a95fcaa49560a8b6cd2048ed5ef4bfdfa7c1.tar.gz rust-41d4a95fcaa49560a8b6cd2048ed5ef4bfdfa7c1.zip | |
Add "better" edition handling on lint-docs tool
| -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 53694545772..8727dcfad9a 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -3803,7 +3803,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail + /// ```rust,edition2018,compile_fail /// #![deny(rust_2021_incompatible_or_patterns)] /// /// macro_rules! match_any { @@ -3843,7 +3843,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); |
