Skip to content

Commit

Permalink
Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank
Browse files Browse the repository at this point in the history
Migrate in-tree crates to 2021

This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #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.
  • Loading branch information
bors committed Sep 21, 2021
2 parents 840acd3 + 3b89679 commit ac2d9fc
Show file tree
Hide file tree
Showing 104 changed files with 185 additions and 152 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc-main"
version = "0.0.0"
edition = '2018'
edition = "2021"

[dependencies]
rustc_driver = { path = "../rustc_driver" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_apfloat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_apfloat"
version = "0.0.0"
edition = "2018"
edition = "2021"

[dependencies]
bitflags = "1.2.1"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_arena/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_arena"
version = "0.0.0"
edition = "2018"
edition = "2021"

[dependencies]
rustc_data_structures = { path = "../rustc_data_structures" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_ast"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_ast_lowering"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_ast_passes"
version = "0.0.0"
edition = "2018"
edition = "2021"

[dependencies]
itertools = "0.9"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_ast_pretty"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_attr"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_borrowck"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_builtin_macros"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_codegen_cranelift"
version = "0.1.0"
edition = "2018"
edition = "2021"

[lib]
crate-type = ["dylib"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#![feature(rustc_private)]

extern crate rustc_data_structures;
extern crate rustc_driver;
extern crate rustc_interface;
extern crate rustc_session;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_codegen_llvm"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
test = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_codegen_ssa"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
test = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_const_eval"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ macro_rules! throw_validation_failure {
///
macro_rules! try_validation {
($e:expr, $where:expr,
$( $( $p:pat )|+ => { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )? ),+ $(,)?
$( $( $p:pat_param )|+ => { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )? ),+ $(,)?
) => {{
match $e {
Ok(x) => x,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_data_structures"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_driver"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
crate-type = ["dylib"]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
name = "rustc_error_codes"
version = "0.0.0"
edition = "2018"
edition = "2021"
2 changes: 1 addition & 1 deletion compiler/rustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_errors"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,15 +1028,13 @@ impl HandlerInner {
let mut error_codes = self
.emitted_diagnostic_codes
.iter()
.filter_map(|x| {
match &x {
.filter_map(|x| match &x {
DiagnosticId::Error(s)
if let Ok(Some(_explanation)) = registry.try_find_description(s) =>
if registry.try_find_description(s).map_or(false, |o| o.is_some()) =>
{
Some(s.clone())
}
_ => None,
}
})
.collect::<Vec<_>>();
if !error_codes.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_expand"
version = "0.0.0"
edition = "2018"
edition = "2021"
build = false

[lib]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_feature"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_fs_util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
name = "rustc_fs_util"
version = "0.0.0"
edition = "2018"
edition = "2021"
2 changes: 1 addition & 1 deletion compiler/rustc_graphviz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
name = "rustc_graphviz"
version = "0.0.0"
edition = "2018"
edition = "2021"
2 changes: 1 addition & 1 deletion compiler/rustc_hir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_hir"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_pretty/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_hir_pretty"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_incremental/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_incremental"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_index/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_index"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_infer"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_interface"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f:
let result_ptr = Ptr(&mut result as *mut _ as *mut ());

let thread = cfg.spawn(move || {
let _ = (&run, &result_ptr);
let run = unsafe { (*(run.0 as *mut Option<F>)).take().unwrap() };
let result = unsafe { &mut *(result_ptr.0 as *mut Option<R>) };
*result = Some(run());
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "rustc_lexer"
version = "0.1.0"
license = "MIT OR Apache-2.0"
edition = "2018"
edition = "2021"

repository = "https://github.com/rust-lang/rust/"
description = """
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_lint"
version = "0.0.0"
edition = "2018"
edition = "2021"

[dependencies]
if_chain = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/array_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust
/// ```rust,edition2018
/// # #![allow(unused)]
/// [1, 2, 3].into_iter().for_each(|n| { *n; });
/// ```
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 @@ -1686,7 +1686,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust
/// ```rust,edition2018
/// let x = 123;
/// match x {
/// 0...100 => {}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/non_fmt_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,no_run
/// ```rust,no_run,edition2018
/// panic!("{}");
/// panic!(123);
/// ```
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint_defs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_lint_defs"
version = "0.0.0"
edition = "2018"
edition = "2021"

[dependencies]
rustc_ast = { path = "../rustc_ast" }
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust
/// ```rust,edition2018
/// trait Trait { }
///
/// fn takes_trait_object(_: Box<Trait>) {
Expand Down Expand Up @@ -3313,7 +3313,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,compile_fail
/// ```rust,edition2018,compile_fail
/// #![deny(rust_2021_prefixes_incompatible_syntax)]
///
/// macro_rules! m {
Expand All @@ -3333,6 +3333,8 @@ declare_lint! {
///
/// This lint suggests to add whitespace between the `z` and `"hey"` tokens
/// to keep them separated in Rust 2021.
// Allow this lint -- rustdoc doesn't yet support threading edition into this lint's parser.
#[allow(rustdoc::invalid_rust_codeblocks)]
pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
Allow,
"identifiers that will be parsed as a prefix in Rust 2021",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_llvm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_llvm"
version = "0.0.0"
edition = "2018"
edition = "2021"

[features]
static-libstdcpp = []
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_macros"
version = "0.1.0"
edition = "2018"
edition = "2021"

[lib]
proc-macro = true
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc_metadata"
version = "0.0.0"
edition = "2018"
edition = "2021"

[lib]
doctest = false
Expand Down
Loading

0 comments on commit ac2d9fc

Please sign in to comment.