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

Rollup of 9 pull requests #120364

Closed
wants to merge 21 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

WaffleLapkin and others added 21 commits January 30, 2023 10:35
Renamed "group by" to "chunk by" a per rust-lang#80552.

Newly stable items:

* `core::slice::ChunkBy`
* `core::slice::ChunkByMut`
* `[T]::chunk`
* `[T]::chunk_by`

Closes rust-lang#80552.
On ELF, the text section is opened with ".text", on MachO with
".section __TEXT,__text".

Previously, on ELF this test was actually matching a GNU note
section, which is no longer emitted on Solaris starting with
LLVM 18.

Fixes rust-lang#120105.
…ines, r=dtolnay

Add `str::Lines::remainder`

Based on rust-lang#98453.

This PR adds `str::Lines::remainder` similarly to [other remainder function on str split iterators](rust-lang#77998).
…r=dtolnay

Stabilize `slice_group_by`

Renamed "group by" to "chunk by" a per rust-lang#80552.

Newly stable items:

* `core::slice::ChunkBy`
* `core::slice::ChunkByMut`
* `[T]::chunk`
* `[T]::chunk_by`

Closes rust-lang#80552.
… r=compiler-errors

Add the `min_exhaustive_patterns` feature gate

## Motivation

Pattern-matching on empty types is tricky around unsafe code. For that reason, current stable rust conservatively requires arms for empty types in all but the simplest case. It has long been the intention to allow omitting empty arms when it's safe to do so. The [`exhaustive_patterns`](rust-lang#51085) feature allows the omission of all empty arms, but hasn't been stabilized because that was deemed dangerous around unsafe code.

## Proposal

This feature aims to stabilize an uncontroversial subset of exhaustive_patterns. Namely: when `min_exhaustive_patterns` is enabled and the data we're matching on is guaranteed to be valid by rust's operational semantics, then we allow empty arms to be omitted. E.g.:

```rust
let x: Result<T, !> = foo();
match x { // ok
    Ok(y) => ...,
}
let Ok(y) = x; // ok
```

If the place is not guaranteed to hold valid data (namely ptr dereferences, ref dereferences (conservatively) and union field accesses), then we keep stable behavior i.e. we (usually) require arms for the empty cases.

```rust
unsafe {
    let ptr: *const Result<u32, !> = ...;
    match *ptr {
        Ok(x) => { ... }
        Err(_) => { ... } // still required
    }
}
let foo: Result<u32, &!> = ...;
match foo {
    Ok(x) => { ... }
    Err(&_) => { ... } // still required because of the dereference
}
unsafe {
    let ptr: *const ! = ...;
    match *ptr {} // already allowed on stable
}
```

Note that we conservatively consider that a valid reference can point to invalid data, hence we don't allow arms of type `&!` and similar cases to be omitted. This could eventually change depending on [opsem decisions](rust-lang/unsafe-code-guidelines#413). Whenever opsem is undecided on a case, we conservatively keep today's stable behavior.

I proposed this behavior in the [`never_patterns`](rust-lang#118155) feature gate but it makes sense on its own and could be stabilized more quickly. The two proposals nicely complement each other.

## Unresolved Questions

Part of the question is whether this requires an RFC. I'd argue this doesn't need one since there is no design question beyond the intent to omit unreachable patterns, but I'm aware the problem can be framed in ways that require design (I'm thinking of the [original never patterns proposal](https://smallcultfollowing.com/babysteps/blog/2018/08/13/never-patterns-exhaustive-matching-and-uninhabited-types-oh-my/), which would frame this behavior as "auto-nevering" happening).

EDIT: I initially proposed a future-compatibility lint as part of this feature, I don't anymore.
Initial implementation of `str::from_raw_parts[_mut]`

ACP (accepted): rust-lang/libs-team#167
Tracking issue: rust-lang#119206

Thanks to `@Kixiron` for previous work on this (rust-lang#107207)

`@rustbot` label +T-libs-api -T-libs
r? `@thomcc`

Closes rust-lang#107207.
…ytes, r=the8472

Specialize `Bytes` on `StdinLock<'_>`

I noticed recently, while profiling a little project, that I was spending a lot of time reading from stdin (even with locking). I was using the `.bytes()` iterator adaptor; I figured, since `StdinLock` is a `BufReader` internally, it would work just as fast. But this is not the case, as `Bytes` is only specialized for the raw `BufReader`, and not the `StdinLock`/`MutexGuard` wrapper. Performance improved significantly when I wrapped the lock in a new `BufReader`, but I was still a bit sore about the double buffer indirection.

This PR attempts to specialize it, by simply calling the already specialized implementation on `BufReader`.
Split assembly tests for ELF and MachO

On ELF, the text section is opened with ".text", on MachO with ".section __TEXT,__text".

Previously, on ELF this test was actually matching a GNU note section, which is no longer emitted on Solaris starting with LLVM 18.

Fixes rust-lang#120105.

r? ``@davidtwco``
…_for_builtin, r=petrochenkov

Builtin macros effectively have implicit #[collapse_debuginfo(yes)]

If collapse_debuginfo attribute for builtin macro is not specified explicitly, it will be effectively set to `#[collapse_debuginfo(yes)]`.
…c-closures, r=oli-obk

Don't manually resolve async closures in `rustc_resolve`

There's a comment here that talks about doing this "[so] closure [args] are detected as upvars rather than normal closure arg usages", but we do upvar analysis on the HIR now:

https://github.com/rust-lang/rust/blob/cd6d8f2a04528f827ad3d399581c0f3502b15a72/compiler/rustc_passes/src/upvars.rs#L21-L29

Removing this ad-hoc logic makes it so that `async |x: &str|` now introduces an implicit binder, like regular closures.

r? ``@oli-obk``
Fix broken markdown in csky-unknown-linux-gnuabiv2.md
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Jan 26, 2024
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=9

@bors
Copy link
Contributor

bors commented Jan 26, 2024

📌 Commit 451d588 has been approved by matthiaskrgr

It is now in the queue for this repository.

@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 Jan 26, 2024
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_03dc7ec9-1094-4882-accd-396186eee999
GITHUB_EVENT_NAME=pull_request
GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=rollup-py00u4d
GITHUB_JOB=pr
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_03dc7ec9-1094-4882-accd-396186eee999
GITHUB_REF=refs/pull/120364/merge
GITHUB_REF_NAME=120364/merge
GITHUB_REF_PROTECTED=false
---
    Checking rustc_traits v0.0.0 (/checkout/compiler/rustc_traits)
    Checking rustc_borrowck v0.0.0 (/checkout/compiler/rustc_borrowck)
    Checking rustc_privacy v0.0.0 (/checkout/compiler/rustc_privacy)
    Checking rustc_passes v0.0.0 (/checkout/compiler/rustc_passes)
error: the feature `slice_group_by` has been stable since 1.76.0-beta.1 and no longer requires an attribute to enable
   |
14 | #![feature(slice_group_by)]
   |            ^^^^^^^^^^^^^^
   |
   |
   = note: `-D stable-features` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(stable_features)]`

error[E0599]: no method named `group_by` found for slice `[&DeadItem]` in the current scope
    |
    |
920 |         for group in dead_codes[..].group_by(|a, b| a.level == b.level) {
    |                                     ^^^^^^^^ method not found in `[&DeadItem]`

error[E0277]: the trait bound `[&DeadItem]: std::marker::Sized` is not satisfied
    |
    |
920 |         for group in dead_codes[..].group_by(|a, b| a.level == b.level) {
    |             ^^^^^ the trait `std::marker::Sized` is not implemented for `[&DeadItem]`
    = note: all local variables must have a statically known size
    = help: unsized locals are gated as an unstable feature


error[E0277]: the trait bound `[&DeadItem]: std::marker::Sized` is not satisfied
    |
    |
920 |         for group in dead_codes[..].group_by(|a, b| a.level == b.level) {
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Sized` is not implemented for `[&DeadItem]`
note: required by a bound in `std::option::Option`
   --> /checkout/library/core/src/option.rs:570:17
    |
570 | pub enum Option<T> {
570 | pub enum Option<T> {
    |                 ^ required by this bound in `Option`

error[E0277]: the trait bound `[&DeadItem]: std::marker::Sized` is not satisfied
    |
    |
920 | /         for group in dead_codes[..].group_by(|a, b| a.level == b.level) {
921 | |             self.lint_at_single_level(&group, participle, Some(def_id), report_on);
922 | |         }
    | |_________^ the trait `std::marker::Sized` is not implemented for `[&DeadItem]`
note: required by a bound in `std::prelude::v1::None`
   --> /checkout/library/core/src/option.rs:570:17
    |
570 | pub enum Option<T> {

@matthiaskrgr matthiaskrgr deleted the rollup-py00u4d branch March 16, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.