Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stdlib to the 2021 edition #92030

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
description = "The Rust Standard Library"
edition = "2018"
edition = "2021"

[lib]
crate-type = ["dylib", "rlib"]
Expand Down
9 changes: 4 additions & 5 deletions library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ macro_rules! error {
($e:expr, $s:expr) => {
match $e {
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
Err(ref err) => assert!(
err.raw_os_error() == Some($s),
format!("`{}` did not have a code of `{}`", err, $s)
),
Err(ref err) => {
assert!(err.raw_os_error() == Some($s), "`{}` did not have a code of `{}`", err, $s)
}
}
};
}
Expand All @@ -58,7 +57,7 @@ macro_rules! error_contains {
match $e {
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
Err(ref err) => {
assert!(err.to_string().contains($s), format!("`{}` did not contain `{}`", err, $s))
assert!(err.to_string().contains($s), "`{}` did not contain `{}`", err, $s)
}
}
};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,6 @@ impl ExitStatusError {
/// ```
/// #![feature(exit_status_error)]
/// # if cfg!(unix) {
/// use std::convert::TryFrom;
/// use std::num::NonZeroI32;
/// use std::process::Command;
///
Expand Down
15 changes: 8 additions & 7 deletions library/std/src/thread/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::Builder;
use crate::any::Any;
use crate::mem;
use crate::panic::panic_any;
use crate::result;
use crate::sync::{
mpsc::{channel, Sender},
Expand Down Expand Up @@ -183,7 +184,7 @@ fn test_simple_newsched_spawn() {
}

#[test]
fn test_try_panic_message_static_str() {
fn test_try_panic_message_string_literal() {
match thread::spawn(move || {
panic!("static string");
})
Expand All @@ -199,9 +200,9 @@ fn test_try_panic_message_static_str() {
}

#[test]
fn test_try_panic_message_owned_str() {
fn test_try_panic_any_message_owned_str() {
match thread::spawn(move || {
panic!("owned string".to_string());
panic_any("owned string".to_string());
})
.join()
{
Expand All @@ -215,9 +216,9 @@ fn test_try_panic_message_owned_str() {
}

#[test]
fn test_try_panic_message_any() {
fn test_try_panic_any_message_any() {
match thread::spawn(move || {
panic!(box 413u16 as Box<dyn Any + Send>);
panic_any(box 413u16 as Box<dyn Any + Send>);
})
.join()
{
Expand All @@ -233,10 +234,10 @@ fn test_try_panic_message_any() {
}

#[test]
fn test_try_panic_message_unit_struct() {
fn test_try_panic_any_message_unit_struct() {
struct Juju;

match thread::spawn(move || panic!(Juju)).join() {
match thread::spawn(move || panic_any(Juju)).join() {
Err(ref e) if e.is::<Juju>() => {}
Err(_) | Ok(()) => panic!(),
}
Expand Down
6 changes: 4 additions & 2 deletions src/tools/tidy/src/edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ pub fn check(path: &Path, bad: &mut bool) {
return;
}

// Library crates are not yet ready to migrate to 2021.
if path.components().any(|c| c.as_os_str() == "library") {
// Not all library crates are ready to migrate to 2021.
if file.components().any(|c| c.as_os_str() == "library")
&& file.components().all(|c| c.as_os_str() != "std")
{
let has = contents.lines().any(is_edition_2018);
if !has {
tidy_error!(
Expand Down