diff --git a/test_crates/type_alias_over_more_generic_underlying/new/Cargo.toml b/test_crates/type_alias_over_more_generic_underlying/new/Cargo.toml new file mode 100644 index 000000000..46ab5ffa5 --- /dev/null +++ b/test_crates/type_alias_over_more_generic_underlying/new/Cargo.toml @@ -0,0 +1,7 @@ +[package] +publish = false +name = "type_alias_over_more_generic_underlying" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/type_alias_over_more_generic_underlying/new/src/lib.rs b/test_crates/type_alias_over_more_generic_underlying/new/src/lib.rs new file mode 100644 index 000000000..5ab8cd01a --- /dev/null +++ b/test_crates/type_alias_over_more_generic_underlying/new/src/lib.rs @@ -0,0 +1,78 @@ +//! We're going to replace the original type (named like `OriginalType`) with two types: +//! - `pub struct NewType` +//! - `pub type OriginalType = NewType` +//! +//! This is not semver-major, since the type alias has: +//! - the same name +//! - the same fields/variants +//! - the same constructibility and pattern-matching behavior. + +pub struct NewStructOnlyPrivateFields { + _marker: std::marker::PhantomData, +} + +pub type OriginalStructOnlyPrivateFields = NewStructOnlyPrivateFields<()>; + +// --- + +pub struct NewStructGeneric { + _marker: std::marker::PhantomData<(A, B)>, +} + +pub type OriginalStructGeneric = NewStructGeneric; + +// --- + +pub struct NewStructMixOfFields { + _marker: std::marker::PhantomData, + pub x: i64, +} + +pub type OriginalStructMixOfFields = NewStructMixOfFields<()>; + +// --- + +pub struct NewStructConstructible { + pub x: T, +} + +pub type OriginalStructConstructible = NewStructConstructible; + +// --- + +pub struct NewStructEmpty { + _marker: std::marker::PhantomData, +} + +pub type OriginalStructEmpty = NewStructEmpty<()>; + +// --- + +#[non_exhaustive] +pub struct NewStructConstructibleNonexhaustive { + pub x: A, +} + +pub type OriginalStructConstructibleNonexhaustive = NewStructConstructibleNonexhaustive; + +// --- + +#[non_exhaustive] +pub struct NewStructEmptyNonexhaustive { + pub x: A, +} + +pub type OriginalStructEmptyNonexhaustive = NewStructEmptyNonexhaustive; + +// --- +// The enum case is interesting: to add a generic parameter, we need to use it somewhere. +// We'll need to add a variant, so the original enum must have been non-exhaustive +// to avoid an immediate major breaking change. + +#[non_exhaustive] +pub enum NewEnumNonexhaustive { + First, + Second(A), +} + +pub type OriginalEnumNonexhaustive = NewEnumNonexhaustive<()>; diff --git a/test_crates/type_alias_over_more_generic_underlying/old/Cargo.toml b/test_crates/type_alias_over_more_generic_underlying/old/Cargo.toml new file mode 100644 index 000000000..46ab5ffa5 --- /dev/null +++ b/test_crates/type_alias_over_more_generic_underlying/old/Cargo.toml @@ -0,0 +1,7 @@ +[package] +publish = false +name = "type_alias_over_more_generic_underlying" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/type_alias_over_more_generic_underlying/old/src/lib.rs b/test_crates/type_alias_over_more_generic_underlying/old/src/lib.rs new file mode 100644 index 000000000..f141436bd --- /dev/null +++ b/test_crates/type_alias_over_more_generic_underlying/old/src/lib.rs @@ -0,0 +1,46 @@ +//! We're going to replace the original type (named like `OriginalType`) with two types: +//! - `pub struct NewType` +//! - `pub type OriginalType = NewType` +//! +//! This is not semver-major, since the type alias has: +//! - the same name +//! - the same fields +//! - the same constructibility and pattern-matching behavior. + +pub struct OriginalStructOnlyPrivateFields { + _marker: std::marker::PhantomData<()>, +} + +pub struct OriginalStructGeneric { + _marker: std::marker::PhantomData, +} + +pub struct OriginalStructMixOfFields { + _marker: std::marker::PhantomData<()>, + pub x: i64, +} + +pub struct OriginalStructConstructible { + pub x: i64, +} + +pub struct OriginalStructEmpty {} + +#[non_exhaustive] +pub struct OriginalStructConstructibleNonexhaustive { + pub x: i64, +} + +#[non_exhaustive] +pub struct OriginalStructEmptyNonexhaustive { + pub x: i64, +} + +// The enum case is interesting: to add a generic parameter, we need to use it somewhere. +// We'll need to add a variant, so the original enum must have been non-exhaustive +// to avoid an immediate major breaking change. + +#[non_exhaustive] +pub enum OriginalEnumNonexhaustive { + First, +}