Skip to content

Commit 2166bcf

Browse files
committed
Add "better" edition handling on lint-docs tool
1 parent 6982935 commit 2166bcf

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

compiler/rustc_lint/src/async_fn_in_trait.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ declare_lint! {
1111
///
1212
/// ### Example
1313
///
14-
/// ```rust
14+
/// ```rust,edition2018
1515
/// pub trait Trait {
1616
/// async fn method(&self);
1717
/// }
@@ -32,7 +32,7 @@ declare_lint! {
3232
///
3333
/// For example, this code is invalid:
3434
///
35-
/// ```rust,compile_fail
35+
/// ```rust,edition2018,compile_fail
3636
/// pub trait Trait {
3737
/// async fn method(&self) {}
3838
/// }
@@ -49,7 +49,7 @@ declare_lint! {
4949
///
5050
/// For example, instead of:
5151
///
52-
/// ```rust
52+
/// ```rust,edition2018
5353
/// pub trait Trait {
5454
/// async fn method(&self) {}
5555
/// }

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ declare_lint! {
12901290
///
12911291
/// ### Example
12921292
///
1293-
/// ```rust
1293+
/// ```rust,edition2018
12941294
/// #[track_caller]
12951295
/// async fn foo() {}
12961296
/// ```

compiler/rustc_lint/src/deref_into_dyn_supertrait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ declare_lint! {
1919
///
2020
/// ### Example
2121
///
22-
/// ```rust,compile_fail
22+
/// ```rust,edition2018,compile_fail
2323
/// #![deny(deref_into_dyn_supertrait)]
2424
/// #![allow(dead_code)]
2525
///

compiler/rustc_lint/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,7 @@ declare_lint! {
18991899
///
19001900
/// ### Example
19011901
///
1902-
/// ```rust,compile_fail
1902+
/// ```rust,edition2018,compile_fail
19031903
/// # use core::sync::atomic::{AtomicU8, Ordering};
19041904
/// let atom = AtomicU8::new(0);
19051905
/// let value = atom.load(Ordering::Release);

compiler/rustc_lint_defs/src/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ declare_lint! {
428428
///
429429
/// ### Example
430430
///
431-
/// ```rust
431+
/// ```rust,edition2018
432432
/// #![feature(must_not_suspend)]
433433
/// #![warn(must_not_suspend)]
434434
///
@@ -1195,7 +1195,7 @@ declare_lint! {
11951195
///
11961196
/// ### Example
11971197
///
1198-
/// ```rust,compile_fail
1198+
/// ```rust,edition2018,compile_fail
11991199
/// extern crate core;
12001200
/// pub use core as reexported_core;
12011201
/// ```
@@ -4514,7 +4514,7 @@ declare_lint! {
45144514
///
45154515
/// ### Example
45164516
///
4517-
/// ```rust,compile_fail
4517+
/// ```rust,edition2018,compile_fail
45184518
/// #![deny(ambiguous_glob_imports)]
45194519
/// pub fn foo() -> u32 {
45204520
/// use sub::*;

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,14 @@ 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") {
445-
cmd.arg("--edition=2015");
446-
} else {
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") {
447449
cmd.arg("--edition=2018");
450+
} else {
451+
cmd.arg("--edition=2015");
448452
}
449453
cmd.arg("--error-format=json");
450454
cmd.arg("--target").arg(self.rustc_target);

0 commit comments

Comments
 (0)