Skip to content

Commit a7fc929

Browse files
authored
Unrolled build for rust-lang#125522
Rollup merge of rust-lang#125522 - spastorino:fix-lint-docs-edition-handling, r=Urgau,michaelwoerister Add "better" edition handling on lint-docs tool r? `@Urgau`
2 parents a59072e + 41d4a95 commit a7fc929

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3757,7 +3757,7 @@ declare_lint! {
37573757
///
37583758
/// ### Example
37593759
///
3760-
/// ```rust,compile_fail
3760+
/// ```rust,edition2018,compile_fail
37613761
/// #![deny(rust_2021_incompatible_or_patterns)]
37623762
///
37633763
/// macro_rules! match_any {
@@ -3797,7 +3797,7 @@ declare_lint! {
37973797
///
37983798
/// ### Example
37993799
///
3800-
/// ```rust,compile_fail
3800+
/// ```rust,edition2018,compile_fail
38013801
/// #![deny(rust_2021_prelude_collisions)]
38023802
///
38033803
/// trait Foo {

src/tools/lint-docs/src/lib.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,19 @@ impl<'a> LintExtractor<'a> {
441441
fs::write(&tempfile, source)
442442
.map_err(|e| format!("failed to write {}: {}", tempfile.display(), e))?;
443443
let mut cmd = Command::new(self.rustc_path);
444-
if options.contains(&"edition2015") {
444+
if options.contains(&"edition2024") {
445+
cmd.arg("--edition=2024");
446+
} else if options.contains(&"edition2021") {
447+
cmd.arg("--edition=2021");
448+
} else if options.contains(&"edition2018") {
449+
cmd.arg("--edition=2018");
450+
} else if options.contains(&"edition2015") {
445451
cmd.arg("--edition=2015");
452+
} else if options.contains(&"edition") {
453+
panic!("lint-docs: unknown edition");
446454
} else {
447-
cmd.arg("--edition=2018");
455+
// defaults to latest edition
456+
cmd.arg("--edition=2021");
448457
}
449458
cmd.arg("--error-format=json");
450459
cmd.arg("--target").arg(self.rustc_target);

0 commit comments

Comments
 (0)