-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 8 pull requests #94734
Rollup of 8 pull requests #94734
Commits on Jan 29, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 19645ac - Browse repository at this point
Copy the full SHA 19645acView commit details
Commits on Mar 3, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 24fe35a - Browse repository at this point
Copy the full SHA 24fe35aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6b46a52 - Browse repository at this point
Copy the full SHA 6b46a52View commit details -
Configuration menu - View commit details
-
Copy full SHA for 700ec66 - Browse repository at this point
Copy the full SHA 700ec66View commit details
Commits on Mar 4, 2022
-
Generalize
get_nullable_type
to allow types where null is all-ones.Generalize get_nullable_type to accept types that have an all-ones bit pattern as their sentry "null" value. This will allow [`OwnedFd`], [`BorrowedFd`], [`OwnedSocket`], and [`BorrowedSocket`] to be marked with `#[rustc_nonnull_optimization_guaranteed]`, which will allow `Option<OwnedFd>`, `Option<BorrowedFd>`, `Option<OwnedSocket>`, and `Option<BorrowedSocket>` to be used in FFI declarations, as described in the [I/O safety RFC]. For example, it will allow a function like `open` on Unix and `WSASocketW` on Windows to be declared using `Option<OwnedFd>` and `Option<OwnedSocket>` return types, respectively. The actual change to add `#[rustc_nonnull_optimization_guaranteed]` to the abovementioned types will be a separate PR, as it'll depend on having this patch in the stage0 compiler. Also, update the diagnostics to mention that "niche optimizations" are used in libstd as well as libcore, as `rustc_layout_scalar_valid_range_start` and `rustc_layout_scalar_valid_range_end` are already in use in libstd. [`OwnedFd`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/fd/owned.rs#L49 [`BorrowedFd`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/fd/owned.rs#L29 [`OwnedSocket`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/windows/io/socket.rs#L51 [`BorrowedSocket`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/windows/io/socket.rs#L29 [I/O safety RFC]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md#ownedfd-and-borrowedfdfd-1
Configuration menu - View commit details
-
Copy full SHA for 86b4658 - Browse repository at this point
Copy the full SHA 86b4658View commit details -
Use '_ for irrelevant lifetimes in Debug impl.
Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 9099353 - Browse repository at this point
Copy the full SHA 9099353View commit details
Commits on Mar 7, 2022
-
Configuration menu - View commit details
-
Copy full SHA for fbd4cfa - Browse repository at this point
Copy the full SHA fbd4cfaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 776be7e - Browse repository at this point
Copy the full SHA 776be7eView commit details -
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for a3d269e - Browse repository at this point
Copy the full SHA a3d269eView commit details
Commits on Mar 8, 2022
-
When encountering a match expr with no arms, suggest it
Given ```rust match Some(42) {} ``` suggest ```rust match Some(42) { None | Some(_) => todo!(), } ```
Configuration menu - View commit details
-
Copy full SHA for 02a3830 - Browse repository at this point
Copy the full SHA 02a3830View commit details -
When finding a match expr with a single arm that requires more, sugge…
…st it Given ```rust match Some(42) { Some(0) => {} } ``` suggest ```rust match Some(42) { Some(0) => {} None | Some(_) => todo!(), } ```
Configuration menu - View commit details
-
Copy full SHA for 2383858 - Browse repository at this point
Copy the full SHA 2383858View commit details -
When finding a match expr with multiple arms that requires more, sugg…
…est it Given ```rust match Some(42) { Some(0) => {} Some(1) => {} } ``` suggest ```rust match Some(42) { Some(0) => {} Some(1) => {} None | Some(_) => todo!(), } ```
Configuration menu - View commit details
-
Copy full SHA for 084ca79 - Browse repository at this point
Copy the full SHA 084ca79View commit details -
Point at uncovered variants in enum definition in
note
instead of a…… `span_label` This makes the order of the output always consistent: 1. Place of the `match` missing arms 2. The `enum` definition span 3. The structured suggestion to add a fallthrough arm
Configuration menu - View commit details
-
Copy full SHA for ab4feea - Browse repository at this point
Copy the full SHA ab4feeaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6f45f73 - Browse repository at this point
Copy the full SHA 6f45f73View commit details -
Configuration menu - View commit details
-
Copy full SHA for a3158c7 - Browse repository at this point
Copy the full SHA a3158c7View commit details -
Rollup merge of rust-lang#91993 - estebank:match-span-suggestion, r=o…
…li-obk Tweak output for non-exhaustive `match` expression * Provide structured suggestion when missing `match` arms * Move pointing at the missing variants *after* the main error <img width="1164" alt="" src="https://user-images.githubusercontent.com/1606434/146312085-b57ef4a3-6e96-4f32-aa2a-803637d9eeba.png">
Configuration menu - View commit details
-
Copy full SHA for e3ea69f - Browse repository at this point
Copy the full SHA e3ea69fView commit details -
Rollup merge of rust-lang#92385 - clarfonthey:const_option, r=fee1-dead
Add Result::{ok, err, and, or, unwrap_or} as const Already opened tracking issue rust-lang#92384. I don't think that this should actually cause any issues as long as the constness is unstable, but we may want to double-check that this doesn't get interpreted as a weird `Drop` bound even for non-const usages.
Configuration menu - View commit details
-
Copy full SHA for e22331c - Browse repository at this point
Copy the full SHA e22331cView commit details -
Rollup merge of rust-lang#94559 - m-ou-se:thread-scope-spawn-closure-…
…without-arg, r=Mark-Simulacrum Remove argument from closure in thread::Scope::spawn. This implements ```@danielhenrymantilla's``` [suggestion](rust-lang#93203 (comment)) for improving the scoped threads interface. Summary: The `Scope` type gets an extra lifetime argument, which represents basically its own lifetime that will be used in `&'scope Scope<'scope, 'env>`: ```diff - pub struct Scope<'env> { .. }; + pub struct Scope<'scope, 'env: 'scope> { .. } pub fn scope<'env, F, T>(f: F) -> T where - F: FnOnce(&Scope<'env>) -> T; + F: for<'scope> FnOnce(&'scope Scope<'scope, 'env>) -> T; ``` This simplifies the `spawn` function, which now no longer passes an argument to the closure you give it, and now uses the `'scope` lifetime for everything: ```diff - pub fn spawn<'scope, F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> + pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> where - F: FnOnce(&Scope<'env>) -> T + Send + 'env, + F: FnOnce() -> T + Send + 'scope, - T: Send + 'env; + T: Send + 'scope; ``` The only difference the user will notice, is that their closure now takes no arguments anymore, even when spawning threads from spawned threads: ```diff thread::scope(|s| { - s.spawn(|_| { + s.spawn(|| { ... }); - s.spawn(|s| { + s.spawn(|| { ... - s.spawn(|_| ...); + s.spawn(|| ...); }); }); ``` <details><summary>And, as a bonus, errors get <em>slightly</em> better because now any lifetime issues point to the outermost <code>s</code> (since there is only one <code>s</code>), rather than the innermost <code>s</code>, making it clear that the lifetime lasts for the entire <code>thread::scope</code>. </summary> ```diff error[E0373]: closure may outlive the current function, but it borrows `a`, which is owned by the current function --> src/main.rs:9:21 | - 7 | s.spawn(|s| { - | - has type `&Scope<'1>` + 6 | thread::scope(|s| { + | - lifetime `'1` appears in the type of `s` 9 | s.spawn(|| println!("{:?}", a)); // might run after `a` is dropped | ^^ - `a` is borrowed here | | | may outlive borrowed value `a` | note: function requires argument type to outlive `'1` --> src/main.rs:9:13 | 9 | s.spawn(|| println!("{:?}", a)); // might run after `a` is dropped | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `a` (and any other referenced variables), use the `move` keyword | 9 | s.spawn(move || println!("{:?}", a)); // might run after `a` is dropped | ++++ " ``` </details> The downside is that the signature of `scope` and `Scope` gets slightly more complex, but in most cases the user wouldn't need to write those, as they just use the argument provided by `thread::scope` without having to name its type. Another downside is that this does not work nicely in Rust 2015 and Rust 2018, since in those editions, `s` would be captured by reference and not by copy. In those editions, the user would need to use `move ||` to capture `s` by copy. (Which is what the compiler suggests in the error.)
Configuration menu - View commit details
-
Copy full SHA for aec535f - Browse repository at this point
Copy the full SHA aec535fView commit details -
Rollup merge of rust-lang#94580 - xFrednet:55112-only-reason-in-lint-…
…attr, r=lcnr Emit `unused_attributes` if a level attr only has a reason Fixes a comment from `compiler/rustc_lint/src/levels.rs`. Lint level attributes that only contain a reason will also trigger the `unused_attribute` lint. The lint now also checks for the `expect` lint level. That's it, have a great rest of the day for everyone reasoning this 🙃 cc: rust-lang#55112
Configuration menu - View commit details
-
Copy full SHA for 83ed227 - Browse repository at this point
Copy the full SHA 83ed227View commit details -
Rollup merge of rust-lang#94586 - sunfishcode:sunfishcode/io-lifetime…
…s-tests, r=davidtwco Generalize `get_nullable_type` to allow types where null is all-ones. Generalize get_nullable_type to accept types that have an all-ones bit pattern as their sentry "null" value. This will allow [`OwnedFd`], [`BorrowedFd`], [`OwnedSocket`], and [`BorrowedSocket`] to be marked with `#[rustc_nonnull_optimization_guaranteed]`, which will allow `Option<OwnedFd>`, `Option<BorrowedFd>`, `Option<OwnedSocket>`, and `Option<BorrowedSocket>` to be used in FFI declarations, as described in the [I/O safety RFC]. For example, it will allow a function like `open` on Unix and `WSASocketW` on Windows to be declared using `Option<OwnedFd>` and `Option<OwnedSocket>` return types, respectively. The actual change to add `#[rustc_nonnull_optimization_guaranteed]` to the abovementioned types will be a separate PR, as it'll depend on having this patch in the stage0 compiler. Also, update the diagnostics to mention that "niche optimizations" are used in libstd as well as libcore, as `rustc_layout_scalar_valid_range_start` and `rustc_layout_scalar_valid_range_end` are already in use in libstd. [`OwnedFd`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/fd/owned.rs#L49 [`BorrowedFd`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/fd/owned.rs#L29 [`OwnedSocket`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/windows/io/socket.rs#L51 [`BorrowedSocket`]: https://github.com/rust-lang/rust/blob/c9dc44be24c58ff13ce46416c4b97ab5c1bd8429/library/std/src/os/windows/io/socket.rs#L29 [I/O safety RFC]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md#ownedfd-and-borrowedfdfd-1
Configuration menu - View commit details
-
Copy full SHA for e4a3627 - Browse repository at this point
Copy the full SHA e4a3627View commit details -
Rollup merge of rust-lang#94708 - notriddle:notriddle/cargo-toml-warn…
…ing, r=lcnr diagnostics: only talk about `Cargo.toml` if running under Cargo Fixes rust-lang#94646
Configuration menu - View commit details
-
Copy full SHA for 98d027c - Browse repository at this point
Copy the full SHA 98d027cView commit details -
Rollup merge of rust-lang#94712 - kckeiks:remove-rwlock-read-error-as…
…sumption, r=Mark-Simulacrum promot debug_assert to assert Fixes rust-lang#94705
Configuration menu - View commit details
-
Copy full SHA for a077e44 - Browse repository at this point
Copy the full SHA a077e44View commit details -
Rollup merge of rust-lang#94726 - lnicola:rust-analyzer-2022-03-08, r…
…=lnicola ⬆️ rust-analyzer r? `@ghost`
Configuration menu - View commit details
-
Copy full SHA for b879216 - Browse repository at this point
Copy the full SHA b879216View commit details