Skip to content

Commit

Permalink
Rollup merge of #125522 - spastorino:fix-lint-docs-edition-handling, …
Browse files Browse the repository at this point in the history
…r=Urgau,michaelwoerister

Add "better" edition handling on lint-docs tool

r? `@Urgau`
  • Loading branch information
GuillaumeGomez authored May 27, 2024
2 parents 86f2fa3 + 41d4a95 commit ad37f40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3757,7 +3757,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,compile_fail
/// ```rust,edition2018,compile_fail
/// #![deny(rust_2021_incompatible_or_patterns)]
///
/// macro_rules! match_any {
Expand Down Expand Up @@ -3797,7 +3797,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,compile_fail
/// ```rust,edition2018,compile_fail
/// #![deny(rust_2021_prelude_collisions)]
///
/// trait Foo {
Expand Down
13 changes: 11 additions & 2 deletions src/tools/lint-docs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ad37f40

Please sign in to comment.