Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dtolnay/serde-untagged
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1.5
Choose a base ref
...
head repository: dtolnay/serde-untagged
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.1.6
Choose a head ref
  • 8 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 1, 2024

  1. Raise minimum tested compiler to 1.69

    Required by toml_edit.
    
        error: package `toml_edit v0.21.1` cannot be built because it requires rustc 1.69 or newer, while the currently active rustc version is 1.67.1
        Either upgrade to rustc 1.69 or newer, or use
        cargo update -p toml_edit@0.21.1 --precise ver
        where `ver` is the latest version of `toml_edit` supporting rustc 1.67.1
    dtolnay committed Feb 1, 2024
    Copy the full SHA
    f641180 View commit details

Commits on Feb 14, 2024

  1. Raise minimum tested compiler to 1.70

    Required by the most recent release of toml_edit.
    
        error: package `toml_edit v0.22.5` cannot be built because it requires rustc 1.70 or
        newer, while the currently active rustc version is 1.69.0
        Either upgrade to rustc 1.70 or newer, or use
        cargo update -p toml_edit@0.22.5 --precise ver
        where `ver` is the latest version of `toml_edit` supporting rustc 1.69.0
    dtolnay committed Feb 14, 2024
    Copy the full SHA
    a09430a View commit details

Commits on Mar 25, 2024

  1. Temporarily disable miri on doctests

    dtolnay committed Mar 25, 2024
    Copy the full SHA
    4458dec View commit details

Commits on Mar 26, 2024

  1. Explicitly install a Rust toolchain for cargo-outdated job

    Debugging a recent cargo-outdated bug, it would have been nice not to
    wonder whether a rustc version change in GitHub's runner image was a
    contributing factor.
    dtolnay committed Mar 26, 2024
    Copy the full SHA
    00546fe View commit details

Commits on Apr 8, 2024

  1. Revert "Temporarily disable miri on doctests"

    This reverts commit 4458dec.
    dtolnay committed Apr 8, 2024
    Copy the full SHA
    66e8334 View commit details

Commits on May 14, 2024

  1. Raise required compiler to rust 1.61

    dtolnay committed May 14, 2024
    Copy the full SHA
    7e41f22 View commit details
  2. Use non-static TypeId implementation from typeid crate

    dtolnay committed May 14, 2024
    Copy the full SHA
    98f1a27 View commit details
  3. Release 0.1.6

    dtolnay committed May 14, 2024
    Copy the full SHA
    900f804 View commit details
Showing with 10 additions and 33 deletions.
  1. +4 −3 .github/workflows/ci.yml
  2. +3 −2 Cargo.toml
  3. +2 −27 src/any.rs
  4. +1 −1 src/lib.rs
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [nightly, beta, stable, 1.67.0]
rust: [nightly, beta, stable, 1.70.0]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
@@ -37,14 +37,14 @@ jobs:
- run: cargo test

msrv:
name: Rust 1.56.0
name: Rust 1.61.0
needs: pre_ci
if: needs.pre_ci.outputs.continue
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.56.0
- uses: dtolnay/rust-toolchain@1.61.0
- run: cargo check --manifest-path tests/crate/Cargo.toml

minimal:
@@ -104,5 +104,6 @@ jobs:
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/install@cargo-outdated
- run: cargo outdated --workspace --exit-code 1
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde-untagged"
version = "0.1.5"
version = "0.1.6"
authors = ["David Tolnay <dtolnay@gmail.com>"]
categories = ["encoding", "no-std"]
description = "Serde `Visitor` implementation for deserializing untagged enums"
@@ -9,11 +9,12 @@ edition = "2021"
keywords = ["serde", "untagged"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/dtolnay/serde-untagged"
rust-version = "1.56"
rust-version = "1.61"

[dependencies]
erased-serde = { version = "0.4.2", default-features = false, features = ["alloc"] }
serde = { version = "1.0.194", default-features = false, features = ["alloc"] }
typeid = "1"

[dev-dependencies]
serde_derive = "1.0.194"
29 changes: 2 additions & 27 deletions src/any.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use alloc::boxed::Box;
#[cfg(any(debug_assertions, miri))]
use core::any::{self, TypeId};
#[cfg(any(debug_assertions, miri))]
use core::marker::PhantomData;
use core::mem;

pub(crate) struct ErasedValue {
@@ -25,7 +23,7 @@ impl ErasedValue {
drop::<T>
},
#[cfg(any(debug_assertions, miri))]
type_id: non_static_type_id::<T>(),
type_id: typeid::of::<T>(),
#[cfg(any(debug_assertions, miri))]
type_name: any::type_name::<T>(),
}
@@ -35,7 +33,7 @@ impl ErasedValue {
#[cfg(any(debug_assertions, miri))]
assert_eq!(
self.type_id,
non_static_type_id::<T>(),
typeid::of::<T>(),
"ErasedValue mismatch: {} vs {}",
self.type_name,
any::type_name::<T>(),
@@ -52,26 +50,3 @@ impl Drop for ErasedValue {
unsafe { (self.drop)(self.ptr) }
}
}

#[cfg(any(debug_assertions, miri))]
fn non_static_type_id<T: ?Sized>() -> TypeId {
trait NonStaticAny {
fn get_type_id(&self) -> TypeId
where
Self: 'static;
}

impl<T: ?Sized> NonStaticAny for PhantomData<T> {
fn get_type_id(&self) -> TypeId
where
Self: 'static,
{
TypeId::of::<T>()
}
}

let phantom_data = PhantomData::<T>;
NonStaticAny::get_type_id(unsafe {
mem::transmute::<&dyn NonStaticAny, &(dyn NonStaticAny + 'static)>(&phantom_data)
})
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -183,7 +183,7 @@
//! ```
#![no_std]
#![doc(html_root_url = "https://docs.rs/serde-untagged/0.1.5")]
#![doc(html_root_url = "https://docs.rs/serde-untagged/0.1.6")]
#![deny(unsafe_op_in_unsafe_fn)]
#![allow(
clippy::doc_markdown,