-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 4 pull requests #94717
Rollup of 4 pull requests #94717
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
Commits on Mar 4, 2022
-
Use '_ for irrelevant lifetimes in Debug impl.
Co-authored-by: Daniel Henry-Mantilla <[email protected]>
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 776be7e - Browse repository at this point
Copy the full SHA 776be7eView commit details -
Co-authored-by: Mark Rousskov <[email protected]>
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
-
Configuration menu - View commit details
-
Copy full SHA for 5756239 - Browse repository at this point
Copy the full SHA 5756239View 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 b5ac2cb - Browse repository at this point
Copy the full SHA b5ac2cbView 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 8ea834a - Browse repository at this point
Copy the full SHA 8ea834aView 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 3e0f5c3 - Browse repository at this point
Copy the full SHA 3e0f5c3View commit details -
Rollup merge of rust-lang#94716 - RalfJung:miri, r=RalfJung
update Miri Fixes rust-lang#94687 r? `@rust-lang/miri`
Configuration menu - View commit details
-
Copy full SHA for de31dcf - Browse repository at this point
Copy the full SHA de31dcfView commit details