-
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
Rollup of 9 pull requests #120466
Rollup of 9 pull requests #120466
Conversation
Co-authored-by: Ralf Jung <post@ralfj.de>
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.
References refer to allocated objects Partially addresses rust-lang/unsafe-code-guidelines#465
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.
Clean dead code Detected by rust-lang#118257
@bors r+ rollup=never p=5 |
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
💔 Test failed - checks-actions |
Flaky. @bors retry |
☀️ Test successful - checks-actions |
📌 Perf builds for each rolled up PR:
previous master: af08c64e38 In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
Finished benchmarking commit (5518eaa): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 662.364s -> 661.382s (-0.15%) |
Successful merges:
read_dir
andReadDir
in Windows Implementation: Check Whether Path to Search In Exists #120373 (Adjust Behaviour ofread_dir
andReadDir
in Windows Implementation: Check Whether Path to Search In Exists)HirId
s have corresponding HIRNode
s #120206)r? @ghost
@rustbot modify labels: rollup
Create a similar rollup