Skip to content

Breaking change involving RefUnwindSafe in 1.1.3 #568

Closed
@dtolnay

Description

@dtolnay

The following code compiles against regex 1.1.2 but not 1.1.3:

fn f(r: regex::Regex) {
    let _ = std::panic::catch_unwind(|| r);
}
error[E0277]: the type `(dyn aho_corasick::prefilter::Prefilter + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
 --> src/main.rs:2:13
  |
2 |     let _ = std::panic::catch_unwind(|| r);
  |             ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn aho_corasick::prefilter::Prefilter + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
  |
  = help: within `regex::exec::ExecReadOnly`, the trait `std::panic::RefUnwindSafe` is not implemented for `(dyn aho_corasick::prefilter::Prefilter + 'static)`
  = note: required because it appears within the type `*const (dyn aho_corasick::prefilter::Prefilter + 'static)`
  = note: required because it appears within the type `std::ptr::Unique<(dyn aho_corasick::prefilter::Prefilter + 'static)>`
  = note: required because it appears within the type `std::boxed::Box<(dyn aho_corasick::prefilter::Prefilter + 'static)>`
  = note: required because it appears within the type `aho_corasick::prefilter::PrefilterObj`
  = note: required because it appears within the type `std::option::Option<aho_corasick::prefilter::PrefilterObj>`
  = note: required because it appears within the type `aho_corasick::nfa::NFA<u32>`
  = note: required because it appears within the type `aho_corasick::ahocorasick::Imp<u32>`
  = note: required because it appears within the type `aho_corasick::ahocorasick::AhoCorasick<u32>`
  = note: required because it appears within the type `std::option::Option<aho_corasick::ahocorasick::AhoCorasick<u32>>`
  = note: required because it appears within the type `regex::exec::ExecReadOnly`
  = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `std::sync::Arc<regex::exec::ExecReadOnly>`
  = note: required because it appears within the type `regex::exec::Exec`
  = note: required because it appears within the type `regex::re_unicode::Regex`
  = note: required because it appears within the type `[closure@src/main.rs:2:38: 2:42 r:regex::re_unicode::Regex]`
  = note: required by `std::panic::catch_unwind`

I noticed that this is breaking rustfmt (https://travis-ci.org/dtolnay/syn/jobs/513667990). Is there an easy fix on your end or would it be better for us to work around this downstream? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions