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

Implementation of sync_nonpoison and nonpoison_mutex #134663

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Aandreba
Copy link

Implementation of sync_nonpoison and nonpoison_mutex
Docs come straight from the poisoned Mutex, so they need to be updated.

Tracked by:

@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 22, 2024
@rust-log-analyzer

This comment has been minimized.

/// # Examples
///
/// ```
/// use std::sync::Mutex;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These doctests need to be updated, they are using the poisioning mutex

use crate::ptr::NonNull;
use crate::sys::sync as sys;

/// A mutual exclusion primitive useful for protecting shared data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs for this one could probably just have a single example and then suggest looking at std::sync::poison::Mutex for more, so that we don't have the detailed documentation repeated in multiple locations. Also make sure the doctests are using the right type here.

@tgross35
Copy link
Contributor

@Amanieu you may want to double check this

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc PG-exploit-mitigations Project group: Exploit mitigations T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Dec 24, 2024
@rustbot

This comment was marked as resolved.

@Noratrieb
Copy link
Member

Looks like you messed up a rebase. No worries, mistakes like this happen sadly (thanks Git for being so hard to use!). To get rid of all these commits, do a git rebase -i upstream/master (where upstream is the rust-lang/rust remote) as described in https://rustc-dev-guide.rust-lang.org/git.html#i-made-a-merge-commit-by-accident.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Amanieu
Copy link
Member

Amanieu commented Dec 24, 2024

This seems fine as a first step. Longer term we may want to consider changing the poisoning mutexes to be a wrapper around a non-poisoning Mutex<Poison<T>>, but that can happen in a later PR.

@jieyouxu jieyouxu removed A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-meta Area: Issues & PRs about the rust-lang/rust repository itself PG-exploit-mitigations Project group: Exploit mitigations A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Dec 24, 2024
@Dylan-DPC
Copy link
Member

@Aandreba any updates on this? thanks

@Aandreba
Copy link
Author

Sorry about the delay, I've been busy with other stuff, but I have a bit of an opening this next days so I'll see how much I can do

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Mar 14, 2025
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot removed the has-merge-commits PR has merge commits, merge with caution. label Mar 19, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor

tgross35 commented Apr 1, 2025

The tests look like they are failing because the path displayed in UI output changed. You should be able to update these by running ./x t --stage 1 tests/ui --bless locally.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#19 exporting to docker image format
#19 sending tarball 20.3s done
#19 DONE 28.1s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: build.build          := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
  Number of decisions:   4447
  longest path:          1159 (code:    152)
  longest backtrack:       66 (code:    428)
Shared 86733 out of 152951 states by creating 14756 new states, saving 71977
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/expmed.cc: In function ‘rtx_def* extract_bit_field_1(rtx, poly_uint64, poly_uint64, int, rtx, machine_mode, machine_mode, bool, bool, rtx_def**)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/expmed.cc:1864:45: warning: ‘*(unsigned int*)((char*)&imode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ may be used uninitialized [-Wmaybe-uninitialized]
 1864 |       rtx sub = extract_bit_field_as_subreg (mode1, op0, imode,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
 1865 |                                              bitsize, bitnum);
      |                                              ~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/expmed.cc:1824:19: note: ‘*(unsigned int*)((char*)&imode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ was declared here
 1824 |   scalar_int_mode imode;
      |                   ^~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gimple-range-gori.cc: In member function ‘void range_def_chain::dump(FILE*, basic_block, const char*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gimple-range-gori.cc:319:19: warning: format not a string literal and no format arguments [-Wformat-security]
  319 |           fprintf (f, prefix);
      |           ~~~~~~~~^~~~~~~~~~~
---
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gcc.cc:7930:9: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 7930 |   write (fd, "\n\n", 2);
      |   ~~~~~~^~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gcc.cc: In member function ‘void driver::final_actions() const’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gcc.cc:9307:13: warning: ignoring return value of ‘int truncate(const char*, __off_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 9307 |     truncate(totruncate_file, 0);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto-wrapper.cc: In function ‘bool find_and_merge_options(int, off_t, const char*, vec<cl_decoded_option>, bool, vec<cl_decoded_option>*, const char*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto-wrapper.cc:1165:8: warning: ignoring return value of ‘ssize_t read(int, void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 1165 |   read (fd, data, length);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc: In function ‘void lto_resolution_read(splay_tree, FILE*, lto_file*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc:2091:10: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2091 |   fscanf (resolution, " ");   /* Read white space.  */
      |   ~~~~~~~^~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc:2093:9: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2093 |   fread (obj_name, sizeof (char), name_len, resolution);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc:2113:10: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2113 |   fscanf (resolution, "%u", &num_symbols);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/jit/jit-recording.cc:32:
---
Applying io_quotes_use            to linux/blkzoned.h
Applying io_quotes_use            to linux/ipmi.h
Applying io_quotes_use            to linux/psp-dbc.h
Applying io_quotes_use            to linux/bt-bmc.h
Applying io_quotes_use            to linux/tps6594_pfsm.h
Applying io_quotes_use            to linux/cxl_mem.h
Applying io_quotes_use            to linux/wmi.h
Applying io_quotes_use            to linux/auto_fs.h
Applying io_quotes_use            to linux/mmtimer.h
Applying io_quotes_use            to linux/f2fs.h
Applying io_quotes_use            to linux/vhost.h
---
Applying machine_name             to x86_64-linux-gnu/bits/unistd_ext.h
Applying io_quotes_use            to x86_64-linux-gnu/asm/mtrr.h
Applying io_quotes_use            to x86_64-linux-gnu/asm/amd_hsmp.h
Applying machine_name             to openssl/e_os2.h
Applying io_quotes_use            to drm/xe_drm.h
Applying io_quotes_use            to drm/radeon_drm.h
Applying io_quotes_use            to drm/panfrost_drm.h
Applying io_quotes_use            to drm/etnaviv_drm.h
Applying io_quotes_use            to drm/lima_drm.h
Applying io_quotes_use            to drm/qaic_accel.h
Applying io_quotes_use            to drm/vc4_drm.h
Applying io_quotes_use            to drm/i915_drm.h
Applying io_quotes_use            to drm/omap_drm.h
Applying io_quotes_use            to drm/pvr_drm.h
Applying io_quotes_use            to drm/amdgpu_drm.h
Applying io_quotes_use            to drm/vgem_drm.h
Applying io_quotes_use            to drm/msm_drm.h
Applying io_quotes_use            to drm/v3d_drm.h
Applying io_quotes_use            to drm/exynos_drm.h
Applying io_quotes_use            to drm/nouveau_drm.h
Applying io_quotes_use            to drm/drm.h
Applying io_quotes_use            to drm/habanalabs_accel.h
Applying io_quotes_use            to drm/tegra_drm.h
Applying io_quotes_use            to rdma/rdma_user_ioctl.h
cc1: note: self-tests are not enabled in this build
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/c++tools/server.cc: In function ‘void server(bool, int, module_resolver*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/c++tools/server.cc:620:10: warning: ignoring return value of ‘int pipe(int*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
---
8 note: future is not `Send` as this value is used across an await
9   --> $DIR/issue-64130-non-send-future-diags.rs:17:11
10    |

11 LL |     let g = x.lock().unwrap();
-    |         - has type `MutexGuard<'_, u32>` which is not `Send`
+    |         - has type `std::sync::MutexGuard<'_, u32>` which is not `Send`
13 LL |     baz().await;
14    |           ^^^^^ await occurs here, with `g` maybe used later
15 note: required by a bound in `is_send`


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args async-await/issue-64130-non-send-future-diags.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/issue-64130-non-send-future-diags.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/issue-64130-non-send-future-diags" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
error: future cannot be sent between threads safely
##[error]  --> /checkout/tests/ui/async-await/issue-64130-non-send-future-diags.rs:23:13
   |
LL |     is_send(foo());
   |             ^^^^^ future returned by `foo` is not `Send`
   |
   = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `std::sync::MutexGuard<'_, u32>`
note: future is not `Send` as this value is used across an await
  --> /checkout/tests/ui/async-await/issue-64130-non-send-future-diags.rs:17:11
   |
LL |     let g = x.lock().unwrap();
   |         - has type `std::sync::MutexGuard<'_, u32>` which is not `Send`
LL |     baz().await;
   |           ^^^^^ await occurs here, with `g` maybe used later
note: required by a bound in `is_send`
  --> /checkout/tests/ui/async-await/issue-64130-non-send-future-diags.rs:9:15
   |
LL | fn is_send<T: Send>(t: T) { }
   |               ^^^^ required by this bound in `is_send`

error: aborting due to 1 previous error
------------------------------------------


---- [ui] tests/ui/async-await/issue-71137.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/issue-71137/issue-71137.stderr"
diff of stderr:

4 LL |   fake_spawn(wrong_mutex());
5    |              ^^^^^^^^^^^^^ future returned by `wrong_mutex` is not `Send`
6    |
-    = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, i32>`
+    = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `std::sync::MutexGuard<'_, i32>`
8 note: future is not `Send` as this value is used across an await
9   --> $DIR/issue-71137.rs:14:26
10    |

11 LL |     let mut guard = m.lock().unwrap();
-    |         --------- has type `MutexGuard<'_, i32>` which is not `Send`
+    |         --------- has type `std::sync::MutexGuard<'_, i32>` which is not `Send`
13 LL |     (async { "right"; }).await;
14    |                          ^^^^^ await occurs here, with `mut guard` maybe used later
15 note: required by a bound in `fake_spawn`


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args async-await/issue-71137.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/issue-71137.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/issue-71137" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
error: future cannot be sent between threads safely
##[error]  --> /checkout/tests/ui/async-await/issue-71137.rs:22:14
   |
LL |   fake_spawn(wrong_mutex()); //~ Error future cannot be sent between threads safely
   |              ^^^^^^^^^^^^^ future returned by `wrong_mutex` is not `Send`
   |
   = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `std::sync::MutexGuard<'_, i32>`
note: future is not `Send` as this value is used across an await
  --> /checkout/tests/ui/async-await/issue-71137.rs:14:26
   |
LL |     let mut guard = m.lock().unwrap();
   |         --------- has type `std::sync::MutexGuard<'_, i32>` which is not `Send`
LL |     (async { "right"; }).await;
   |                          ^^^^^ await occurs here, with `mut guard` maybe used later
note: required by a bound in `fake_spawn`
  --> /checkout/tests/ui/async-await/issue-71137.rs:8:27
   |
LL | fn fake_spawn<F: Future + Send + 'static>(f: F) { }
   |                           ^^^^ required by this bound in `fake_spawn`

error: aborting due to 1 previous error
------------------------------------------


---
- error[E0277]: `MutexGuard<'_, ()>` cannot be sent between threads safely
+ error[E0277]: `std::sync::MutexGuard<'_, ()>` cannot be sent between threads safely
2   --> $DIR/issue-67893.rs:9:7
3    |
4 LL |     g(issue_67893::run())

-    |     - ^^^^^^^^^^^^^^^^^^ `MutexGuard<'_, ()>` cannot be sent between threads safely
+    |     - ^^^^^^^^^^^^^^^^^^ `std::sync::MutexGuard<'_, ()>` cannot be sent between threads safely
6    |     |
7    |     required by a bound introduced by this call
8    |

11 LL | pub async fn run() {
---
To only update this specific test, also pass `--test-args async-await/issues/issue-67893.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/issues/issue-67893.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/issues/issue-67893" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/issues/issue-67893/auxiliary" "--edition=2018"
stdout: none
--- stderr -------------------------------
error[E0277]: `std::sync::MutexGuard<'_, ()>` cannot be sent between threads safely
##[error]  --> /checkout/tests/ui/async-await/issues/issue-67893.rs:9:7
   |
LL |     g(issue_67893::run())
   |     - ^^^^^^^^^^^^^^^^^^ `std::sync::MutexGuard<'_, ()>` cannot be sent between threads safely
   |     |
   |     required by a bound introduced by this call
   |
  ::: /checkout/tests/ui/async-await/issues/auxiliary/issue_67893.rs:9:1
   |
---
  --> /checkout/tests/ui/async-await/issues/auxiliary/issue_67893.rs:9:20
   |
LL |   pub async fn run() {
   |  ____________________^
LL | |     let x: Arc<Mutex<()>> = make_arc();
LL | |     f(*x.lock().unwrap()).await;
LL | | }
   | |_^
note: required by a bound in `g`
  --> /checkout/tests/ui/async-await/issues/issue-67893.rs:6:14
   |
LL | fn g(_: impl Send) {}
   |              ^^^^ required by this bound in `g`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
------------------------------------------
---
To only update this specific test, also pass `--test-args issues/issue-54062.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/issues/issue-54062.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-54062" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0616]: field `inner` of struct `std::sync::Mutex` is private
##[error]  --> /checkout/tests/ui/issues/issue-54062.rs:10:24
   |
---
---- [ui] tests/ui/lint/must_not_suspend/mutex.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/must_not_suspend/mutex/mutex.stderr"
diff of stderr:

- error: `MutexGuard` held across a suspend point, but should not be
+ error: `std::sync::MutexGuard` held across a suspend point, but should not be
2   --> $DIR/mutex.rs:8:9
3    |
4 LL |     let _guard = m.lock().unwrap();


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args lint/must_not_suspend/mutex.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/lint/must_not_suspend/mutex.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/must_not_suspend/mutex" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
error: `std::sync::MutexGuard` held across a suspend point, but should not be
##[error]  --> /checkout/tests/ui/lint/must_not_suspend/mutex.rs:8:9
   |
LL |     let _guard = m.lock().unwrap(); //~ ERROR `MutexGuard` held across
   |         ^^^^^^
LL |     other().await;
   |             ----- the value is held across this suspend point
   |
note: holding a MutexGuard across suspend points can cause deadlocks, delays, and cause Futures to not implement `Send`
  --> /checkout/tests/ui/lint/must_not_suspend/mutex.rs:8:9
   |
LL |     let _guard = m.lock().unwrap(); //~ ERROR `MutexGuard` held across
   |         ^^^^^^
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
  --> /checkout/tests/ui/lint/must_not_suspend/mutex.rs:8:9
   |
LL |     let _guard = m.lock().unwrap(); //~ ERROR `MutexGuard` held across
   |         ^^^^^^
note: the lint level is defined here
  --> /checkout/tests/ui/lint/must_not_suspend/mutex.rs:3:9
   |
LL | #![deny(must_not_suspend)]
   |         ^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error
------------------------------------------


---- [ui] tests/ui/suggestions/inner_type.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/inner_type/inner_type.stderr"
diff of stderr:

30 LL |     other_item.borrow_mut().some_mutable_method();
31    |               +++++++++++++
32 
- error[E0599]: no method named `method` found for struct `Mutex` in the current scope
+ error[E0599]: no method named `method` found for struct `std::sync::Mutex` in the current scope
34   --> $DIR/inner_type.rs:27:18
---
To only update this specific test, also pass `--test-args suggestions/inner_type.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/suggestions/inner_type.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/inner_type" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error[E0599]: no method named `method` found for struct `RefCell` in the current scope
##[error]  --> /checkout/tests/ui/suggestions/inner_type.rs:17:16
   |
LL |     other_item.method();
   |                ^^^^^^ method not found in `RefCell<Struct<u32>>`
   |
note: the method `method` exists on the type `Struct<u32>`
  --> /checkout/tests/ui/suggestions/inner_type.rs:9:5
   |
LL |     pub fn method(&self) {}
   |     ^^^^^^^^^^^^^^^^^^^^
help: use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists
   |
LL |     other_item.borrow().method();
   |               +++++++++

error[E0599]: no method named `some_mutable_method` found for struct `RefCell` in the current scope
##[error]  --> /checkout/tests/ui/suggestions/inner_type.rs:21:16
   |
LL |     other_item.some_mutable_method();
   |                ^^^^^^^^^^^^^^^^^^^ method not found in `RefCell<Struct<u32>>`
   |
note: the method `some_mutable_method` exists on the type `Struct<u32>`
  --> /checkout/tests/ui/suggestions/inner_type.rs:11:5
   |
LL |     pub fn some_mutable_method(&mut self) {}
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use `.borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist
   |
LL |     other_item.borrow_mut().some_mutable_method();
   |               +++++++++++++

error[E0599]: no method named `method` found for struct `std::sync::Mutex` in the current scope
##[error]  --> /checkout/tests/ui/suggestions/inner_type.rs:27:18
   |
LL |     another_item.method();
   |                  ^^^^^^ method not found in `Mutex<Struct<u32>>`
   |
note: the method `method` exists on the type `Struct<u32>`
  --> /checkout/tests/ui/suggestions/inner_type.rs:9:5
   |
LL |     pub fn method(&self) {}
   |     ^^^^^^^^^^^^^^^^^^^^
help: use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
   |
LL |     another_item.lock().unwrap().method();
   |                 ++++++++++++++++

error[E0599]: no method named `method` found for struct `RwLock` in the current scope
##[error]  --> /checkout/tests/ui/suggestions/inner_type.rs:33:18
   |
LL |     another_item.method();
   |                  ^^^^^^ method not found in `RwLock<Struct<u32>>`
   |
note: the method `method` exists on the type `Struct<u32>`
  --> /checkout/tests/ui/suggestions/inner_type.rs:9:5
   |
LL |     pub fn method(&self) {}
   |     ^^^^^^^^^^^^^^^^^^^^
help: use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
   |
LL |     another_item.read().unwrap().method();
   |                 ++++++++++++++++

error[E0599]: no method named `some_mutable_method` found for struct `RwLock` in the current scope
##[error]  --> /checkout/tests/ui/suggestions/inner_type.rs:37:18
   |
LL |     another_item.some_mutable_method();
   |                  ^^^^^^^^^^^^^^^^^^^ method not found in `RwLock<Struct<u32>>`
   |
note: the method `some_mutable_method` exists on the type `Struct<u32>`
  --> /checkout/tests/ui/suggestions/inner_type.rs:11:5
   |
LL |     pub fn some_mutable_method(&mut self) {}
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired
   |
LL |     another_item.write().unwrap().some_mutable_method();
   |                 +++++++++++++++++

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0599`.
---
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/sync/mutexguard-sync/mutexguard-sync.stderr"
diff of stderr:

8    |
9    = help: the trait `Sync` is not implemented for `Cell<i32>`
10    = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead
-    = note: required for `MutexGuard<'_, Cell<i32>>` to implement `Sync`
+    = note: required for `std::sync::MutexGuard<'_, Cell<i32>>` to implement `Sync`
12 note: required by a bound in `test_sync`
13   --> $DIR/mutexguard-sync.rs:5:17
14    |


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args sync/mutexguard-sync.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/sync/mutexguard-sync.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/sync/mutexguard-sync" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0277]: `Cell<i32>` cannot be shared between threads safely
##[error]  --> /checkout/tests/ui/sync/mutexguard-sync.rs:11:15
   |
LL |     test_sync(guard);
   |     --------- ^^^^^ `Cell<i32>` cannot be shared between threads safely
   |     |
   |     required by a bound introduced by this call
   |
   = help: the trait `Sync` is not implemented for `Cell<i32>`
   = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead
   = note: required for `std::sync::MutexGuard<'_, Cell<i32>>` to implement `Sync`
note: required by a bound in `test_sync`
  --> /checkout/tests/ui/sync/mutexguard-sync.rs:5:17
   |
LL | fn test_sync<T: Sync>(_t: T) {}
   |                 ^^^^ required by this bound in `test_sync`

error: aborting due to 1 previous error

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

14 LL |     pub const fn new() -> std::sync::Mutex<dyn T> {}
15    |                           ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
16    |
-    = help: within `Mutex<(dyn T + 'static)>`, the trait `Sized` is not implemented for `(dyn T + 'static)`
- note: required because it appears within the type `Mutex<(dyn T + 'static)>`
+    = help: within `std::sync::Mutex<(dyn T + 'static)>`, the trait `Sized` is not implemented for `(dyn T + 'static)`
+ note: required because it appears within the type `std::sync::Mutex<(dyn T + 'static)>`
19   --> $SRC_DIR/std/src/sync/poison/mutex.rs:LL:COL
20    = note: the return type of a function must have a statically known size
21 

27    |                  |
28    |                  implicitly returns `()` as its body has no tail or `return` expression
29    |
-    = note: expected struct `Mutex<(dyn T + 'static)>`
+    = note: expected struct `std::sync::Mutex<(dyn T + 'static)>`
31            found unit type `()`
32 
33 error: aborting due to 3 previous errors


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args traits/const-traits/span-bug-issue-121418.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/traits/const-traits/span-bug-issue-121418.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/traits/const-traits/span-bug-issue-121418" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: inherent impls cannot be `const`
##[error]  --> /checkout/tests/ui/traits/const-traits/span-bug-issue-121418.rs:6:12
   |
LL | impl const dyn T {
   |      ----- ^^^^^ inherent impl for this type
   |      |
   |      `const` because of this
   |
   = note: only trait implementations may be annotated with `const`

error[E0277]: the size for values of type `(dyn T + 'static)` cannot be known at compilation time
##[error]  --> /checkout/tests/ui/traits/const-traits/span-bug-issue-121418.rs:8:27
   |
LL |     pub const fn new() -> std::sync::Mutex<dyn T> {}
   |                           ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: within `std::sync::Mutex<(dyn T + 'static)>`, the trait `Sized` is not implemented for `(dyn T + 'static)`
note: required because it appears within the type `std::sync::Mutex<(dyn T + 'static)>`
  --> /rustc/FAKE_PREFIX/library/std/src/sync/poison/mutex.rs:175:12
   = note: the return type of a function must have a statically known size

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/traits/const-traits/span-bug-issue-121418.rs:8:27
   |
LL |     pub const fn new() -> std::sync::Mutex<dyn T> {}
   |                  ---      ^^^^^^^^^^^^^^^^^^^^^^^ expected `Mutex<dyn T>`, found `()`
   |                  |
   |                  implicitly returns `()` as its body has no tail or `return` expression
   |
   = note: expected struct `std::sync::Mutex<(dyn T + 'static)>`
           found unit type `()`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0277, E0308.
---
---- [ui] tests/ui/typeck/assign-non-lval-derefmut.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/typeck/assign-non-lval-derefmut/assign-non-lval-derefmut.stderr"
diff of stderr:

11 LL |     *x.lock().unwrap() = 2;
12    |     +
13 
- error[E0368]: binary assignment operation `+=` cannot be applied to type `MutexGuard<'_, usize>`
+ error[E0368]: binary assignment operation `+=` cannot be applied to type `std::sync::MutexGuard<'_, usize>`
15   --> $DIR/assign-non-lval-derefmut.rs:7:5
16    |
17 LL |     x.lock().unwrap() += 1;

18    |     -----------------^^^^^
19    |     |
-    |     cannot use `+=` on type `MutexGuard<'_, usize>`
+    |     cannot use `+=` on type `std::sync::MutexGuard<'_, usize>`
21    |
- note: the foreign item type `MutexGuard<'_, usize>` doesn't implement `AddAssign<{integer}>`
+ note: the foreign item type `std::sync::MutexGuard<'_, usize>` doesn't implement `AddAssign<{integer}>`
23   --> $SRC_DIR/std/src/sync/poison/mutex.rs:LL:COL
24    |
25    = note: not implement `AddAssign<{integer}>`

36 LL |     y = 2;
37    |         ^ expected `MutexGuard<'_, usize>`, found integer
38    |
-    = note: expected struct `MutexGuard<'_, usize>`
+    = note: expected struct `std::sync::MutexGuard<'_, usize>`
40                 found type `{integer}`
41 help: consider dereferencing here to assign to the mutably borrowed value
42    |

43 LL |     *y = 2;
44    |     +
45 
- error[E0368]: binary assignment operation `+=` cannot be applied to type `MutexGuard<'_, usize>`
+ error[E0368]: binary assignment operation `+=` cannot be applied to type `std::sync::MutexGuard<'_, usize>`
47   --> $DIR/assign-non-lval-derefmut.rs:13:5
48    |
49 LL |     y += 1;

50    |     -^^^^^
51    |     |
-    |     cannot use `+=` on type `MutexGuard<'_, usize>`
+    |     cannot use `+=` on type `std::sync::MutexGuard<'_, usize>`
53    |
- note: the foreign item type `MutexGuard<'_, usize>` doesn't implement `AddAssign<{integer}>`
+ note: the foreign item type `std::sync::MutexGuard<'_, usize>` doesn't implement `AddAssign<{integer}>`
55   --> $SRC_DIR/std/src/sync/poison/mutex.rs:LL:COL
56    |
57    = note: not implement `AddAssign<{integer}>`


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args typeck/assign-non-lval-derefmut.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/typeck/assign-non-lval-derefmut.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/typeck/assign-non-lval-derefmut" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0070]: invalid left-hand side of assignment
##[error]  --> /checkout/tests/ui/typeck/assign-non-lval-derefmut.rs:5:23
   |
LL |     x.lock().unwrap() = 2;
   |     ----------------- ^
   |     |
   |     cannot assign to this expression
   |
help: consider dereferencing here to assign to the mutably borrowed value
   |
LL |     *x.lock().unwrap() = 2;
   |     +

error[E0368]: binary assignment operation `+=` cannot be applied to type `std::sync::MutexGuard<'_, usize>`
##[error]  --> /checkout/tests/ui/typeck/assign-non-lval-derefmut.rs:7:5
   |
LL |     x.lock().unwrap() += 1;
   |     -----------------^^^^^
   |     |
   |     cannot use `+=` on type `std::sync::MutexGuard<'_, usize>`
   |
note: the foreign item type `std::sync::MutexGuard<'_, usize>` doesn't implement `AddAssign<{integer}>`
  --> /rustc/FAKE_PREFIX/library/std/src/sync/poison/mutex.rs:225:1
   |
   = note: not implement `AddAssign<{integer}>`
help: `+=` can be used on `usize` if you dereference the left-hand side
   |
LL |     *x.lock().unwrap() += 1;
   |     +

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/assign-non-lval-derefmut.rs:11:9
   |
---
   = note: expected struct `std::sync::MutexGuard<'_, usize>`
                found type `{integer}`
help: consider dereferencing here to assign to the mutably borrowed value
   |
LL |     *y = 2;
   |     +

error[E0368]: binary assignment operation `+=` cannot be applied to type `std::sync::MutexGuard<'_, usize>`
##[error]  --> /checkout/tests/ui/typeck/assign-non-lval-derefmut.rs:13:5
   |
LL |     y += 1;
   |     -^^^^^
   |     |
   |     cannot use `+=` on type `std::sync::MutexGuard<'_, usize>`
   |
note: the foreign item type `std::sync::MutexGuard<'_, usize>` doesn't implement `AddAssign<{integer}>`
  --> /rustc/FAKE_PREFIX/library/std/src/sync/poison/mutex.rs:225:1
   |
   = note: not implement `AddAssign<{integer}>`
help: `+=` can be used on `usize` if you dereference the left-hand side
   |
LL |     *y += 1;
   |     +

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0070, E0308, E0368.
---
-             found struct `MutexGuard<'_, &i32>`
+             found struct `std::sync::MutexGuard<'_, &i32>`
67 help: consider dereferencing the type
68    |
69 LL |     **x.lock().unwrap()


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args typeck/deref-multi.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/typeck/deref-multi.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/typeck/deref-multi" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/deref-multi.rs:2:5
   |
LL | fn a(x: &&i32) -> i32 {
   |                   --- expected `i32` because of return type
LL |     x
   |     ^ expected `i32`, found `&&i32`
   |
help: consider dereferencing the borrow
   |
LL |     **x
   |     ++

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/deref-multi.rs:7:5
   |
LL | fn a2(x: &&&&&i32) -> i32 {
   |                       --- expected `i32` because of return type
LL |     x
   |     ^ expected `i32`, found `&&&&&i32`
   |
help: consider dereferencing the borrow
   |
LL |     *****x
   |     +++++

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/deref-multi.rs:12:5
   |
LL | fn b(x: &i32) -> i32 {
   |                  --- expected `i32` because of return type
LL |     &x
   |     ^^ expected `i32`, found `&&i32`
   |
help: consider removing the `&` and dereferencing the borrow instead
   |
LL -     &x
LL +     *x
   |

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/deref-multi.rs:17:5
   |
LL | fn c(x: Box<i32>) -> i32 {
   |                      --- expected `i32` because of return type
LL |     &x
   |     ^^ expected `i32`, found `&Box<i32>`
   |
   = note:   expected type `i32`
           found reference `&Box<i32>`
help: consider removing the `&` and dereferencing the borrow instead
   |
LL -     &x
LL +     *x
   |

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/deref-multi.rs:22:5
   |
LL | fn d(x: std::sync::Mutex<&i32>) -> i32 {
   |                                    --- expected `i32` because of return type
LL |     x.lock().unwrap()
   |     ^^^^^^^^^^^^^^^^^ expected `i32`, found `MutexGuard<'_, &i32>`
   |
   = note: expected type `i32`
            found struct `std::sync::MutexGuard<'_, &i32>`
help: consider dereferencing the type
   |
LL |     **x.lock().unwrap()
   |     ++

error: aborting due to 5 previous errors

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants