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

Update stdlib to the 2021 edition #92030

merged 1 commit into from
Dec 18, 2021

Conversation

rukai
Copy link
Contributor

@rukai rukai commented Dec 17, 2021

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?

@rust-highfive
Copy link
Collaborator

r? @kennytm

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 17, 2021
@rust-log-analyzer

This comment has been minimized.

@rukai
Copy link
Contributor Author

rukai commented Dec 17, 2021

Oh, seeing as theres a whole lint against it, maybe this needs more ceremony then some random person coming along and bumping to 2021.

// Library crates are not yet ready to migrate to 2021.
if path.components().any(|c| c.as_os_str() == "library") {
let has = contents.lines().any(is_edition_2018);
if !has {
tidy_error!(
bad,
"{} doesn't have `edition = \"2018\"` on a separate line",
file.display()
);
}

@jyn514
Copy link
Member

jyn514 commented Dec 17, 2021

@m-ou-se do you happen to know why there's a lint against upgrading libstd to 2021?

@rukai please don't just delete the tests completely - you should be able to tell rustdoc to run them with an old edition using the edition2018 language string.

@jyn514
Copy link
Member

jyn514 commented Dec 17, 2021

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?

@rukai
Copy link
Contributor Author

rukai commented Dec 17, 2021

ah, replacing them with ui tests makes sense!
I'll do that.

@jyn514
Copy link
Member

jyn514 commented Dec 17, 2021

Hmm, this looks related to macro spans? Not sure what the bugs @Mark-Simulacrum referred to were.

#89103:

It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there.

@m-ou-se
Copy link
Member

m-ou-se commented Dec 17, 2021

ah, replacing them with ui tests makes sense! I'll do that.

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.

Comment on lines 41 to 45
Err(ref err) => assert!(
err.raw_os_error() == Some($s),
"{}",
format!("`{}` did not have a code of `{}`", err, $s)
),
Copy link
Member

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:

Suggested change
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),

Comment on lines 61 to 66
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)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment on lines 203 to 205
match thread::spawn(move || {
panic!("owned string".to_string());
})
Copy link
Member

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().

@m-ou-se
Copy link
Member

m-ou-se commented Dec 17, 2021

@m-ou-se do you happen to know why there's a lint against upgrading libstd to 2021?

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.

@rust-log-analyzer

This comment has been minimized.

@rukai
Copy link
Contributor Author

rukai commented Dec 17, 2021

Thanks for the feedback!
Should be all addressed now.
I opted to special case std in the lint so that we remember to remove the lint when everything is moved to 2021.

@m-ou-se m-ou-se assigned m-ou-se and unassigned kennytm Dec 17, 2021
@m-ou-se m-ou-se added A-edition-2021 Area: The 2021 edition C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 17, 2021
@@ -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
Copy link
Member

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.)

@m-ou-se
Copy link
Member

m-ou-se commented Dec 17, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Dec 17, 2021

📌 Commit b656384 has been approved by m-ou-se

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 17, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 18, 2021
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?
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 18, 2021
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?
This was referenced Dec 18, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 18, 2021
…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
@bors bors merged commit efbefb6 into rust-lang:master Dec 18, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2021 Area: The 2021 edition C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants