-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Oh, seeing as theres a whole lint against it, maybe this needs more ceremony then some random person coming along and bumping to 2021. rust/src/tools/tidy/src/edition.rs Lines 26 to 35 in f410bc7
|
Oh hmm, those are unit tests, not doctests - I'm not sure how to make them use a different edition :/ maybe they need to be UI tests instead so they're in a separate crate? |
ah, replacing them with ui tests makes sense! |
Hmm, this looks related to macro spans? Not sure what the bugs @Mark-Simulacrum referred to were.
|
There's no need for that. You can still panic with arbitrary payloads in Rust 2021. You just need to use panic_any instead of the panic (or assert) macro. |
library/std/src/fs/tests.rs
Outdated
Err(ref err) => assert!( | ||
err.raw_os_error() == Some($s), | ||
"{}", | ||
format!("`{}` did not have a code of `{}`", err, $s) | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use format!() to format the argument to a format string. So instead of adding "{}", just remove the format!()
macro:
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), |
library/std/src/fs/tests.rs
Outdated
Err(ref err) => { | ||
assert!(err.to_string().contains($s), format!("`{}` did not contain `{}`", err, $s)) | ||
assert!( | ||
err.to_string().contains($s), | ||
"{}", | ||
format!("`{}` did not contain `{}`", err, $s) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
library/std/src/thread/tests.rs
Outdated
match thread::spawn(move || { | ||
panic!("owned string".to_string()); | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to remove these tests. Just replace panic!() by panic_any().
That lint was originally checking that everything is using Rust 2018 rather than 2015. For most of the crates it's been changed to check for 2021 instead. So it's not meant as a lint against upgrading, more a lint against not using 2015. We can change it to accept either 2018 or 2021 for now, or to require 2021 for std specifically as well. |
This comment has been minimized.
This comment has been minimized.
Thanks for the feedback! |
src/tools/tidy/src/edition.rs
Outdated
@@ -24,7 +24,10 @@ pub fn check(path: &Path, bad: &mut bool) { | |||
} | |||
|
|||
// Library crates are not yet ready to migrate to 2021. | |||
if path.components().any(|c| c.as_os_str() == "library") { | |||
// TOOD: Once all library crates are migrated to 2021 then simplify the check to always check for 2021 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in TODO.
(Maybe just say 'Not all library crate are ..' in the existing comment? We're force to update this anyway when another library crate moves to 2021, so it's not like we can forget anything here.)
@bors r+ |
📌 Commit b656384 has been approved by |
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?
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?
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#91439 (Mark defaulted `PartialEq`/`PartialOrd` methods as const) - rust-lang#91516 (Improve suggestion to change struct field to &mut) - rust-lang#91896 (Remove `in_band_lifetimes` for `rustc_passes`) - rust-lang#91909 (:arrow_up: rust-analyzer) - rust-lang#91922 (Remove `in_band_lifetimes` from `rustc_mir_dataflow`) - rust-lang#92025 (Revert "socket ancillary data implementation for dragonflybsd.") - rust-lang#92030 (Update stdlib to the 2021 edition) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
progress towards #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?