Skip to content

Commit

Permalink
Merge pull request #240 from artichoke/lopopolo/test-auto-traits
Browse files Browse the repository at this point in the history
Fix v1.9.0 regression where `SymbolTable` is no longer `Send`
  • Loading branch information
lopopolo authored Jul 28, 2023
2 parents ad78869 + 4fca27a commit 2f6db93
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "intaglio"
version = "1.9.0" # remember to set `html_root_url` in `src/lib.rs`.
version = "1.9.1" # remember to set `html_root_url` in `src/lib.rs`.
authors = ["Ryan Lopopolo <rjl@hyperbo.la>"]
license = "MIT"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
intaglio = "1.9.0"
intaglio = "1.9.1"
```

Then intern UTF-8 strings like:
Expand Down
16 changes: 16 additions & 0 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,22 @@ mod boxed {
}
}

// SAFETY: `PinBox` acts like `Box`.
unsafe impl<T> Send for PinBox<T>
where
T: ?Sized,
Box<T>: Send,
{
}

// SAFETY: `PinBox` acts like `Box`.
unsafe impl<T> Sync for PinBox<T>
where
T: ?Sized,
Box<T>: Sync,
{
}

#[cfg(test)]
mod tests {
use core::fmt::Write;
Expand Down
19 changes: 18 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
//! [`&Path`]: std::path::Path
//! [`&'static Path`]: std::path::Path
#![doc(html_root_url = "https://docs.rs/intaglio/1.9.0")]
#![doc(html_root_url = "https://docs.rs/intaglio/1.9.1")]

use core::fmt;
use core::num::TryFromIntError;
Expand Down Expand Up @@ -272,6 +272,8 @@ mod tests {
use core::cmp::Ordering;
use core::fmt::Write as _;
use core::hash::{BuildHasher as _, Hash as _, Hasher as _};
use core::marker::Unpin;
use core::panic::{RefUnwindSafe, UnwindSafe};
use std::collections::hash_map::RandomState;

use super::SymbolOverflowError;
Expand Down Expand Up @@ -357,6 +359,21 @@ mod tests {

assert_eq!(default_hash, new_hash);
}

#[test]
fn auto_traits_are_implemented() {
fn constraint<T: RefUnwindSafe + Send + Sync + Unpin + UnwindSafe>(_table: T) {}

constraint(crate::SymbolTable::with_capacity(0));
#[cfg(feature = "bytes")]
constraint(crate::bytes::SymbolTable::with_capacity(0));
#[cfg(feature = "cstr")]
constraint(crate::cstr::SymbolTable::with_capacity(0));
#[cfg(feature = "osstr")]
constraint(crate::osstr::SymbolTable::with_capacity(0));
#[cfg(feature = "path")]
constraint(crate::path::SymbolTable::with_capacity(0));
}
}

// Ensure code blocks in `README.md` compile
Expand Down

0 comments on commit 2f6db93

Please sign in to comment.