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 #120466

Merged
merged 30 commits into from
Jan 29, 2024
Merged

Rollup of 9 pull requests #120466

merged 30 commits into from
Jan 29, 2024

Conversation

Dylan-DPC
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

joshlf and others added 30 commits October 12, 2023 15:35
General improvements, and also aims to better encourage the reader
to actually check out Arc::try_unwrap.
It has 1-to-1 correspondence to its expression id.

Also remove mostly useless `visit_let_expr`.
Add type annotations to MIR so that borrowck can pass constraints from
inline constants in patterns to the containing function.
Improve handling of expressions in patterns

Closes rust-lang#112593.

Methodcalls' dots in patterns are silently recovered as commas (e.g. `Foo("".len())` -> `Foo("", len())`) so extra diagnostics are emitted:
```rs
struct Foo(u8, String, u8);

fn bar(foo: Foo) -> bool {
    match foo {
        Foo(4, "yippee".yeet(), 7) => true,
        _ => false
    }
}
```
```
error: expected one of `)`, `,`, `...`, `..=`, `..`, or `|`, found `.`
 --> main.rs:5:24
  |
5 |         Foo(4, "yippee".yeet(), 7) => true,
  |                        ^
  |                        |
  |                        expected one of `)`, `,`, `...`, `..=`, `..`, or `|`
  |                        help: missing `,`

error[E0531]: cannot find tuple struct or tuple variant `yeet` in this scope
 --> main.rs:5:25
  |
5 |         Foo(4, "yippee".yeet(), 7) => true,
  |                         ^^^^ not found in this scope

error[E0023]: this pattern has 4 fields, but the corresponding tuple struct has 3 fields
 --> main.rs:5:13
  |
1 | struct Foo(u8, String, u8);
  |            --  ------  -- tuple struct has 3 fields
...
5 |         Foo(4, "yippee".yeet(), 7) => true,
  |             ^  ^^^^^^^^ ^^^^^^  ^ expected 3 fields, found 4

error: aborting due to 3 previous errors
```

This PR checks for patterns that ends with a dot and a lowercase ident (as structs/variants should be uppercase):
```
error: expected a pattern, found a method call
 --> main.rs:5:16
  |
5 |         Foo(4, "yippee".yeet(), 7) => true,
  |                ^^^^^^^^^^^^^^^ method calls are not allowed in patterns

error: aborting due to 1 previous error
```

Also check for expressions:
```rs
fn is_idempotent(x: f32) -> bool {
    match x {
        x * x => true,
        _ => false,
    }
}

fn main() {
    let mut t: [i32; 5];
    let t[0] = 1;
}
```
```
error: expected a pattern, found an expression
 --> main.rs:3:9
  |
3 |         x * x => true,
  |         ^^^^^ arbitrary expressions are not allowed in patterns

error: expected a pattern, found an expression
  --> main.rs:10:9
   |
10 |     let t[0] = 1;
   |         ^^^^ arbitrary expressions are not allowed in patterns
```

Would be cool if the compiler could suggest adding a guard for `match`es, but I've no idea how to do it.

---
`@rustbot` label +A-diagnostics +A-parser +A-patterns +C-enhancement
…ark-Simulacrum

Improve documentation for [A]Rc::into_inner

General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap.

This addresses concerns from rust-lang#106894 (comment).

Rendered:

![Screenshot_20240123_114436](https://github.com/rust-lang/rust/assets/3986214/68896d62-13e0-4f3a-8073-91d8e77c5554)
![Screenshot_20240123_114455](https://github.com/rust-lang/rust/assets/3986214/dc58e4bd-dd7f-40b1-bc50-fd6200dde593)
…120040, r=ChrisDenton

Adjust Behaviour of `read_dir` and `ReadDir` in Windows Implementation: Check Whether Path to Search In Exists

This pull request changes the `read_dir` function's and the `ReadDir` structure's internal implementations for the Windows operating system to make its behaviour more accurate.

It should be noted that `ERROR_FILE_NOT_FOUND` is returned by the `FindFirstFileW` function when *no matching files can be found*, not necessarily that the path to search in does not exist in the first place. Therefore, directly returning the "The system cannot find the file specified." may not be accurate.

An extra check for whether the path to search in exists is added, returning a constructed `ReadDir` iterator with its handle being an `INVALID_HANDLE_VALUE` returned by the `FindFirstFileW` function if `ERROR_FILE_NOT_FOUND` is indeed the last OS error. The `ReadDir` implementation for the Windows operating system is correspondingly updated to always return `None` if the handle it has is an `INVALID_HANDLE_VALUE` which can only be the case if and only if specifically constructed by the `read_dir` function in the aforementioned conditions.

It should also be noted that `FindFirstFileW` would have returned `ERROR_PATH_NOT_FOUND` if the path to search in does not exist in the first place.

Presumably fixes rust-lang#120040.
…mir, r=davidtwco

Borrow check inline const patterns

Add type annotations to MIR so that borrowck can pass constraints from inline constants in patterns to the containing function.
Also enables some inline constant pattern tests that were fixed by the THIR unsafeck stabilization.

cc rust-lang#76001
…tive, r=Nilstrieb

Stop using derivative in rustc_pattern_analysis

CC rust-lang#109302, rust-lang/rust-analyzer#16420 (comment)

r? ````@Nadrieril````
…errors

hir: Two preparatory changes for rust-lang#120206

cc rust-lang#120206
r? ```@compiler-errors```
…s, r=oli-obk

Fix incorrect comment in normalize_newlines

The incorrect comment seems to be left over from sometime before this function was first merged.
@rustbot rustbot added O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Jan 29, 2024
@Dylan-DPC
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Jan 29, 2024

📌 Commit c70c4cc has been approved by Dylan-DPC

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 29, 2024
@bors
Copy link
Contributor

bors commented Jan 29, 2024

⌛ Testing commit c70c4cc with merge 9ee33fb...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 29, 2024
Rollup of 9 pull requests

Successful merges:

 - rust-lang#116677 (References refer to allocated objects)
 - rust-lang#118625 (Improve handling of expressions in patterns)
 - rust-lang#120266 (Improve documentation for [A]Rc::into_inner)
 - rust-lang#120373 (Adjust Behaviour of `read_dir` and `ReadDir` in Windows Implementation: Check Whether Path to Search In Exists)
 - rust-lang#120390 (Borrow check inline const patterns)
 - rust-lang#120420 (Stop using derivative in rustc_pattern_analysis)
 - rust-lang#120428 (hir: Two preparatory changes for rust-lang#120206)
 - rust-lang#120453 (Fix incorrect comment in normalize_newlines)
 - rust-lang#120462 (Clean dead code)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Jan 29, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 29, 2024
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@GuillaumeGomez
Copy link
Member

Flaky.

@bors retry

@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 29, 2024
@bors
Copy link
Contributor

bors commented Jan 29, 2024

⌛ Testing commit c70c4cc with merge 5518eaa...

@bors
Copy link
Contributor

bors commented Jan 29, 2024

☀️ Test successful - checks-actions
Approved by: Dylan-DPC
Pushing 5518eaa to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 29, 2024
@bors bors merged commit 5518eaa into rust-lang:master Jan 29, 2024
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 29, 2024
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#116677 References refer to allocated objects 813a3813ca562c1f94b523fe56df41988b50cf0b (link)
#118625 Improve handling of expressions in patterns 2a79c40d2af629850974afa8f1eace207411e8b7 (link)
#120266 Improve documentation for [A]Rc::into_inner ab1dd7055efa9409e016ba3c733eebbe430afb4b (link)
#120373 Adjust Behaviour of read_dir and ReadDir in Windows Imp… 731f73e918335b69cd3688cd65e98f835054dfcc (link)
#120390 Borrow check inline const patterns a33abcb9186f3982b74ee99079dd0f20e6f79e26 (link)
#120420 Stop using derivative in rustc_pattern_analysis bc00a841dfc3387d877d137e627d68ba2d2491a7 (link)
#120428 hir: Two preparatory changes for #120206 b01cda7a9a54acbdb9e4829143b514493ad06ed8 (link)
#120453 Fix incorrect comment in normalize_newlines 15008e13500ec1c7f1ba0cf1668af45841d3e997 (link)
#120462 Clean dead code f7b91a99dc17ec418c7264406738c8275d6261d0 (link)

previous master: af08c64e38

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5518eaa): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.6% [1.3%, 5.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.8% [-5.8%, -5.8%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 662.364s -> 661.382s (-0.15%)
Artifact size: 308.02 MiB -> 308.09 MiB (0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.