Skip to content

Commit

Permalink
Rollup merge of rust-lang#92030 - rukai:stdlib2021, r=m-ou-se
Browse files Browse the repository at this point in the history
Update stdlib to the 2021 edition

progress towards rust-lang#88638

I couldnt find a way to run the 2018 style panic tests against 2018 so I just deleted them, maybe theres a way to do it that I missed though?
  • Loading branch information
matthiaskrgr authored Dec 18, 2021
2 parents b8d0fa7 + b656384 commit f3bf520
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
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

0 comments on commit f3bf520

Please sign in to comment.