Skip to content

Commit

Permalink
Unsafecell fix (#32)
Browse files Browse the repository at this point in the history
* Bumped patch release,updated layout for Cell and UnsafeCell due to rustc bug.

Link to rust bug rust-lang/rust#68206

* Travis config:remove Cargo.lock after beta builds

* Fix previous commit
  • Loading branch information
rodrimati1992 committed Jan 17, 2020
1 parent 9418815 commit d1d44b4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -35,6 +35,9 @@ script:
- cd "${TRAVIS_BUILD_DIR}/testing/version_compatibility/impl_0"
- cargo +beta build

- cd "${TRAVIS_BUILD_DIR}/"
- rm Cargo.lock

- cd "${TRAVIS_BUILD_DIR}/examples/0_modules_and_interface_types/impl/"
- cargo check

Expand Down
15 changes: 15 additions & 0 deletions Changelog.md
Expand Up @@ -2,6 +2,21 @@ This is the changelog,summarising changes in each version(some minor changes may

# 0.8

### 0.8.2

Breaking Change(caused by soundness fix in rustc):

[This unsoundness bug for all Cell-like std types](https://github.com/rust-lang/rust/issues/68206) is going to be solved by making UnsafeCell not propagate niches.

In preparation for this change,this library will not propagate niches from T into `*Cell<T>`,
this will cause runtime errors when loading libraries containing either `*Cell` type wrapping a type with non-zero optimizations (including references,and`NonZero*` types),
and compile-time errors when putting `Option<Cell<NonZero>>` in ffi boundaries.

Dynamic libraries built on a previous patch release might have to be built from scratch,
if they contain the previously mentioned types in their API.

### 0.8.0

Added checks when loading dynamic libraries to ensure that Rust doesn't change how it represents
zero-sized types in the "C" ABI.
This means that in some rare cases,it won't be possible to link dynamic libraries across a
Expand Down
2 changes: 1 addition & 1 deletion abi_stable/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "abi_stable"
version = "0.8.1"
version = "0.8.2"
authors = ["rodrimati1992 <rodrimatt1985@gmail.com>"]
edition="2018"
license = "MIT/Apache-2.0"
Expand Down
18 changes: 11 additions & 7 deletions abi_stable/src/abi_stability/stable_abi_trait.rs
Expand Up @@ -1188,10 +1188,13 @@ mod rust_1_36_impls{

/////////////

macro_rules! impl_sabi_for_transparent {
macro_rules! impl_sabi_for_newtype {
(@trans transparent)=>{ P::IsNonZeroType };
(@trans C)=>{ False };
(
$type_constr:ident
$(where[ $($where_clause:tt)* ])* ,
$transparency:ident,
$type_name:literal,
$mod_path:expr
) => (
Expand All @@ -1208,7 +1211,7 @@ macro_rules! impl_sabi_for_transparent {
$($($where_clause)*)*
{
type Kind=ValueKind;
type IsNonZeroType = P::IsNonZeroType;
type IsNonZeroType = impl_sabi_for_newtype!(@trans $transparency);

const S_LAYOUT: &'static TypeLayout = {
const MONO_TYPE_LAYOUT:&'static MonoTypeLayout=&MonoTypeLayout::new(
Expand Down Expand Up @@ -1243,11 +1246,12 @@ macro_rules! impl_sabi_for_transparent {
}


impl_sabi_for_transparent!{ Wrapping ,"Wrapping" ,"std::num" }
impl_sabi_for_transparent!{ Pin ,"Pin" ,"std::pin" }
impl_sabi_for_transparent!{ ManuallyDrop,"ManuallyDrop","std::mem" }
impl_sabi_for_transparent!{ Cell ,"Cell" ,"std::cell" }
impl_sabi_for_transparent!{ UnsafeCell ,"UnsafeCell" ,"std::cell" }
impl_sabi_for_newtype!{ Wrapping ,transparent,"Wrapping" ,"std::num" }
impl_sabi_for_newtype!{ Pin ,transparent,"Pin" ,"std::pin" }
impl_sabi_for_newtype!{ ManuallyDrop,transparent,"ManuallyDrop","std::mem" }

impl_sabi_for_newtype!{ Cell ,C,"Cell" ,"std::cell" }
impl_sabi_for_newtype!{ UnsafeCell ,C,"UnsafeCell" ,"std::cell" }

/////////////

Expand Down

0 comments on commit d1d44b4

Please sign in to comment.