Skip to content

std::sync::barrier::BarrierState is not RefUnwindSafe anymore #146087

@weiznich

Description

@weiznich

Code

I tried this code:

git clone https://github.com/diesel-rs/diesel
cd diesel
git checkout 29a13b3
cargo +nightly check -p diesel -F sqlite -F returning_clauses_for_sqlite_3_35 --all-targets

I expected to see this happen: Compilation suceeds

Instead, this happened: Compilation fails with this error:

error[E0277]: the type `UnsafeCell<std::sync::barrier::BarrierState>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
   --> diesel/src/sqlite/connection/row.rs:383:48
    |
383 |           sleep_utils::register_impl(&mut conn2, move |a: i32| {
    |  _________--------------------------_____________^
    | |         |
    | |         required by a bound introduced by this call
384 | |             barrier.wait();
385 | |             std::thread::sleep(Duration::from_secs(a as u64));
386 | |             a
387 | |         })
    | |_________^ `UnsafeCell<std::sync::barrier::BarrierState>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
    |
    = help: within `Barrier`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<std::sync::barrier::BarrierState>`
note: required because it appears within the type `std::sync::nonpoison::Mutex<std::sync::barrier::BarrierState>`
   --> /home/weiznich/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/nonpoison/mutex.rs:50:12
    |
 50 | pub struct Mutex<T: ?Sized> {
    |            ^^^^^
note: required because it appears within the type `Barrier`
   --> /home/weiznich/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/barrier.rs:28:12
    |
 28 | pub struct Barrier {
    |            ^^^^^^^
    = note: required for `Arc<Barrier>` to implement `UnwindSafe`
note: required because it's used within this closure
   --> diesel/src/sqlite/connection/row.rs:383:48
    |
383 |         sleep_utils::register_impl(&mut conn2, move |a: i32| {
    |                                                ^^^^^^^^^^^^^
note: required by a bound in `sleep_utils::register_impl`
   --> diesel/src/sqlite/connection/row.rs:346:5
    |
346 |     #[crate::declare_sql_function]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `register_impl`
    = note: this error originates in the attribute macro `crate::declare_sql_function` (in Nightly builds, run with -Z macro-backtrace for more info)

Version it worked on

It most recently worked on: Rust nightly-2025-08-30

Version with regression

rustc --version --verbose:

rustc 1.91.0-nightly (07d246fc6 2025-08-31)
binary: rustc
commit-hash: 07d246fc6dc227903da2955b38a59e060539a485
commit-date: 2025-08-31
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0

Cargo bisect-rustc:

Regression in rust-lang-ci@4de4acb

The PR introducing the regression in this rollup is #144651: Implementation: #[feature(nonpoison_condvar)]

searched nightlies: from nightly-2025-08-30 to nightly-2025-08-31
regressed nightly: nightly-2025-08-31
searched commit range: fe55364...523d399
regressed commit: e95db59

bisected with cargo-bisect-rustc v0.6.8

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 2025-08-30 --end 2025-08-31 -- check -F sqlite -F returning_clauses_for_sqlite_3_35 --all-targets -p diesel 

cc @connortsui20 as author of the relevant PR

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-highHigh priorityT-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions