Switch all libraries to the 2021 edition
This commit is contained in:
parent
f52eb4ca8b
commit
06a1c14d52
18 changed files with 18 additions and 65 deletions
|
@ -6,7 +6,7 @@ repository = "https://github.com/rust-lang/rust.git"
|
||||||
description = "The Rust core allocation and collections library"
|
description = "The Rust core allocation and collections library"
|
||||||
autotests = false
|
autotests = false
|
||||||
autobenches = false
|
autobenches = false
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
core = { path = "../core" }
|
core = { path = "../core" }
|
||||||
|
|
|
@ -6,7 +6,7 @@ repository = "https://github.com/rust-lang/rust.git"
|
||||||
description = "The Rust Core Library"
|
description = "The Rust Core Library"
|
||||||
autotests = false
|
autotests = false
|
||||||
autobenches = false
|
autobenches = false
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
test = false
|
test = false
|
||||||
|
|
|
@ -66,8 +66,6 @@ where
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(array_from_fn)]
|
/// #![feature(array_from_fn)]
|
||||||
/// # // Apparently these doc tests are still on edition2018
|
|
||||||
/// # use std::convert::TryInto;
|
|
||||||
///
|
///
|
||||||
/// let array: Result<[u8; 5], _> = std::array::try_from_fn(|i| i.try_into());
|
/// let array: Result<[u8; 5], _> = std::array::try_from_fn(|i| i.try_into());
|
||||||
/// assert_eq!(array, Ok([0, 1, 2, 3, 4]));
|
/// assert_eq!(array, Ok([0, 1, 2, 3, 4]));
|
||||||
|
|
|
@ -426,8 +426,6 @@ pub trait TryInto<T>: Sized {
|
||||||
/// `TryFrom<T>` can be implemented as follows:
|
/// `TryFrom<T>` can be implemented as follows:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryFrom;
|
|
||||||
///
|
|
||||||
/// struct GreaterThanZero(i32);
|
/// struct GreaterThanZero(i32);
|
||||||
///
|
///
|
||||||
/// impl TryFrom<i32> for GreaterThanZero {
|
/// impl TryFrom<i32> for GreaterThanZero {
|
||||||
|
@ -448,8 +446,6 @@ pub trait TryInto<T>: Sized {
|
||||||
/// As described, [`i32`] implements `TryFrom<`[`i64`]`>`:
|
/// As described, [`i32`] implements `TryFrom<`[`i64`]`>`:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryFrom;
|
|
||||||
///
|
|
||||||
/// let big_number = 1_000_000_000_000i64;
|
/// let big_number = 1_000_000_000_000i64;
|
||||||
/// // Silently truncates `big_number`, requires detecting
|
/// // Silently truncates `big_number`, requires detecting
|
||||||
/// // and handling the truncation after the fact.
|
/// // and handling the truncation after the fact.
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::iter::FromIterator;
|
|
||||||
///
|
|
||||||
/// let five_fives = std::iter::repeat(5).take(5);
|
/// let five_fives = std::iter::repeat(5).take(5);
|
||||||
///
|
///
|
||||||
/// let v = Vec::from_iter(five_fives);
|
/// let v = Vec::from_iter(five_fives);
|
||||||
|
@ -37,8 +35,6 @@
|
||||||
/// Implementing `FromIterator` for your type:
|
/// Implementing `FromIterator` for your type:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::iter::FromIterator;
|
|
||||||
///
|
|
||||||
/// // A sample collection, that's just a wrapper over Vec<T>
|
/// // A sample collection, that's just a wrapper over Vec<T>
|
||||||
/// #[derive(Debug)]
|
/// #[derive(Debug)]
|
||||||
/// struct MyCollection(Vec<i32>);
|
/// struct MyCollection(Vec<i32>);
|
||||||
|
@ -102,8 +98,6 @@ pub trait FromIterator<A>: Sized {
|
||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::iter::FromIterator;
|
|
||||||
///
|
|
||||||
/// let five_fives = std::iter::repeat(5).take(5);
|
/// let five_fives = std::iter::repeat(5).take(5);
|
||||||
///
|
///
|
||||||
/// let v = Vec::from_iter(five_fives);
|
/// let v = Vec::from_iter(five_fives);
|
||||||
|
|
|
@ -1155,8 +1155,6 @@ pub trait Iterator {
|
||||||
/// Stopping after an initial [`None`]:
|
/// Stopping after an initial [`None`]:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryFrom;
|
|
||||||
///
|
|
||||||
/// let a = [0, 1, 2, -3, 4, 5, -6];
|
/// let a = [0, 1, 2, -3, 4, 5, -6];
|
||||||
///
|
///
|
||||||
/// let iter = a.iter().map_while(|x| u32::try_from(*x).ok());
|
/// let iter = a.iter().map_while(|x| u32::try_from(*x).ok());
|
||||||
|
@ -1172,8 +1170,6 @@ pub trait Iterator {
|
||||||
/// removed:
|
/// removed:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryFrom;
|
|
||||||
///
|
|
||||||
/// let a = [1, 2, -3, 4];
|
/// let a = [1, 2, -3, 4];
|
||||||
/// let mut iter = a.iter();
|
/// let mut iter = a.iter();
|
||||||
///
|
///
|
||||||
|
|
|
@ -2602,8 +2602,6 @@ macro_rules! int_impl {
|
||||||
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryInto;
|
|
||||||
///
|
|
||||||
#[doc = concat!("fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
#[doc = concat!("fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
||||||
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
||||||
/// *input = rest;
|
/// *input = rest;
|
||||||
|
@ -2633,8 +2631,6 @@ macro_rules! int_impl {
|
||||||
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryInto;
|
|
||||||
///
|
|
||||||
#[doc = concat!("fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
#[doc = concat!("fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
||||||
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
||||||
/// *input = rest;
|
/// *input = rest;
|
||||||
|
@ -2675,8 +2671,6 @@ macro_rules! int_impl {
|
||||||
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryInto;
|
|
||||||
///
|
|
||||||
#[doc = concat!("fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
#[doc = concat!("fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
||||||
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
||||||
/// *input = rest;
|
/// *input = rest;
|
||||||
|
|
|
@ -2323,8 +2323,6 @@ macro_rules! uint_impl {
|
||||||
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryInto;
|
|
||||||
///
|
|
||||||
#[doc = concat!("fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
#[doc = concat!("fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
||||||
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
||||||
/// *input = rest;
|
/// *input = rest;
|
||||||
|
@ -2354,8 +2352,6 @@ macro_rules! uint_impl {
|
||||||
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryInto;
|
|
||||||
///
|
|
||||||
#[doc = concat!("fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
#[doc = concat!("fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
||||||
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
||||||
/// *input = rest;
|
/// *input = rest;
|
||||||
|
@ -2396,8 +2392,6 @@ macro_rules! uint_impl {
|
||||||
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
/// When starting from a slice rather than an array, fallible conversion APIs can be used:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::convert::TryInto;
|
|
||||||
///
|
|
||||||
#[doc = concat!("fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
#[doc = concat!("fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
|
||||||
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
#[doc = concat!(" let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
|
||||||
/// *input = rest;
|
/// *input = rest;
|
||||||
|
|
|
@ -4,7 +4,7 @@ version = "0.0.0"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/rust-lang/rust.git"
|
repository = "https://github.com/rust-lang/rust.git"
|
||||||
description = "Implementation of Rust panics via process aborts"
|
description = "Implementation of Rust panics via process aborts"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
test = false
|
test = false
|
||||||
|
|
|
@ -4,7 +4,7 @@ version = "0.0.0"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/rust-lang/rust.git"
|
repository = "https://github.com/rust-lang/rust.git"
|
||||||
description = "Implementation of Rust panics via stack unwinding"
|
description = "Implementation of Rust panics via stack unwinding"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
test = false
|
test = false
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "proc_macro"
|
name = "proc_macro"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
std = { path = "../std" }
|
std = { path = "../std" }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "profiler_builtins"
|
name = "profiler_builtins"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
test = false
|
test = false
|
||||||
|
|
|
@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
|
||||||
description = """
|
description = """
|
||||||
Hack for the compiler's own build system
|
Hack for the compiler's own build system
|
||||||
"""
|
"""
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
|
@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
|
||||||
description = """
|
description = """
|
||||||
Hack for the compiler's own build system
|
Hack for the compiler's own build system
|
||||||
"""
|
"""
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
|
@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
|
||||||
description = """
|
description = """
|
||||||
Hack for the compiler's own build system
|
Hack for the compiler's own build system
|
||||||
"""
|
"""
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "test"
|
name = "test"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["dylib", "rlib"]
|
crate-type = ["dylib", "rlib"]
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "unwind"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/rust-lang/rust.git"
|
repository = "https://github.com/rust-lang/rust.git"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
include = [
|
include = [
|
||||||
'/libunwind/*',
|
'/libunwind/*',
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,11 +2,6 @@
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
fn is_edition_2018(mut line: &str) -> bool {
|
|
||||||
line = line.trim();
|
|
||||||
line == "edition = \"2018\""
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_edition_2021(mut line: &str) -> bool {
|
fn is_edition_2021(mut line: &str) -> bool {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
line == "edition = \"2021\""
|
line == "edition = \"2021\""
|
||||||
|
@ -23,27 +18,13 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not all library crates are ready to migrate to 2021.
|
let is_2021 = contents.lines().any(is_edition_2021);
|
||||||
if file.components().any(|c| c.as_os_str() == "library")
|
if !is_2021 {
|
||||||
&& file.components().all(|c| c.as_os_str() != "std")
|
tidy_error!(
|
||||||
{
|
bad,
|
||||||
let has = contents.lines().any(is_edition_2018);
|
"{} doesn't have `edition = \"2021\"` on a separate line",
|
||||||
if !has {
|
file.display()
|
||||||
tidy_error!(
|
);
|
||||||
bad,
|
|
||||||
"{} doesn't have `edition = \"2018\"` on a separate line",
|
|
||||||
file.display()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let is_2021 = contents.lines().any(is_edition_2021);
|
|
||||||
if !is_2021 {
|
|
||||||
tidy_error!(
|
|
||||||
bad,
|
|
||||||
"{} doesn't have `edition = \"2021\"` on a separate line",
|
|
||||||
file.display()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue