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

Stabilize "RangeFrom" patterns in 1.55 #83918

Merged
merged 6 commits into from
Jul 11, 2021

Conversation

workingjubilee
Copy link
Member

@workingjubilee workingjubilee commented Apr 6, 2021

Implements a partial stabilization of #67264 and #37854.
Reference PR: rust-lang/reference#900

Stabilization Report

This stabilizes the X.. pattern, shown as such, offering an exhaustive match for unsigned integers:

match x as u32 {
      0 => println!("zero!"),
      1.. => println!("positive number!"),
}

Currently if a Rust author wants to write such a match on an integer, they must use 1..={integer}::MAX . By allowing a "RangeFrom" style pattern, this simplifies the match to not require the MAX path and thus not require specifically repeating the type inside the match, allowing for easier refactoring. This is particularly useful for instances like the above case, where different behavior on "0" vs. "1 or any positive number" is desired, and the actual MAX is unimportant.

Notably, this excepts slice patterns which include half-open ranges from stabilization, as the wisdom of those is still subject to some debate.

Practical Applications

Instances of this specific usage have appeared in the compiler:

Some(1..) => ty.uninhabited_from(tcx, param_env),

Some(1..) => tcx.conservative_is_privately_uninhabited(param_env.and(ty)),

And I have noticed there are also a handful of "in the wild" users who have deployed it to similar effect, especially in the case of rejecting any value of a certain number or greater. It simply makes it much more ergonomic to write an irrefutable match, as done in Katholieke Universiteit Leuven's SCALE and MAMBA project.

Tests

There were already many tests in src/test/ui/half-open-range/patterns, as well as generic pattern tests that test the exclusive_range_pattern feature, many dating back to the feature's introduction and remaining standing to this day. However, this stabilization comes with some additional tests to explore the... sometimes interesting behavior of interactions with other patterns. e.g. There is, at least, a mild diagnostic improvement in some edge cases, because before now, the pattern 0..=(5+1) encounters the half_open_range_patterns feature gate and can thus emit the request to enable the feature flag, while also emitting the "inclusive range with no end" diagnostic. There is no intent to allow an X..= pattern that I am aware of, so removing the flag request is a strict improvement. The arrival of the J | K "or" pattern also enables some odd formations.

Some of the behavior tested for here is derived from experiments in this Playground example, linked at #67264 (comment), which may be useful to reference to observe the current behavior more closely.

In addition tests constituting an explanation of the "slicing range patterns" syntax issue are included in this PR.

Desiderata

The exclusive range patterns and half-open range patterns are fairly strongly requested by many authors, as they make some patterns much more natural to write, but there is disagreement regarding the "closed" exclusive range pattern or the "RangeTo" pattern, especially where it creates "off by one" gaps in the presence of a "catch-all" wildcard case. Also, there are obviously no range analyses in place that will force diagnostics for e.g. highly overlapping matches. I believe these should be warned on, ideally, and I think it would be reasonable to consider such a blocker to stabilizing this feature, but there is no technical issue with the feature as-is from the purely syntactic perspective as such overlapping or missed matches can already be generated today with such a catch-all case. And part of the "point" of the feature, at least from my view, is to make it easier to omit wildcard matches: a pattern with such an "open" match produces an irrefutable match and does not need the wild card case, making it easier to benefit from exhaustiveness checking.

History

I checked but I couldn't actually find an RFC for this, and given "approved provisionally by lang team without an RFC", I believe this might require an RFC before it can land? Unsure of procedure here, on account of this being stabilizing a subset of a feature of syntax.

r? @scottmcm

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

This comment has been minimized.

@jonas-schievink jonas-schievink added relnotes Marks issues that should be documented in the release notes of the next release. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Apr 6, 2021
@rust-log-analyzer

This comment has been minimized.

@workingjubilee workingjubilee added the needs-fcp This change is insta-stable, so needs a completed FCP to proceed. label Apr 6, 2021
@scottmcm
Copy link
Member

scottmcm commented May 4, 2021

Lang previously expressed interest in stabilizing this, so let's do it!

I think this is a particularly nice win when coupled with the exhaustive integer matching from 1.33, as a great way to write "and everything X and above" without using a wildcard.

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented May 4, 2021

Team member @scottmcm has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels May 4, 2021
@nikomatsakis
Copy link
Contributor

@rfcbot reviewed

@rfcbot
Copy link

rfcbot commented May 4, 2021

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels May 4, 2021
@bstrie
Copy link
Contributor

bstrie commented May 10, 2021

This has a little bit of a surprising contrast with slice patterns. Consider this (working) code:

let x = [-100, -50, 50, 100];

assert_eq!(&x[..], &[-100, -50, 50, 100]);
assert_eq!(&x[..2], &[-100, -50]);
assert_eq!(&x[2..], &[50, 100]);
assert_eq!(&x[1..3], &[-50, 50]);

let [y @ ..] = x;
assert_eq!(x, y);

A user might then expect the following to work:

let [neg @ ..2, pos @ 2..] = x; // error
assert_eq!(neg, [-100, -50]);
assert_eq!(pos, [50, 100]);

let [_, fifties @ 1..3, _] = x; // error
assert_eq!(fifties, [-50, 50])

However with the feature as implemented, the pattern [..x, x..] doesn't mean "match an array of arbitrary length and split it array into two at index x", it means "match an array of exactly two elements, where the first element's value is less than x and the second's is greater or equal to x". It's a bit of an unfortunate situation where [..] and [0..] will mean surprisingly different things in pattern context.

The most future-proofed solution here would be to produce a compilation error when encountering a .. at the top level of a slice pattern (excepting RangeFull). This is backwards-compatible with existing [..] slice patterns, and would most likely never be encountered by people trying to use range patterns. And since match 42 { .. => () } is already invalid (can't use .. outside of tuple, tuple struct, and slice patterns), this would leave us in a state where RangeFull patterns, despite meaning something different from the other Range patterns, would be distinct and disjoint in semantics with no ambiguity. And of course it would be backwards-compatible if anybody wanted to lift this restriction in the future, either to allow slicing with RangeFrom et al or to revive the behavior as it is currently implemented (basically, deciding whether you'd rather have 0.. be surprisingly different from [0..], or have [0..] be surprisingly different from [..]).

@workingjubilee
Copy link
Member Author

I'm sorry, I don't know if I truly understand what you actually mean here. ".. excepting RangeFull" seems like a contradiction. I currently assume you mean the slicing patterns that match the RangeFrom, RangeTo, and RangeExclusive patterns, but I am not sure, because when I first read it yesterday, I assumed you meant literally barring the .. token except for the specific character sequence of [..] only. Which would clearly be unacceptable, because I regularly use patterns akin to this:

let xs = [13, 1, 5, 2, 3, 1, 21, 8];
let [a, b, c @ ..] = xs;
println!(r"first element: {a}
second element: {b}
rest: {c:?}", a = a, b = b, c = c);

Specifically I like this for repeatedly dismantling parts of a slice for e.g. argument parsing. Which is valid with or without the @ binding and capturing .. and its associated values here. Now, at this point I am more confident that I am repeating you, as I believe you're looking at the case of a slice pattern combining with a RangeFrom and RangeTo pattern, and how it would be desirable to instead have

let [first_two @ ..2, rest @ 2..] = xs;

work on multi-element arrays, whereas instead it errors with

error[E0527]: pattern requires 2 elements but array has 8
 --> src/main.rs:6:5
  |
6 | let [first_two @ ..2, rest @ 2..] = xs;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 8 elements

error: aborting due to previous error

However, this currently already works,

// The pattern becomes refutable because this is now matching on an integer inside the slice pattern.
if let [a, b, c @ 5..=9, ..] = xs {
    println!("captured {}, {}, and {}!", a, b, c); // prints: captured 13, 1, and 5!
} else {
    println!("whoops");
}

So, my response is: I believe the ship may have actually sailed already for RangeExclusive patterns, because they should match RangeInclusive patterns in basically all ways excepting the range inclusiveness. I believe allowing "slicing RangeTo" and "slicing RangeFrom" patterns is plausible, but is conditioned on our accepting the deviance of RangeFrom and RangeTo vs. RangeInclusive/RangeExclusive, or doing an appropriate "edition dance". I indeed could see barring RangeExclusive, RangeFrom, and RangeTo within slice patterns for the moment and advancing an RFC which addresses this fully.

I believe the RangeFrom patterns are noncontroversial outside slice patterns, because validating it in the simple non-slicing cases won't introduce more confusion. And there's already some notional overlap in slice patterns with legal SliceIndex expressions. I repeat myself, but again, this is valid:

println!("{:?}", &xs[2..=5]); // prints: [5, 2, 3, 1]

but "conflicts" with the slice pattern

let [ys @ 2..=5] = xs;
println!("{:?}", ys);

instead producing the error

error[E0527]: pattern requires 1 element but array has 8
 --> src/main.rs:6:5
  |
6 | let [ys @ 2..=5] = xs;
  |     ^^^^^^^^^^^^ expected 8 elements

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels May 14, 2021
@rfcbot
Copy link

rfcbot commented May 14, 2021

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

@rfcbot rfcbot added the to-announce Announce this issue on triage meeting label May 14, 2021
@workingjubilee
Copy link
Member Author

workingjubilee commented May 14, 2021

Assuming I understand @bstrie's remarks correctly, I will update this PR with the appropriate restrictions as suggested, unless there is a broad consensus otherwise, because I did not adequately address this in my stabilization report. This should not be merged until then. I am marking this as a draft for the moment until this is resolved (i.e. I reapply this feature gate for slices and itemize the slice syntax concerns in the appropriate issues). Hopefully I get around to this Sooner rather than Later.

TODO: Done.

@bstrie
Copy link
Contributor

bstrie commented Jun 4, 2021

I'm not qualified to comment on the implementation but the tests look good to me. 👍 Thanks!

@workingjubilee workingjubilee changed the title Stabilize "RangeFrom" patterns Stabilize "RangeFrom" patterns in 1.54 Jun 4, 2021
@workingjubilee
Copy link
Member Author

Excellent,
and followup comments have been added to the appropriate tracking issues.
I consider this satisfactory and it is ready to merge.

@nikomatsakis
Copy link
Contributor

I'm trying to remember where our discussion left off in the last lang team meeting and/or on Zulip. I am still feeling rather unconvinced that we should feature gate patterns like this. I feel like having range patterns not compose within slice patterns feels rather surprising to me, and I don't think using the same syntax for some other meaning seems very likely.

@workingjubilee
Copy link
Member Author

workingjubilee commented Jun 5, 2021

Mmm, I agree with bstrie that there is syntactic conflict with SliceIndex. All the code where I write destructuring slices, very often byteslices, would be neater and simpler if it could use a pattern like

let [octobyte 0..8, rest @ ..] = byteslice;
let num = u64::from_le_bytes(octobyte);

Instead, to do that, I have to use

let [a, b, c, d, e, f, g, h, rest @ ..] = byteslice;
let num = u64::from_le_bytes([a, b, c, d, e, f, g, h]);

And yes, I have written variants of the above several times. I don't consider the .try_into().unwrap() case less bad. It's agreed that range patterns are rare in slices... and I think they are rare because what a user would really expect, where a range pattern inside a slice pattern works like SliceIndex, doesn't work.

In any case, I did not adequately address the conflict between range patterns and slice patterns in my stabilization report, even though it was mentioned in the issue, because I didn't understand it. I reestablished the feature gate only because that seemed like the most minimal possible proofing to allow further attention to be paid to it, and assume even that will be obviated in short order by future actions. We could also make it fail to compile in this PR, or cancel incremental stabilization of range patterns and wait for a full RFC on the whole shindig. All of those seem like valid ways to address the concern... otherwise why wait for final comment periods if we don't address concerns in those comments?

I understand it's all a very weird and unsatisfying situation, mind, I just feel prematurely settling things would be even more unsatisfying.

@joshtriplett
Copy link
Member

@rfcbot concern consider-alternative-further

@workingjubilee, can you start a new thread in the lang Zulip stream to discuss this further, so that we can consider possibilities with you?

@rfcbot rfcbot added the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Jun 22, 2021
@joshtriplett
Copy link
Member

Based on discussion with @workingjubilee, it sounds like the net effect of this PR is to stabilize RangeFrom patterns except for the combination of range patterns within slice patterns. That allows for further evaluation of how to make those compatible in the most intuitive and least confusing way we can.

I think it's appropriate to go ahead with a partial stabilization here. Even if we want to stabilize range patterns within slice patterns as well, I think it's reasonable to do that in a separate PR that discusses the tradeoffs, rather than complicating this PR.

We're not making an irreversible decision to stabilize something that would commit us down one or the other path; rather, we're intentionally only stabilizing the subset that still allows us to make that decision separately in the future.

Given that:

@rfcbot resolved consider-alternative-further

@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Jun 23, 2021
@rfcbot
Copy link

rfcbot commented Jun 23, 2021

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Jun 23, 2021
@workingjubilee workingjubilee changed the title Stabilize "RangeFrom" patterns in 1.54 Stabilize "RangeFrom" patterns in 1.55 Jun 25, 2021
@inquisitivecrystal
Copy link
Contributor

I think that rfcbot may have gotten confused by the fact that this went through FCP again after the FCP had finished once. It looks to me like the FCP is now over and this is ready to merge, though I could be missing something.

@workingjubilee
Copy link
Member Author

You are correct.
@bors r=joshtriplett

@bors
Copy link
Contributor

bors commented Jul 11, 2021

📌 Commit 43bad44 has been approved by joshtriplett

@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 Jul 11, 2021
@bors
Copy link
Contributor

bors commented Jul 11, 2021

⌛ Testing commit 43bad44 with merge 0d76b73...

@bors
Copy link
Contributor

bors commented Jul 11, 2021

☀️ Test successful - checks-actions
Approved by: joshtriplett
Pushing 0d76b73 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 11, 2021
@bors bors merged commit 0d76b73 into rust-lang:master Jul 11, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 11, 2021
@workingjubilee workingjubilee deleted the stable-rangefrom-pat branch September 14, 2021 04:19
@workingjubilee workingjubilee added the A-patterns Relating to patterns and pattern matching label Sep 23, 2021
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Nov 20, 2021
Pkgsrc changes:
 * Bump bootstrap kit version to 1.55.0.
 * Adjust patches as needed, some no longer apply (so removed)
 * Update checksum adjustments.
 * Avoid rust-llvm on SunOS
 * Optionally build docs
 * Remove reference to closed/old PR#54621

Upstream changes:

Version 1.56.1 (2021-11-01)
===========================

- New lints to detect the presence of bidirectional-override Unicode
  codepoints in the compiled source code ([CVE-2021-42574])

[CVE-2021-42574]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-42574

Version 1.56.0 (2021-10-21)
========================

Language
--------

- [The 2021 Edition is now stable.][rust#88100]
  See [the edition guide][rust-2021-edition-guide] for more details.
- [The pattern in `binding @ pattern` can now also introduce new bindings.]
  [rust#85305]
- [Union field access is permitted in `const fn`.][rust#85769]

[rust-2021-edition-guide]:
  https://doc.rust-lang.org/nightly/edition-guide/rust-2021/index.html

Compiler
--------

- [Upgrade to LLVM 13.][rust#87570]
- [Support memory, address, and thread sanitizers on aarch64-unknown-freebsd.]
  [rust#88023]
- [Allow specifying a deployment target version for all iOS targets][rust#87699]
- [Warnings can be forced on with `--force-warn`.][rust#87472]
  This feature is primarily intended for usage by `cargo fix`, rather than
  end users.
- [Promote `aarch64-apple-ios-sim` to Tier 2\*.][rust#87760]
- [Add `powerpc-unknown-freebsd` at Tier 3\*.][rust#87370]
- [Add `riscv32imc-esp-espidf` at Tier 3\*.][rust#87666]

\* Refer to Rust's [platform support page][platform-support-doc] for more
information on Rust's tiered platform support.

Libraries
---------

- [Allow writing of incomplete UTF-8 sequences via stdout/stderr on Windows.]
  [rust#83342]
  The Windows console still requires valid Unicode, but this change allows
  splitting a UTF-8 character across multiple write calls. This allows, for
  instance, programs that just read and write data buffers (e.g. copying a file
  to stdout) without regard for Unicode or character boundaries.
- [Prefer `AtomicU{64,128}` over Mutex for Instant backsliding protection.]
  [rust#83093]
  For this use case, atomics scale much better under contention.
- [Implement `Extend<(A, B)>` for `(Extend<A>, Extend<B>)`][rust#85835]
- [impl Default, Copy, Clone for std::io::Sink and std::io::Empty][rust#86744]
- [`impl From<[(K, V); N]>` for all collections.][rust#84111]
- [Remove `P: Unpin` bound on impl Future for Pin.][rust#81363]
- [Treat invalid environment variable names as non-existent.][rust#86183]
  Previously, the environment functions would panic if given a
  variable name with an internal null character or equal sign (`=`).
  Now, these functions will just treat such names as non-existent
  variables, since the OS cannot represent the existence of a
  variable with such a name.

Stabilised APIs
---------------

- [`std::os::unix::fs::chroot`]
- [`UnsafeCell::raw_get`]
- [`BufWriter::into_parts`]
- [`core::panic::{UnwindSafe, RefUnwindSafe, AssertUnwindSafe}`]
  These APIs were previously stable in `std`, but are now also available
  in `core`.
- [`Vec::shrink_to`]
- [`String::shrink_to`]
- [`OsString::shrink_to`]
- [`PathBuf::shrink_to`]
- [`BinaryHeap::shrink_to`]
- [`VecDeque::shrink_to`]
- [`HashMap::shrink_to`]
- [`HashSet::shrink_to`]

These APIs are now usable in const contexts:

- [`std::mem::transmute`]
- [`[T]::first`][`slice::first`]
- [`[T]::split_first`][`slice::split_first`]
- [`[T]::last`][`slice::last`]
- [`[T]::split_last`][`slice::split_last`]

Cargo
-----

- [Cargo supports specifying a minimum supported Rust version in Cargo.toml.]
  [`rust-version`]
  This has no effect at present on dependency version selection.
  We encourage crates to specify their minimum supported Rust
  version, and we encourage CI systems that support Rust code to
  include a crate's specified minimum version in the text matrix
  for that crate by default.

Compatibility notes
-------------------

- [Update to new argument parsing rules on Windows.][rust#87580]
  This adjusts Rust's standard library to match the behavior of the standard
  libraries for C/C++. The rules have changed slightly over time, and this PR
  brings us to the latest set of rules (changed in 2008).
- [Disallow the aapcs calling convention on aarch64][rust#88399]
  This was already not supported by LLVM; this change surfaces this lack of
  support with a better error message.
- [Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default][rust#87385]
- [Warn when an escaped newline skips multiple lines.][rust#87671]
- [Calls to `libc::getpid` / `std::process::id` from `Command::pre_exec`
  may return different values on glibc <= 2.24.][rust#81825]
  Rust now invokes the `clone3` system call directly, when available,
  to use new functionality available via that system call. Older
  versions of glibc cache the result of `getpid`, and only update
  that cache when calling glibc's clone/fork functions, so a direct
  system call bypasses that cache update. glibc 2.25 and newer no
  longer cache `getpid` for exactly this reason.

Internal changes
----------------
These changes provide no direct user facing benefits, but represent
significant improvements to the internals and overall performance
of rustc and related tools.

- [LLVM is compiled with PGO in published x86_64-unknown-linux-gnu artifacts.]
  [rust#88069]
  This improves the performance of most Rust builds.
- [Unify representation of macros in internal data structures.][rust#88019]
  This change fixes a host of bugs with the handling of macros by the compiler,
  as well as rustdoc.

[`std::os::unix::fs::chroot`]: https://doc.rust-lang.org/stable/std/os/unix/fs/fn.chroot.html
[`Iterator::intersperse`]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html#method.intersperse
[`Iterator::intersperse_with`]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html#method.intersperse
[`UnsafeCell::raw_get`]: https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#method.raw_get
[`BufWriter::into_parts`]: https://doc.rust-lang.org/stable/std/io/struct.BufWriter.html#method.into_parts
[`core::panic::{UnwindSafe, RefUnwindSafe, AssertUnwindSafe}`]: rust-lang/rust#84662
[`Vec::shrink_to`]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.shrink_to
[`String::shrink_to`]: https://doc.rust-lang.org/stable/std/string/struct.String.html#method.shrink_to
[`OsString::shrink_to`]: https://doc.rust-lang.org/stable/std/ffi/struct.OsString.html#method.shrink_to
[`PathBuf::shrink_to`]: https://doc.rust-lang.org/stable/std/path/struct.PathBuf.html#method.shrink_to
[`BinaryHeap::shrink_to`]: https://doc.rust-lang.org/stable/std/collections/struct.BinaryHeap.html#method.shrink_to
[`VecDeque::shrink_to`]: https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.shrink_to
[`HashMap::shrink_to`]: https://doc.rust-lang.org/stable/std/collections/hash_map/struct.HashMap.html#method.shrink_to
[`HashSet::shrink_to`]: https://doc.rust-lang.org/stable/std/collections/hash_set/struct.HashSet.html#method.shrink_to
[`std::mem::transmute`]: https://doc.rust-lang.org/stable/std/mem/fn.transmute.html
[`slice::first`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.first
[`slice::split_first`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_first
[`slice::last`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.last
[`slice::split_last`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_last
[`rust-version`]: https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-rust-version-field
[rust#87671]: rust-lang/rust#87671
[rust#86183]: rust-lang/rust#86183
[rust#87385]: rust-lang/rust#87385
[rust#88100]: rust-lang/rust#88100
[rust#86860]: rust-lang/rust#86860
[rust#84039]: rust-lang/rust#84039
[rust#86492]: rust-lang/rust#86492
[rust#88363]: rust-lang/rust#88363
[rust#85305]: rust-lang/rust#85305
[rust#87832]: rust-lang/rust#87832
[rust#88069]: rust-lang/rust#88069
[rust#87472]: rust-lang/rust#87472
[rust#87699]: rust-lang/rust#87699
[rust#87570]: rust-lang/rust#87570
[rust#88023]: rust-lang/rust#88023
[rust#87760]: rust-lang/rust#87760
[rust#87370]: rust-lang/rust#87370
[rust#87580]: rust-lang/rust#87580
[rust#83342]: rust-lang/rust#83342
[rust#83093]: rust-lang/rust#83093
[rust#88177]: rust-lang/rust#88177
[rust#88548]: rust-lang/rust#88548
[rust#88551]: rust-lang/rust#88551
[rust#88299]: rust-lang/rust#88299
[rust#88220]: rust-lang/rust#88220
[rust#85835]: rust-lang/rust#85835
[rust#86879]: rust-lang/rust#86879
[rust#86744]: rust-lang/rust#86744
[rust#84662]: rust-lang/rust#84662
[rust#86593]: rust-lang/rust#86593
[rust#81050]: rust-lang/rust#81050
[rust#81363]: rust-lang/rust#81363
[rust#84111]: rust-lang/rust#84111
[rust#85769]: rust-lang/rust#85769 (comment)
[rust#88490]: rust-lang/rust#88490
[rust#88269]: rust-lang/rust#88269
[rust#84176]: rust-lang/rust#84176
[rust#88399]: rust-lang/rust#88399
[rust#88227]: rust-lang/rust#88227
[rust#88200]: rust-lang/rust#88200
[rust#82776]: rust-lang/rust#82776
[rust#88077]: rust-lang/rust#88077
[rust#87728]: rust-lang/rust#87728
[rust#87050]: rust-lang/rust#87050
[rust#87619]: rust-lang/rust#87619
[rust#81825]: rust-lang/rust#81825 (comment)
[rust#88019]: rust-lang/rust#88019
[rust#87666]: rust-lang/rust#87666

Version 1.55.0 (2021-09-09)
============================

Language
--------
- [You can now write open "from" range patterns (`X..`), which will start
  at `X` and will end at the maximum value of the integer.][83918]
- [You can now explicitly import the prelude of different editions
  through `std::prelude` (e.g. `use std::prelude::rust_2021::*;`).][86294]

Compiler
--------
- [Added tier 3\* support for `powerpc64le-unknown-freebsd`.][83572]

\* Refer to Rust's [platform support page][platform-support-doc] for more
   information on Rust's tiered platform support.

Libraries
---------

- [Updated std's float parsing to use the Eisel-Lemire algorithm.][86761]
  These improvements should in general provide faster string parsing of floats,
  no longer reject certain valid floating point values, and reduce
  the produced code size for non-stripped artifacts.
- [`string::Drain` now implements `AsRef<str>` and `AsRef<[u8]>`.][86858]

Stabilised APIs
---------------

- [`Bound::cloned`]
- [`Drain::as_str`]
- [`IntoInnerError::into_error`]
- [`IntoInnerError::into_parts`]
- [`MaybeUninit::assume_init_mut`]
- [`MaybeUninit::assume_init_ref`]
- [`MaybeUninit::write`]
- [`array::map`]
- [`ops::ControlFlow`]
- [`x86::_bittest`]
- [`x86::_bittestandcomplement`]
- [`x86::_bittestandreset`]
- [`x86::_bittestandset`]
- [`x86_64::_bittest64`]
- [`x86_64::_bittestandcomplement64`]
- [`x86_64::_bittestandreset64`]
- [`x86_64::_bittestandset64`]

The following previously stable functions are now `const`.

- [`str::from_utf8_unchecked`]


Cargo
-----
- [Cargo will now deduplicate compiler diagnostics to the terminal when invoking
  rustc in parallel such as when using `cargo test`.][cargo/9675]
- [The package definition in `cargo metadata` now includes the `"default_run"`
  field from the manifest.][cargo/9550]
- [Added `cargo d` as an alias for `cargo doc`.][cargo/9680]
- [Added `{lib}` as formatting option for `cargo tree` to print the `"lib_name"`
  of packages.][cargo/9663]

Rustdoc
-------
- [Added "Go to item on exact match" search option.][85876]
- [The "Implementors" section on traits no longer shows redundant
  method definitions.][85970]
- [Trait implementations are toggled open by default.][86260] This should
  make the implementations more searchable by tools like `CTRL+F` in
  your browser.
- [Intra-doc links should now correctly resolve associated items (e.g. methods)
  through type aliases.][86334]
- [Traits which are marked with `#[doc(hidden)]` will no longer appear in the
  "Trait Implementations" section.][86513]


Compatibility Notes
-------------------
- [std functions that return an `io::Error` will no longer use the
  `ErrorKind::Other` variant.][85746] This is to better reflect that these
  kinds of errors could be categorised [into newer more specific `ErrorKind`
  variants][79965], and that they do not represent a user error.
- [Using environment variable names with `process::Command` on Windows now
  behaves as expected.][85270] Previously using envionment variables with
  `Command` would cause them to be ASCII-uppercased.
- [Rustdoc will now warn on using rustdoc lints that aren't prefixed
  with `rustdoc::`][86849]

[86849]: rust-lang/rust#86849
[86513]: rust-lang/rust#86513
[86334]: rust-lang/rust#86334
[86260]: rust-lang/rust#86260
[85970]: rust-lang/rust#85970
[85876]: rust-lang/rust#85876
[83572]: rust-lang/rust#83572
[86294]: rust-lang/rust#86294
[86858]: rust-lang/rust#86858
[86761]: rust-lang/rust#86761
[85769]: rust-lang/rust#85769
[85746]: rust-lang/rust#85746
[85305]: rust-lang/rust#85305
[85270]: rust-lang/rust#85270
[84111]: rust-lang/rust#84111
[83918]: rust-lang/rust#83918
[79965]: rust-lang/rust#79965
[87370]: rust-lang/rust#87370
[87298]: rust-lang/rust#87298
[cargo/9663]: rust-lang/cargo#9663
[cargo/9675]: rust-lang/cargo#9675
[cargo/9550]: rust-lang/cargo#9550
[cargo/9680]: rust-lang/cargo#9680
[cargo/9663]: rust-lang/cargo#9663
[`array::map`]: https://doc.rust-lang.org/stable/std/primitive.array.html#method.map
[`Bound::cloned`]: https://doc.rust-lang.org/stable/std/ops/enum.Bound.html#method.cloned
[`Drain::as_str`]: https://doc.rust-lang.org/stable/std/string/struct.Drain.html#method.as_str
[`IntoInnerError::into_error`]: https://doc.rust-lang.org/stable/std/io/struct.IntoInnerError.html#method.into_error
[`IntoInnerError::into_parts`]: https://doc.rust-lang.org/stable/std/io/struct.IntoInnerError.html#method.into_parts
[`MaybeUninit::assume_init_mut`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_mut
[`MaybeUninit::assume_init_ref`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_ref
[`MaybeUninit::write`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.write
[`Seek::rewind`]: https://doc.rust-lang.org/stable/std/io/trait.Seek.html#method.rewind
[`ops::ControlFlow`]: https://doc.rust-lang.org/stable/std/ops/enum.ControlFlow.html
[`str::from_utf8_unchecked`]: https://doc.rust-lang.org/stable/std/str/fn.from_utf8_unchecked.html
[`x86::_bittest`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittest.html
[`x86::_bittestandcomplement`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittestandcomplement.html
[`x86::_bittestandreset`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittestandreset.html
[`x86::_bittestandset`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittestandset.html
[`x86_64::_bittest64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittest64.html
[`x86_64::_bittestandcomplement64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittestandcomplement64.html
[`x86_64::_bittestandreset64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittestandreset64.html
[`x86_64::_bittestandset64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittestandset64.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-patterns Relating to patterns and pattern matching disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.