diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-02 18:36:06 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-02 18:36:06 -0600 |
| commit | 8cdfa445d6629ffef4cb84967ff7017654045bc2 (patch) | |
| tree | 22f0b0907c024c78d26a731e2e1f5219407d8102 /vendor/ref-cast/tests | |
| parent | 4351c74c7c5f97156bc94d3a8549b9940ac80e3f (diff) | |
chore: add vendor directory
Diffstat (limited to 'vendor/ref-cast/tests')
27 files changed, 432 insertions, 0 deletions
diff --git a/vendor/ref-cast/tests/compiletest.rs b/vendor/ref-cast/tests/compiletest.rs new file mode 100644 index 00000000..23a6a065 --- /dev/null +++ b/vendor/ref-cast/tests/compiletest.rs @@ -0,0 +1,7 @@ +#[rustversion::attr(not(nightly), ignore = "requires nightly")] +#[cfg_attr(miri, ignore = "incompatible with miri")] +#[test] +fn ui() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/ui/*.rs"); +} diff --git a/vendor/ref-cast/tests/test_custom.rs b/vendor/ref-cast/tests/test_custom.rs new file mode 100644 index 00000000..73d9bd69 --- /dev/null +++ b/vendor/ref-cast/tests/test_custom.rs @@ -0,0 +1,18 @@ +#[forbid(unsafe_code)] +mod forbid_unsafe { + use ref_cast::{ref_cast_custom, RefCastCustom}; + + #[derive(RefCastCustom)] + #[repr(transparent)] + pub struct Custom(#[allow(dead_code)] str); + + impl Custom { + #[ref_cast_custom] + pub fn new(s: &str) -> &Custom; + } +} + +#[test] +fn test_forbid_unsafe() { + forbid_unsafe::Custom::new("..."); +} diff --git a/vendor/ref-cast/tests/test_trivial.rs b/vendor/ref-cast/tests/test_trivial.rs new file mode 100644 index 00000000..c5ec85ae --- /dev/null +++ b/vendor/ref-cast/tests/test_trivial.rs @@ -0,0 +1,52 @@ +#![allow(clippy::manual_non_exhaustive)] + +use ref_cast::RefCast; +use std::marker::PhantomData; + +type Marker = PhantomData<str>; + +#[derive(RefCast)] +#[repr(transparent)] +pub struct ImplicitUnit { + pub value: usize, + _private: (), +} + +#[derive(RefCast)] +#[repr(transparent)] +pub struct ImplicitPhantomData<T> { + pub value: T, + pub marker: PhantomData<T>, +} + +#[derive(RefCast)] +#[repr(transparent)] +pub struct ExplicitTrivial { + pub value: usize, + #[trivial] + pub marker: Marker, +} + +#[derive(RefCast)] +#[repr(C)] +pub struct Override<U, V> { + #[trivial] + pub first: PhantomData<U>, + pub second: PhantomData<V>, +} + +#[derive(RefCast)] +#[repr(transparent)] +pub struct Unsized<'a> { + pub marker: PhantomData<&'a str>, + pub value: str, +} + +#[test] +fn test_trivial() { + ImplicitUnit::ref_cast(&0); + ImplicitPhantomData::ref_cast(&0); + ExplicitTrivial::ref_cast(&0); + Override::<u8, i8>::ref_cast(&PhantomData::<i8>); + Unsized::ref_cast("..."); +} diff --git a/vendor/ref-cast/tests/ui/cross-crate.rs b/vendor/ref-cast/tests/ui/cross-crate.rs new file mode 100644 index 00000000..7368b3d0 --- /dev/null +++ b/vendor/ref-cast/tests/ui/cross-crate.rs @@ -0,0 +1,10 @@ +use ref_cast::ref_cast_custom; +use ref_cast_test_suite::Struct; + +#[ref_cast_custom] +fn ref_cast(s: &str) -> &Struct; + +#[ref_cast_custom] +fn ref_cast_mut(s: &mut str) -> &mut Struct; + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/cross-crate.stderr b/vendor/ref-cast/tests/ui/cross-crate.stderr new file mode 100644 index 00000000..7de06292 --- /dev/null +++ b/vendor/ref-cast/tests/ui/cross-crate.stderr @@ -0,0 +1,11 @@ +error[E0639]: cannot create non-exhaustive struct using struct expression + --> tests/ui/cross-crate.rs:5:32 + | +5 | fn ref_cast(s: &str) -> &Struct; + | ^ + +error[E0639]: cannot create non-exhaustive struct using struct expression + --> tests/ui/cross-crate.rs:8:44 + | +8 | fn ref_cast_mut(s: &mut str) -> &mut Struct; + | ^ diff --git a/vendor/ref-cast/tests/ui/dst-before-trivial.rs b/vendor/ref-cast/tests/ui/dst-before-trivial.rs new file mode 100644 index 00000000..df294f54 --- /dev/null +++ b/vendor/ref-cast/tests/ui/dst-before-trivial.rs @@ -0,0 +1,12 @@ +use ref_cast::RefCast; +use std::marker::PhantomData; + +#[derive(RefCast)] +#[repr(transparent)] +struct Bytes<'arena> { + bytes: [u8], + #[trivial] + marker: PhantomData<&'arena ()>, +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/dst-before-trivial.stderr b/vendor/ref-cast/tests/ui/dst-before-trivial.stderr new file mode 100644 index 00000000..f5e8d4e9 --- /dev/null +++ b/vendor/ref-cast/tests/ui/dst-before-trivial.stderr @@ -0,0 +1,17 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> tests/ui/dst-before-trivial.rs:7:12 + | +7 | bytes: [u8], + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: only the last field of a struct may have a dynamically sized type + = help: change the field's type to have a statically known size +help: borrowed types always have a statically known size + | +7 | bytes: &[u8], + | + +help: the `Box` type always has a statically known size and allocates its contents in the heap + | +7 | bytes: Box<[u8]>, + | ++++ + diff --git a/vendor/ref-cast/tests/ui/extra-arg.rs b/vendor/ref-cast/tests/ui/extra-arg.rs new file mode 100644 index 00000000..a23eff2b --- /dev/null +++ b/vendor/ref-cast/tests/ui/extra-arg.rs @@ -0,0 +1,12 @@ +use ref_cast::{ref_cast_custom, RefCastCustom}; + +#[derive(RefCastCustom)] +#[repr(transparent)] +pub struct Thing(String); + +impl Thing { + #[ref_cast_custom] + pub fn ref_cast(s: &String, wat: i32) -> &Self; +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/extra-arg.stderr b/vendor/ref-cast/tests/ui/extra-arg.stderr new file mode 100644 index 00000000..4676d50d --- /dev/null +++ b/vendor/ref-cast/tests/ui/extra-arg.stderr @@ -0,0 +1,13 @@ +error: ref_cast_custom function is required to have a single argument + --> tests/ui/extra-arg.rs:9:33 + | +9 | pub fn ref_cast(s: &String, wat: i32) -> &Self; + | ^^^^^^^^ + +error: associated function in `impl` without body + --> tests/ui/extra-arg.rs:9:5 + | +9 | pub fn ref_cast(s: &String, wat: i32) -> &Self; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the function: `{ <body> }` diff --git a/vendor/ref-cast/tests/ui/function-body.rs b/vendor/ref-cast/tests/ui/function-body.rs new file mode 100644 index 00000000..915044a8 --- /dev/null +++ b/vendor/ref-cast/tests/ui/function-body.rs @@ -0,0 +1,12 @@ +use ref_cast::{ref_cast_custom, RefCastCustom}; + +#[derive(RefCastCustom)] +#[repr(transparent)] +pub struct Thing(String); + +impl Thing { + #[ref_cast_custom] + pub fn ref_cast(s: &String) -> &Self {} +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/function-body.stderr b/vendor/ref-cast/tests/ui/function-body.stderr new file mode 100644 index 00000000..3161d334 --- /dev/null +++ b/vendor/ref-cast/tests/ui/function-body.stderr @@ -0,0 +1,13 @@ +error: expected `;` + --> tests/ui/function-body.rs:9:42 + | +9 | pub fn ref_cast(s: &String) -> &Self {} + | ^ + +error[E0308]: mismatched types + --> tests/ui/function-body.rs:9:36 + | +9 | pub fn ref_cast(s: &String) -> &Self {} + | -------- ^^^^^ expected `&Thing`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression diff --git a/vendor/ref-cast/tests/ui/impl-trait.rs b/vendor/ref-cast/tests/ui/impl-trait.rs new file mode 100644 index 00000000..ee3777b4 --- /dev/null +++ b/vendor/ref-cast/tests/ui/impl-trait.rs @@ -0,0 +1,15 @@ +use ref_cast::{ref_cast_custom, RefCastCustom}; + +#[derive(RefCastCustom)] +#[repr(transparent)] +pub struct Thing(str); + +impl Thing { + #[ref_cast_custom] + pub fn ref_cast(s: impl AsRef<str>) -> &Self; + + #[ref_cast_custom] + pub fn ref_cast2(s: &impl AsRef<str>) -> &Self; +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/impl-trait.stderr b/vendor/ref-cast/tests/ui/impl-trait.stderr new file mode 100644 index 00000000..e22076a6 --- /dev/null +++ b/vendor/ref-cast/tests/ui/impl-trait.stderr @@ -0,0 +1,31 @@ +error[E0106]: missing lifetime specifier + --> tests/ui/impl-trait.rs:9:44 + | +9 | pub fn ref_cast(s: impl AsRef<str>) -> &Self; + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` + | +9 | pub fn ref_cast(s: impl AsRef<str>) -> &'static Self; + | +++++++ +help: consider introducing a named lifetime parameter + | +9 | pub fn ref_cast<'a>(s: impl AsRef<str>) -> &'a Self; + | ++++ ++ + +error[E0562]: `impl Trait` is not allowed in paths + --> tests/ui/impl-trait.rs:9:24 + | +9 | pub fn ref_cast(s: impl AsRef<str>) -> &Self; + | ^^^^^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error[E0562]: `impl Trait` is not allowed in paths + --> tests/ui/impl-trait.rs:12:26 + | +12 | pub fn ref_cast2(s: &impl AsRef<str>) -> &Self; + | ^^^^^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods diff --git a/vendor/ref-cast/tests/ui/no-custom.rs b/vendor/ref-cast/tests/ui/no-custom.rs new file mode 100644 index 00000000..116b197c --- /dev/null +++ b/vendor/ref-cast/tests/ui/no-custom.rs @@ -0,0 +1,11 @@ +use ref_cast::ref_cast_custom; + +#[repr(transparent)] +pub struct Thing(String); + +impl Thing { + #[ref_cast_custom] + pub fn ref_cast(s: &String) -> &Self; +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/no-custom.stderr b/vendor/ref-cast/tests/ui/no-custom.stderr new file mode 100644 index 00000000..38269be3 --- /dev/null +++ b/vendor/ref-cast/tests/ui/no-custom.stderr @@ -0,0 +1,35 @@ +error[E0277]: the trait bound `&Thing: ref_cast::custom::RefCastOkay<&String>` is not satisfied + --> tests/ui/no-custom.rs:8:36 + | +8 | pub fn ref_cast(s: &String) -> &Self; + | ^^^^^ the trait `RefCastCustom<String>` is not implemented for `Thing` + | + = help: the following other types implement trait `ref_cast::custom::RefCastOkay<From>`: + `&'a To` implements `ref_cast::custom::RefCastOkay<&'a From>` + `&'a mut To` implements `ref_cast::custom::RefCastOkay<&'a mut From>` + = note: required for `&Thing` to implement `ref_cast::custom::RefCastOkay<&String>` +note: required by a bound in `ref_cast_custom` + --> src/custom.rs + | + | pub fn ref_cast_custom<From, To>(_arg: From) + | --------------- required by a bound in this function + | where + | To: RefCastOkay<From>, + | ^^^^^^^^^^^^^^^^^ required by this bound in `ref_cast_custom` + +error[E0071]: expected struct, variant or union type, found inferred type + --> tests/ui/no-custom.rs:8:41 + | +8 | pub fn ref_cast(s: &String) -> &Self; + | ^ not a struct + +error[E0277]: the trait bound `Thing: RefCastCustom<String>` is not satisfied + --> tests/ui/no-custom.rs:8:41 + | +8 | pub fn ref_cast(s: &String) -> &Self; + | ^ the trait `RefCastCustom<String>` is not implemented for `Thing` + | + = help: the following other types implement trait `ref_cast::custom::RefCastOkay<From>`: + `&'a To` implements `ref_cast::custom::RefCastOkay<&'a From>` + `&'a mut To` implements `ref_cast::custom::RefCastOkay<&'a mut From>` + = note: required for `&Thing` to implement `ref_cast::custom::RefCastOkay<&String>` diff --git a/vendor/ref-cast/tests/ui/no-repr.rs b/vendor/ref-cast/tests/ui/no-repr.rs new file mode 100644 index 00000000..65398da0 --- /dev/null +++ b/vendor/ref-cast/tests/ui/no-repr.rs @@ -0,0 +1,8 @@ +use ref_cast::RefCast; + +#[derive(RefCast)] +struct Test { + s: String, +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/no-repr.stderr b/vendor/ref-cast/tests/ui/no-repr.stderr new file mode 100644 index 00000000..3fcc2d2e --- /dev/null +++ b/vendor/ref-cast/tests/ui/no-repr.stderr @@ -0,0 +1,7 @@ +error: RefCast trait requires #[repr(transparent)] + --> tests/ui/no-repr.rs:3:10 + | +3 | #[derive(RefCast)] + | ^^^^^^^ + | + = note: this error originates in the derive macro `RefCast` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/vendor/ref-cast/tests/ui/not-trivial.rs b/vendor/ref-cast/tests/ui/not-trivial.rs new file mode 100644 index 00000000..292f282c --- /dev/null +++ b/vendor/ref-cast/tests/ui/not-trivial.rs @@ -0,0 +1,11 @@ +use ref_cast::RefCast; + +#[derive(RefCast)] +#[repr(C)] +struct Test { + one: String, + #[trivial] + two: String, +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/not-trivial.stderr b/vendor/ref-cast/tests/ui/not-trivial.stderr new file mode 100644 index 00000000..9983cdc9 --- /dev/null +++ b/vendor/ref-cast/tests/ui/not-trivial.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `String: ref_cast::trivial::Trivial` is not satisfied + --> tests/ui/not-trivial.rs:8:10 + | +8 | two: String, + | ^^^^^^ the trait `ref_cast::trivial::Trivial` is not implemented for `String` + | + = help: the following other types implement trait `ref_cast::trivial::Trivial`: + () + PhantomData<T> + PhantomPinned +note: required by a bound in `assert_trivial` + --> src/trivial.rs + | + | pub fn assert_trivial<T: Trivial>() {} + | ^^^^^^^ required by this bound in `assert_trivial` diff --git a/vendor/ref-cast/tests/ui/private.rs b/vendor/ref-cast/tests/ui/private.rs new file mode 100644 index 00000000..4c222a07 --- /dev/null +++ b/vendor/ref-cast/tests/ui/private.rs @@ -0,0 +1,19 @@ +use ref_cast::{ref_cast_custom, RefCast, RefCastCustom}; + +#[derive(RefCast, RefCastCustom)] +#[repr(transparent)] +pub struct Public { + private: Private, +} + +struct Private; + +impl Public { + #[ref_cast_custom] + fn ref_cast(private: &Private) -> &Public; + + #[ref_cast_custom] + fn ref_cast_mut(private: &mut Private) -> &mut Public; +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/private.stderr b/vendor/ref-cast/tests/ui/private.stderr new file mode 100644 index 00000000..732b31c5 --- /dev/null +++ b/vendor/ref-cast/tests/ui/private.stderr @@ -0,0 +1,10 @@ +error[E0446]: private type `Private` in public interface + --> tests/ui/private.rs:3:10 + | +3 | #[derive(RefCast, RefCastCustom)] + | ^^^^^^^ can't leak private type +... +9 | struct Private; + | -------------- `Private` declared as private + | + = note: this error originates in the derive macro `RefCast` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/vendor/ref-cast/tests/ui/repr-align.rs b/vendor/ref-cast/tests/ui/repr-align.rs new file mode 100644 index 00000000..3b4ff4ae --- /dev/null +++ b/vendor/ref-cast/tests/ui/repr-align.rs @@ -0,0 +1,9 @@ +use ref_cast::RefCast; + +#[derive(RefCast)] +#[repr(align(2), C, align = "2")] +struct Test { + s: String, +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/repr-align.stderr b/vendor/ref-cast/tests/ui/repr-align.stderr new file mode 100644 index 00000000..64e388a3 --- /dev/null +++ b/vendor/ref-cast/tests/ui/repr-align.stderr @@ -0,0 +1,17 @@ +error: aligned repr on struct that implements RefCast is not supported + --> tests/ui/repr-align.rs:4:8 + | +4 | #[repr(align(2), C, align = "2")] + | ^^^^^^^^ + +error: aligned repr on struct that implements RefCast is not supported + --> tests/ui/repr-align.rs:4:21 + | +4 | #[repr(align(2), C, align = "2")] + | ^^^^^^^^^^^ + +error[E0693]: incorrect `repr(align)` attribute format + --> tests/ui/repr-align.rs:4:21 + | +4 | #[repr(align(2), C, align = "2")] + | ^^^^^^^^^^^ help: use parentheses instead: `align(2)` diff --git a/vendor/ref-cast/tests/ui/short-lifetime.rs b/vendor/ref-cast/tests/ui/short-lifetime.rs new file mode 100644 index 00000000..83783c39 --- /dev/null +++ b/vendor/ref-cast/tests/ui/short-lifetime.rs @@ -0,0 +1,12 @@ +use ref_cast::{ref_cast_custom, RefCastCustom}; + +#[derive(RefCastCustom)] +#[repr(transparent)] +pub struct Thing(String); + +impl Thing { + #[ref_cast_custom] + pub fn ref_cast<'a>(s: &String) -> &'a Self; +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/short-lifetime.stderr b/vendor/ref-cast/tests/ui/short-lifetime.stderr new file mode 100644 index 00000000..d3bfde1e --- /dev/null +++ b/vendor/ref-cast/tests/ui/short-lifetime.stderr @@ -0,0 +1,7 @@ +error[E0621]: explicit lifetime required in the type of `s` + --> tests/ui/short-lifetime.rs:9:48 + | +9 | pub fn ref_cast<'a>(s: &String) -> &'a Self; + | ------- ^ lifetime `'a` required + | | + | help: add explicit lifetime `'a` to the type of `s`: `&'a String` diff --git a/vendor/ref-cast/tests/ui/unrecognized-repr.rs b/vendor/ref-cast/tests/ui/unrecognized-repr.rs new file mode 100644 index 00000000..f74e0dc2 --- /dev/null +++ b/vendor/ref-cast/tests/ui/unrecognized-repr.rs @@ -0,0 +1,9 @@ +use ref_cast::RefCast; + +#[derive(RefCast)] +#[repr(packed, C, usize, usize(0), usize = "0")] +struct Test { + s: String, +} + +fn main() {} diff --git a/vendor/ref-cast/tests/ui/unrecognized-repr.stderr b/vendor/ref-cast/tests/ui/unrecognized-repr.stderr new file mode 100644 index 00000000..ae5f2c15 --- /dev/null +++ b/vendor/ref-cast/tests/ui/unrecognized-repr.stderr @@ -0,0 +1,39 @@ +error: unrecognized repr on struct that implements RefCast + --> tests/ui/unrecognized-repr.rs:4:19 + | +4 | #[repr(packed, C, usize, usize(0), usize = "0")] + | ^^^^^ + +error: unrecognized repr on struct that implements RefCast + --> tests/ui/unrecognized-repr.rs:4:26 + | +4 | #[repr(packed, C, usize, usize(0), usize = "0")] + | ^^^^^^^^ + +error: unrecognized repr on struct that implements RefCast + --> tests/ui/unrecognized-repr.rs:4:36 + | +4 | #[repr(packed, C, usize, usize(0), usize = "0")] + | ^^^^^^^^^^^ + +error[E0552]: invalid representation hint: `usize` does not take a parenthesized argument list + --> tests/ui/unrecognized-repr.rs:4:26 + | +4 | #[repr(packed, C, usize, usize(0), usize = "0")] + | ^^^^^^^^ + +error[E0552]: invalid representation hint: `usize` does not take a value + --> tests/ui/unrecognized-repr.rs:4:36 + | +4 | #[repr(packed, C, usize, usize(0), usize = "0")] + | ^^^^^^^^^^^ + +error[E0517]: attribute should be applied to an enum + --> tests/ui/unrecognized-repr.rs:4:19 + | +4 | #[repr(packed, C, usize, usize(0), usize = "0")] + | ^^^^^ +5 | / struct Test { +6 | | s: String, +7 | | } + | |_- not an enum |
