Update stdlib to the 2021 edition

This commit is contained in:
Lucas Kent 2021-12-17 20:08:36 +11:00
parent 9b45f04414
commit b656384d83
5 changed files with 17 additions and 16 deletions

View File

@ -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 = "The Rust Standard Library" description = "The Rust Standard Library"
edition = "2018" edition = "2021"
[lib] [lib]
crate-type = ["dylib", "rlib"] crate-type = ["dylib", "rlib"]

View File

@ -38,10 +38,9 @@ macro_rules! error {
($e:expr, $s:expr) => { ($e:expr, $s:expr) => {
match $e { match $e {
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s), Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
Err(ref err) => assert!( Err(ref err) => {
err.raw_os_error() == Some($s), assert!(err.raw_os_error() == Some($s), "`{}` did not have a code of `{}`", err, $s)
format!("`{}` did not have a code of `{}`", err, $s) }
),
} }
}; };
} }
@ -58,7 +57,7 @@ macro_rules! error_contains {
match $e { match $e {
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s), Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
Err(ref err) => { 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)
} }
} }
}; };

View File

@ -1600,7 +1600,6 @@ impl ExitStatusError {
/// ``` /// ```
/// #![feature(exit_status_error)] /// #![feature(exit_status_error)]
/// # if cfg!(unix) { /// # if cfg!(unix) {
/// use std::convert::TryFrom;
/// use std::num::NonZeroI32; /// use std::num::NonZeroI32;
/// use std::process::Command; /// use std::process::Command;
/// ///

View File

@ -1,6 +1,7 @@
use super::Builder; use super::Builder;
use crate::any::Any; use crate::any::Any;
use crate::mem; use crate::mem;
use crate::panic::panic_any;
use crate::result; use crate::result;
use crate::sync::{ use crate::sync::{
mpsc::{channel, Sender}, mpsc::{channel, Sender},
@ -183,7 +184,7 @@ fn test_simple_newsched_spawn() {
} }
#[test] #[test]
fn test_try_panic_message_static_str() { fn test_try_panic_message_string_literal() {
match thread::spawn(move || { match thread::spawn(move || {
panic!("static string"); panic!("static string");
}) })
@ -199,9 +200,9 @@ fn test_try_panic_message_static_str() {
} }
#[test] #[test]
fn test_try_panic_message_owned_str() { fn test_try_panic_any_message_owned_str() {
match thread::spawn(move || { match thread::spawn(move || {
panic!("owned string".to_string()); panic_any("owned string".to_string());
}) })
.join() .join()
{ {
@ -215,9 +216,9 @@ fn test_try_panic_message_owned_str() {
} }
#[test] #[test]
fn test_try_panic_message_any() { fn test_try_panic_any_message_any() {
match thread::spawn(move || { match thread::spawn(move || {
panic!(box 413u16 as Box<dyn Any + Send>); panic_any(box 413u16 as Box<dyn Any + Send>);
}) })
.join() .join()
{ {
@ -233,10 +234,10 @@ fn test_try_panic_message_any() {
} }
#[test] #[test]
fn test_try_panic_message_unit_struct() { fn test_try_panic_any_message_unit_struct() {
struct Juju; 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(ref e) if e.is::<Juju>() => {}
Err(_) | Ok(()) => panic!(), Err(_) | Ok(()) => panic!(),
} }

View File

@ -23,8 +23,10 @@ pub fn check(path: &Path, bad: &mut bool) {
return; return;
} }
// Library crates are not yet ready to migrate to 2021. // Not all library crates are ready to migrate to 2021.
if path.components().any(|c| c.as_os_str() == "library") { 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); let has = contents.lines().any(is_edition_2018);
if !has { if !has {
tidy_error!( tidy_error!(