Skip to content

Commit 55fcb35

Browse files
authored
Unrolled build for rust-lang#140348
Rollup merge of rust-lang#140348 - ehuss:lint-docs-edition, r=compiler-errors Update lint-docs to default to Rust 2024 This updates the lint-docs tool to default to the 2024 edition. The lint docs are supposed to illustrate the code with the latest edition, and I just forgot to update this in rust-lang#133349. Some docs needed to add the `edition` attribute since they were assuming a particular edition, but were missing the explicit annotation. This also includes a commit to simplify the edition handling in lint-docs.
2 parents 267cae5 + 1f108fe commit 55fcb35

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ declare_lint! {
948948
///
949949
/// ### Example
950950
///
951-
/// ```rust,compile_fail
951+
/// ```rust,compile_fail,edition2021
952952
/// #[no_mangle]
953953
/// const FOO: i32 = 5;
954954
/// ```

compiler/rustc_lint/src/impl_trait_overcaptures.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ declare_lint! {
4141
///
4242
/// ### Example
4343
///
44-
/// ```rust,compile_fail
44+
/// ```rust,compile_fail,edition2021
4545
/// # #![deny(impl_trait_overcaptures)]
4646
/// # use std::fmt::Display;
4747
/// let mut x = vec![];

compiler/rustc_lint_defs/src/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ declare_lint! {
14241424
///
14251425
/// ### Example
14261426
///
1427-
/// ```rust,compile_fail
1427+
/// ```rust,compile_fail,edition2021
14281428
/// macro_rules! foo {
14291429
/// () => {};
14301430
/// ($name) => { };
@@ -4128,7 +4128,7 @@ declare_lint! {
41284128
///
41294129
/// ### Example
41304130
///
4131-
/// ```rust,compile_fail
4131+
/// ```rust,compile_fail,edition2021
41324132
/// #![deny(dependency_on_unit_never_type_fallback)]
41334133
/// fn main() {
41344134
/// if true {

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

+8-14
Original file line numberDiff line numberDiff line change
@@ -444,21 +444,15 @@ impl<'a> LintExtractor<'a> {
444444
fs::write(&tempfile, source)
445445
.map_err(|e| format!("failed to write {}: {}", tempfile.display(), e))?;
446446
let mut cmd = Command::new(self.rustc_path);
447-
if options.contains(&"edition2024") {
448-
cmd.arg("--edition=2024");
449-
cmd.arg("-Zunstable-options");
450-
} else if options.contains(&"edition2021") {
451-
cmd.arg("--edition=2021");
452-
} else if options.contains(&"edition2018") {
453-
cmd.arg("--edition=2018");
454-
} else if options.contains(&"edition2015") {
455-
cmd.arg("--edition=2015");
456-
} else if options.contains(&"edition") {
457-
panic!("lint-docs: unknown edition");
458-
} else {
447+
let edition = options
448+
.iter()
449+
.filter_map(|opt| opt.strip_prefix("edition"))
450+
.next()
459451
// defaults to latest edition
460-
cmd.arg("--edition=2021");
461-
}
452+
.unwrap_or("2024");
453+
cmd.arg(format!("--edition={edition}"));
454+
// Just in case this is an unstable edition.
455+
cmd.arg("-Zunstable-options");
462456
cmd.arg("--error-format=json");
463457
cmd.arg("--target").arg(self.rustc_target);
464458
if let Some(target_linker) = self.rustc_linker {

0 commit comments

Comments
 (0)