Rollup merge of #154059 - Enselic:dropped-mutex-guard, r=Kivooeo

tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`

After bisect it turns out that the test passes in `nightly-2023-09-24` but fails in `nightly-2023-09-23`:

    $ rustc +nightly-2023-09-23 --edition 2018 tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs
    error: `MutexGuard` held across a suspend point, but should not be
      --> tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs:13:9
       |
    13 |     let lock = foo.lock().unwrap();
       |         ^^^^
    ...
    18 |     bar().await;
       |           ----- the value is held across this suspend point
       |

That leaves us with

<details>
<summary>git log e4133ba9b1a150..13e6f24b9adda67 --no-merges --oneline </summary>

bffb3467e1 Make test more robust to opts.
44ac8dcc71 Remove GeneratorWitness and rename GeneratorWitnessMIR.
855a75b6d6 Remove useless wrapper.
baa64b0e77 Remove dead error code.
6aa1268900 Bless clippy.
d989e14cf2 Bless mir-opt
211d2ed07b Bless tests.
286502c9ed Enable drop_tracking_mir by default.
a626caaad9 Revert duplication of tests.
ff03204365 Fold lifetimes before substitution.
9450b75986 Do not construct def_path_str for MustNotSuspend.
58ef3a0ec9 diagnostics: simpler 83556 handling by bailing out
79d685325c Check types live across yields in generators too
c21867f9f6 Check that closure's by-value captures are sized
d3dea30cb4 Point at cause of expectation of `break` value when possible
4ed4913e67 Merge `ExternProviders` into the general `Providers` struct
2ba911c832 Have a single struct for queries and hook
9090ed8119 Fix test on targets with crt-static default
5db9a5ee38 Update cargo
9defc971f1 Add tracing instrumentation, just like queries automatically add it
2157f31731 Add a way to decouple the implementation and the declaration of a TyCtxt method.
d5ec9af09d Add test to guard against VecDeque optimization regression
3799af3337 diagnostics: avoid mismatch between variance index and hir generic
34c248d31f compiletest: load supports-xray from target spec
64e27cb4d9 compiletest: load supported sanitizers from target spec
bc7bb3c8e7 compiletest: use builder pattern to construct Config in tests

</details>

of which 286502c9ed (https://github.com/rust-lang/rust/pull/107421) seems most likely. I can't find an existing test except the "inactive" one, so let's simply activate it.

Closes rust-lang/rust#89562 which is where the activated test comes from. The test was originally added in rust-lang/rust#89826.

Tracking issue:
- rust-lang/rust#83310
This commit is contained in:
Stuart Cook
2026-03-20 15:33:07 +11:00
committed by GitHub
2 changed files with 5 additions and 2 deletions
-1
View File
@@ -1475,7 +1475,6 @@ ui/lint/issue-97094.rs
ui/lint/issue-99387.rs
ui/lint/let_underscore/issue-119696-err-on-fn.rs
ui/lint/let_underscore/issue-119697-extra-let.rs
ui/lint/must_not_suspend/issue-89562.rs
ui/lint/unused/issue-103320-must-use-ops.rs
ui/lint/unused/issue-104397.rs
ui/lint/unused/issue-105061-array-lint.rs
@@ -1,9 +1,13 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/89562>
//@ edition:2018
//@ run-pass
#![feature(must_not_suspend)]
#![deny(must_not_suspend)]
use std::sync::Mutex;
// Copied from the issue. Allow-by-default for now, so run-pass
pub async fn foo() {
let foo = Mutex::new(1);
let lock = foo.lock().unwrap();