Add "better" edition handling on lint-docs tool

This commit is contained in:
Santiago Pastorino 2024-05-24 23:58:00 -03:00
parent 698293518d
commit 41d4a95fca
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
2 changed files with 14 additions and 5 deletions

View file

@ -3803,7 +3803,7 @@ declare_lint! {
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust,compile_fail /// ```rust,edition2018,compile_fail
/// #![deny(rust_2021_incompatible_or_patterns)] /// #![deny(rust_2021_incompatible_or_patterns)]
/// ///
/// macro_rules! match_any { /// macro_rules! match_any {
@ -3843,7 +3843,7 @@ declare_lint! {
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust,compile_fail /// ```rust,edition2018,compile_fail
/// #![deny(rust_2021_prelude_collisions)] /// #![deny(rust_2021_prelude_collisions)]
/// ///
/// trait Foo { /// trait Foo {

View file

@ -441,10 +441,19 @@ impl<'a> LintExtractor<'a> {
fs::write(&tempfile, source) fs::write(&tempfile, source)
.map_err(|e| format!("failed to write {}: {}", tempfile.display(), e))?; .map_err(|e| format!("failed to write {}: {}", tempfile.display(), e))?;
let mut cmd = Command::new(self.rustc_path); let mut cmd = Command::new(self.rustc_path);
if options.contains(&"edition2015") { if options.contains(&"edition2024") {
cmd.arg("--edition=2015"); cmd.arg("--edition=2024");
} else { } else if options.contains(&"edition2021") {
cmd.arg("--edition=2021");
} else if options.contains(&"edition2018") {
cmd.arg("--edition=2018"); cmd.arg("--edition=2018");
} else if options.contains(&"edition2015") {
cmd.arg("--edition=2015");
} else if options.contains(&"edition") {
panic!("lint-docs: unknown edition");
} else {
// defaults to latest edition
cmd.arg("--edition=2021");
} }
cmd.arg("--error-format=json"); cmd.arg("--error-format=json");
cmd.arg("--target").arg(self.rustc_target); cmd.arg("--target").arg(self.rustc_target);