Skip to content

Commit ac2d9fc

Browse files
committed
Auto merge of rust-lang#89103 - Mark-Simulacrum:migrate-2021, r=estebank
Migrate in-tree crates to 2021 This replaces rust-lang#89075 (cherry picking some of the commits from there), and closes rust-lang#88637 and fixes rust-lang#89074. It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there. I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first. Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately. It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.
2 parents 840acd3 + 3b89679 commit ac2d9fc

File tree

104 files changed

+185
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+185
-152
lines changed

compiler/rustc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc-main"
33
version = "0.0.0"
4-
edition = '2018'
4+
edition = "2021"
55

66
[dependencies]
77
rustc_driver = { path = "../rustc_driver" }

compiler/rustc_apfloat/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_apfloat"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[dependencies]
77
bitflags = "1.2.1"

compiler/rustc_arena/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_arena"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[dependencies]
77
rustc_data_structures = { path = "../rustc_data_structures" }

compiler/rustc_ast/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_ast"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_ast_lowering/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_ast_lowering"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_ast_passes/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_ast_passes"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[dependencies]
77
itertools = "0.9"

compiler/rustc_ast_pretty/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_ast_pretty"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_attr/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_attr"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_borrowck/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_borrowck"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_builtin_macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_builtin_macros"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_codegen_cranelift/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_codegen_cranelift"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
crate-type = ["dylib"]

compiler/rustc_codegen_cranelift/src/bin/cg_clif_build_sysroot.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
99
#![feature(rustc_private)]
1010

11-
extern crate rustc_data_structures;
1211
extern crate rustc_driver;
1312
extern crate rustc_interface;
1413
extern crate rustc_session;

compiler/rustc_codegen_llvm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_codegen_llvm"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
test = false

compiler/rustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_codegen_ssa"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
test = false

compiler/rustc_const_eval/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_const_eval"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_const_eval/src/interpret/validity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ macro_rules! throw_validation_failure {
7777
///
7878
macro_rules! try_validation {
7979
($e:expr, $where:expr,
80-
$( $( $p:pat )|+ => { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )? ),+ $(,)?
80+
$( $( $p:pat_param )|+ => { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )? ),+ $(,)?
8181
) => {{
8282
match $e {
8383
Ok(x) => x,

compiler/rustc_data_structures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_data_structures"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_driver/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_driver"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
crate-type = ["dylib"]

compiler/rustc_error_codes/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[package]
22
name = "rustc_error_codes"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"

compiler/rustc_errors/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_errors"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_errors/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1028,15 +1028,13 @@ impl HandlerInner {
10281028
let mut error_codes = self
10291029
.emitted_diagnostic_codes
10301030
.iter()
1031-
.filter_map(|x| {
1032-
match &x {
1031+
.filter_map(|x| match &x {
10331032
DiagnosticId::Error(s)
1034-
if let Ok(Some(_explanation)) = registry.try_find_description(s) =>
1033+
if registry.try_find_description(s).map_or(false, |o| o.is_some()) =>
10351034
{
10361035
Some(s.clone())
10371036
}
10381037
_ => None,
1039-
}
10401038
})
10411039
.collect::<Vec<_>>();
10421040
if !error_codes.is_empty() {

compiler/rustc_expand/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_expand"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55
build = false
66

77
[lib]

compiler/rustc_feature/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_feature"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_fs_util/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[package]
22
name = "rustc_fs_util"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"

compiler/rustc_graphviz/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[package]
22
name = "rustc_graphviz"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"

compiler/rustc_hir/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_hir"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_hir_pretty/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_hir_pretty"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_incremental/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_incremental"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_index/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_index"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_infer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_infer"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_interface/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_interface"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

compiler/rustc_interface/src/util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f:
125125
let result_ptr = Ptr(&mut result as *mut _ as *mut ());
126126

127127
let thread = cfg.spawn(move || {
128+
let _ = (&run, &result_ptr);
128129
let run = unsafe { (*(run.0 as *mut Option<F>)).take().unwrap() };
129130
let result = unsafe { &mut *(result_ptr.0 as *mut Option<R>) };
130131
*result = Some(run());

compiler/rustc_lexer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rustc_lexer"
33
version = "0.1.0"
44
license = "MIT OR Apache-2.0"
5-
edition = "2018"
5+
edition = "2021"
66

77
repository = "https://github.com/rust-lang/rust/"
88
description = """

compiler/rustc_lint/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_lint"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[dependencies]
77
if_chain = "1.0"

compiler/rustc_lint/src/array_into_iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare_lint! {
1313
///
1414
/// ### Example
1515
///
16-
/// ```rust
16+
/// ```rust,edition2018
1717
/// # #![allow(unused)]
1818
/// [1, 2, 3].into_iter().for_each(|n| { *n; });
1919
/// ```

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ declare_lint! {
16861686
///
16871687
/// ### Example
16881688
///
1689-
/// ```rust
1689+
/// ```rust,edition2018
16901690
/// let x = 123;
16911691
/// match x {
16921692
/// 0...100 => {}

compiler/rustc_lint/src/non_fmt_panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ declare_lint! {
1818
///
1919
/// ### Example
2020
///
21-
/// ```rust,no_run
21+
/// ```rust,no_run,edition2018
2222
/// panic!("{}");
2323
/// panic!(123);
2424
/// ```

compiler/rustc_lint_defs/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_lint_defs"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[dependencies]
77
rustc_ast = { path = "../rustc_ast" }

compiler/rustc_lint_defs/src/builtin.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ declare_lint! {
15841584
///
15851585
/// ### Example
15861586
///
1587-
/// ```rust
1587+
/// ```rust,edition2018
15881588
/// trait Trait { }
15891589
///
15901590
/// fn takes_trait_object(_: Box<Trait>) {
@@ -3313,7 +3313,7 @@ declare_lint! {
33133313
///
33143314
/// ### Example
33153315
///
3316-
/// ```rust,compile_fail
3316+
/// ```rust,edition2018,compile_fail
33173317
/// #![deny(rust_2021_prefixes_incompatible_syntax)]
33183318
///
33193319
/// macro_rules! m {
@@ -3333,6 +3333,8 @@ declare_lint! {
33333333
///
33343334
/// This lint suggests to add whitespace between the `z` and `"hey"` tokens
33353335
/// to keep them separated in Rust 2021.
3336+
// Allow this lint -- rustdoc doesn't yet support threading edition into this lint's parser.
3337+
#[allow(rustdoc::invalid_rust_codeblocks)]
33363338
pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
33373339
Allow,
33383340
"identifiers that will be parsed as a prefix in Rust 2021",

compiler/rustc_llvm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_llvm"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[features]
77
static-libstdcpp = []

compiler/rustc_macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_macros"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
proc-macro = true

compiler/rustc_metadata/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc_metadata"
33
version = "0.0.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[lib]
77
doctest = false

0 commit comments

Comments
 (0)