Skip to content

Commit

Permalink
Add "better" edition handling on lint-docs tool
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed May 24, 2024
1 parent 6982935 commit 2166bcf
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_lint/src/async_fn_in_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust
/// ```rust,edition2018
/// pub trait Trait {
/// async fn method(&self);
/// }
Expand All @@ -32,7 +32,7 @@ declare_lint! {
///
/// For example, this code is invalid:
///
/// ```rust,compile_fail
/// ```rust,edition2018,compile_fail
/// pub trait Trait {
/// async fn method(&self) {}
/// }
Expand All @@ -49,7 +49,7 @@ declare_lint! {
///
/// For example, instead of:
///
/// ```rust
/// ```rust,edition2018
/// pub trait Trait {
/// async fn method(&self) {}
/// }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust
/// ```rust,edition2018
/// #[track_caller]
/// async fn foo() {}
/// ```
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/deref_into_dyn_supertrait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,compile_fail
/// ```rust,edition2018,compile_fail
/// #![deny(deref_into_dyn_supertrait)]
/// #![allow(dead_code)]
///
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,compile_fail
/// ```rust,edition2018,compile_fail
/// # use core::sync::atomic::{AtomicU8, Ordering};
/// let atom = AtomicU8::new(0);
/// let value = atom.load(Ordering::Release);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust
/// ```rust,edition2018
/// #![feature(must_not_suspend)]
/// #![warn(must_not_suspend)]
///
Expand Down Expand Up @@ -1195,7 +1195,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,compile_fail
/// ```rust,edition2018,compile_fail
/// extern crate core;
/// pub use core as reexported_core;
/// ```
Expand Down Expand Up @@ -4514,7 +4514,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,compile_fail
/// ```rust,edition2018,compile_fail
/// #![deny(ambiguous_glob_imports)]
/// pub fn foo() -> u32 {
/// use sub::*;
Expand Down
10 changes: 7 additions & 3 deletions src/tools/lint-docs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,14 @@ 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") {
cmd.arg("--edition=2015");
} else {
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 {
cmd.arg("--edition=2015");
}
cmd.arg("--error-format=json");
cmd.arg("--target").arg(self.rustc_target);
Expand Down

0 comments on commit 2166bcf

Please sign in to comment.