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 6 pull requests #91790

Closed
wants to merge 30 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

sunfishcode and others added 30 commits September 9, 2021 14:16
As suggested in rust-lang#88564. This adds a `try_clone()` to `OwnedFd` by
refactoring the code out of the existing `File`/`Socket` code.
This commit also updates `stdarch` git submodule.
…` point

```
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
  --> $DIR/issue-72312.rs:10:24
   |
LL |     pub async fn start(&self) {
   |                        ^^^^^ this data with an anonymous lifetime `'_`...
...
LL |         require_static(async move {
   |         -------------- ...is required to live as long as `'static` here...
LL |             &self;
   |             ----- ...and is captured here
   |
note: `'static` lifetime requirement introduced by this trait bound
  --> $DIR/issue-72312.rs:2:22
   |
LL | fn require_static<T: 'static>(val: T) -> T {
   |                      ^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0759`.
```

Fix rust-lang#72312.
* take diagnostic logic out of happy-path
* sort/dedup once
* add more comments
More accurate filtering still needed.
In Rust, nesting method calls with both require `&mut` access to `self`
produces a borrow-check error:

    error[E0499]: cannot borrow `*self` as mutable more than once at a time
     --> src/lib.rs:7:14
      |
    7 |     self.foo(self.bar());
      |     ---------^^^^^^^^^^-
      |     |    |   |
      |     |    |   second mutable borrow occurs here
      |     |    first borrow later used by call
      |     first mutable borrow occurs here

That's because Rust has a left-to-right evaluation order, and the method
receiver is passed first. Thus, the argument to the method cannot then
mutate `self`.

There's an easy solution to this error: just extract a local variable
for the inner argument:

    let tmp = self.bar();
    self.foo(tmp);

However, the error doesn't give any suggestion of how to solve the
problem. As a result, new users may assume that it's impossible to
express their code correctly and get stuck.

This commit adds a (non-structured) suggestion to extract a local
variable for the inner argument to solve the error. The suggestion uses
heuristics that eliminate most false positives, though there are a few
false negatives (cases where the suggestion should be emitted but is
not). Those other cases can be implemented in a future change.
Suggest using a temporary variable to fix borrowck errors

Fixes rust-lang#77834.

In Rust, nesting method calls with both require `&mut` access to `self`
produces a borrow-check error:

    error[E0499]: cannot borrow `*self` as mutable more than once at a time
     --> src/lib.rs:7:14
      |
    7 |     self.foo(self.bar());
      |     ---------^^^^^^^^^^-
      |     |    |   |
      |     |    |   second mutable borrow occurs here
      |     |    first borrow later used by call
      |     first mutable borrow occurs here

That's because Rust has a left-to-right evaluation order, and the method
receiver is passed first. Thus, the argument to the method cannot then
mutate `self`.

There's an easy solution to this error: just extract a local variable
for the inner argument:

    let tmp = self.bar();
    self.foo(tmp);

However, the error doesn't give any suggestion of how to solve the
problem. As a result, new users may assume that it's impossible to
express their code correctly and get stuck.

This commit adds a (non-structured) suggestion to extract a local
variable for the inner argument to solve the error. The suggestion uses
heuristics that eliminate most false positives, though there are a few
false negatives (cases where the suggestion should be emitted but is
not). Those other cases can be implemented in a future change.
…r=joshtriplett

Add a `try_clone()` function to `OwnedFd`.

As suggested in rust-lang#88564. This adds a `try_clone()` to `OwnedFd` by
refactoring the code out of the existing `File`/`Socket` code.

r? ``@joshtriplett``
Point at capture points for non-`'static` reference crossing a `yield` point

```
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
  --> $DIR/issue-72312.rs:10:24
   |
LL |     pub async fn start(&self) {
   |                        ^^^^^ this data with an anonymous lifetime `'_`...
...
LL |         require_static(async move {
   |         -------------- ...is required to live as long as `'static` here...
LL |             &self;
   |             ----- ...and is captured here
   |
note: `'static` lifetime requirement introduced by this trait bound
  --> $DIR/issue-72312.rs:2:22
   |
LL | fn require_static<T: 'static>(val: T) -> T {
   |                      ^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0759`.
```

Fix rust-lang#72312.
Make `intrinsics::write_bytes` const

This is required to constify `MaybeUninit::zeroed` and `(*mut T)::write_bytes`.

Tracking issue: rust-lang#86302
Make `Borrow` and `BorrowMut` impls `const`

Tracking issue: rust-lang#91522
…anieu

Add spin_loop hint for RISC-V architecture

This commit uses the PAUSE instruction (rust-lang/stdarch#1262) to implement RISC-V spin loop, and updates `stdarch` submodule to use the merged PAUSE instruction.
@rustbot rustbot added the rollup A PR which is a rollup label Dec 11, 2021
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=6

@bors
Copy link
Contributor

bors commented Dec 11, 2021

📌 Commit 2356936 has been approved by matthiaskrgr

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 11, 2021
@bors
Copy link
Contributor

bors commented Dec 11, 2021

⌛ Testing commit 2356936 with merge 11f9b5ea82c48fcab8ab71d67851f9a79dce0e69...

@bors
Copy link
Contributor

bors commented Dec 11, 2021

💔 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 Dec 11, 2021
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-msvc-1 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test sync::mpsc::tests::stress_recv_timeout_two_threads ... ok

failures:

---- net::tcp::tests::clone_accept_smoke stdout ----
thread 'net::tcp::tests::clone_accept_smoke' panicked at 'received error for `a.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\tcp\tests.rs:582:18
---- net::tcp::tests::clone_accept_concurrent stdout ----
---- net::tcp::tests::clone_accept_concurrent stdout ----
thread 'net::tcp::tests::clone_accept_concurrent' panicked at 'received error for `a.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\tcp\tests.rs:600:18
---- net::tcp::tests::close_readwrite_smoke stdout ----
---- net::tcp::tests::close_readwrite_smoke stdout ----
thread 'net::tcp::tests::close_readwrite_smoke' panicked at 'received error for `s.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\tcp\tests.rs:484:22
---- net::tcp::tests::clone_while_reading stdout ----
---- net::tcp::tests::clone_while_reading stdout ----
thread 'net::tcp::tests::clone_while_reading' panicked at 'received error for `tcp.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\tcp\tests.rs:556:20
---- net::tcp::tests::tcp_clone_smoke stdout ----
---- net::tcp::tests::tcp_clone_smoke stdout ----
thread 'net::tcp::tests::tcp_clone_smoke' panicked at 'received error for `s1.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\tcp\tests.rs:370:18
---- net::tcp::tests::tcp_clone_two_read stdout ----
---- net::tcp::tests::tcp_clone_two_read stdout ----
thread 'net::tcp::tests::tcp_clone_two_read' panicked at 'received error for `s1.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\tcp\tests.rs:403:18
---- net::tcp::tests::tcp_clone_two_write stdout ----
---- net::tcp::tests::tcp_clone_two_write stdout ----
thread 'net::tcp::tests::tcp_clone_two_write' panicked at 'received error for `s1.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\tcp\tests.rs:434:18
---- net::udp::tests::udp_clone_smoke stdout ----
---- net::udp::tests::udp_clone_smoke stdout ----
thread 'net::udp::tests::udp_clone_smoke' panicked at 'received error for `sock1.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\udp\tests.rs:85:21
---- net::udp::tests::udp_clone_two_read stdout ----
---- net::udp::tests::udp_clone_two_read stdout ----
thread 'net::udp::tests::udp_clone_two_read' panicked at 'received error for `sock1.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\udp\tests.rs:116:21
---- net::udp::tests::udp_clone_two_write stdout ----
---- net::udp::tests::udp_clone_two_write stdout ----
thread 'net::udp::tests::udp_clone_two_write' panicked at 'received error for `sock1.try_clone()`: The operation completed successfully. (os error 0)', library\std\src\net\udp\tests.rs:149:21

failures:
    net::tcp::tests::clone_accept_concurrent
    net::tcp::tests::clone_accept_smoke
---
    net::udp::tests::udp_clone_two_write

test result: FAILED. 873 passed; 10 failed; 3 ignored; 0 measured; 0 filtered out; finished in 14.09s

error: test failed, to rerun pass '-p std --lib'


command did not execute successfully: "\\\\?\\D:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "test" "--target" "x86_64-pc-windows-msvc" "-Zbinary-dep-depinfo" "-j" "8" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace profiler compiler-builtins-c" "--manifest-path" "D:\\a\\rust\\rust\\library/test/Cargo.toml" "-p" "std" "--"


Build completed unsuccessfully in 0:55:14
Build completed unsuccessfully in 0:55:14
make: *** [Makefile:72: ci-subset-1] Error 1

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-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants