Skip to content

Commit b656384

Browse files
committed
Update stdlib to the 2021 edition
1 parent 9b45f04 commit b656384

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
license = "MIT OR Apache-2.0"
55
repository = "https://github.com/rust-lang/rust.git"
66
description = "The Rust Standard Library"
7-
edition = "2018"
7+
edition = "2021"
88

99
[lib]
1010
crate-type = ["dylib", "rlib"]

library/std/src/fs/tests.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ macro_rules! error {
3838
($e:expr, $s:expr) => {
3939
match $e {
4040
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
41-
Err(ref err) => assert!(
42-
err.raw_os_error() == Some($s),
43-
format!("`{}` did not have a code of `{}`", err, $s)
44-
),
41+
Err(ref err) => {
42+
assert!(err.raw_os_error() == Some($s), "`{}` did not have a code of `{}`", err, $s)
43+
}
4544
}
4645
};
4746
}
@@ -58,7 +57,7 @@ macro_rules! error_contains {
5857
match $e {
5958
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
6059
Err(ref err) => {
61-
assert!(err.to_string().contains($s), format!("`{}` did not contain `{}`", err, $s))
60+
assert!(err.to_string().contains($s), "`{}` did not contain `{}`", err, $s)
6261
}
6362
}
6463
};

library/std/src/process.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,6 @@ impl ExitStatusError {
16001600
/// ```
16011601
/// #![feature(exit_status_error)]
16021602
/// # if cfg!(unix) {
1603-
/// use std::convert::TryFrom;
16041603
/// use std::num::NonZeroI32;
16051604
/// use std::process::Command;
16061605
///

library/std/src/thread/tests.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::Builder;
22
use crate::any::Any;
33
use crate::mem;
4+
use crate::panic::panic_any;
45
use crate::result;
56
use crate::sync::{
67
mpsc::{channel, Sender},
@@ -183,7 +184,7 @@ fn test_simple_newsched_spawn() {
183184
}
184185

185186
#[test]
186-
fn test_try_panic_message_static_str() {
187+
fn test_try_panic_message_string_literal() {
187188
match thread::spawn(move || {
188189
panic!("static string");
189190
})
@@ -199,9 +200,9 @@ fn test_try_panic_message_static_str() {
199200
}
200201

201202
#[test]
202-
fn test_try_panic_message_owned_str() {
203+
fn test_try_panic_any_message_owned_str() {
203204
match thread::spawn(move || {
204-
panic!("owned string".to_string());
205+
panic_any("owned string".to_string());
205206
})
206207
.join()
207208
{
@@ -215,9 +216,9 @@ fn test_try_panic_message_owned_str() {
215216
}
216217

217218
#[test]
218-
fn test_try_panic_message_any() {
219+
fn test_try_panic_any_message_any() {
219220
match thread::spawn(move || {
220-
panic!(box 413u16 as Box<dyn Any + Send>);
221+
panic_any(box 413u16 as Box<dyn Any + Send>);
221222
})
222223
.join()
223224
{
@@ -233,10 +234,10 @@ fn test_try_panic_message_any() {
233234
}
234235

235236
#[test]
236-
fn test_try_panic_message_unit_struct() {
237+
fn test_try_panic_any_message_unit_struct() {
237238
struct Juju;
238239

239-
match thread::spawn(move || panic!(Juju)).join() {
240+
match thread::spawn(move || panic_any(Juju)).join() {
240241
Err(ref e) if e.is::<Juju>() => {}
241242
Err(_) | Ok(()) => panic!(),
242243
}

src/tools/tidy/src/edition.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ pub fn check(path: &Path, bad: &mut bool) {
2323
return;
2424
}
2525

26-
// Library crates are not yet ready to migrate to 2021.
27-
if path.components().any(|c| c.as_os_str() == "library") {
26+
// Not all library crates are ready to migrate to 2021.
27+
if file.components().any(|c| c.as_os_str() == "library")
28+
&& file.components().all(|c| c.as_os_str() != "std")
29+
{
2830
let has = contents.lines().any(is_edition_2018);
2931
if !has {
3032
tidy_error!(

0 commit comments

Comments
 (0)