Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+7
View File
@@ -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");
}
+18
View File
@@ -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("...");
}
+52
View File
@@ -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("...");
}
+10
View File
@@ -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() {}
@@ -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;
| ^
@@ -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() {}
@@ -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]>,
| ++++ +
+12
View File
@@ -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() {}
+13
View File
@@ -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> }`
+12
View File
@@ -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() {}
@@ -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
+15
View File
@@ -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() {}
@@ -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
+11
View File
@@ -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() {}
+67
View File
@@ -0,0 +1,67 @@
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;
| ^^^^^ unsatisfied trait bound
|
help: the trait `ref_cast::__private25::RefCastCustom<String>` is not implemented for `Thing`
--> tests/ui/no-custom.rs:4:1
|
4 | pub struct Thing(String);
| ^^^^^^^^^^^^^^^^
help: the following other types implement trait `ref_cast::custom::RefCastOkay<From>`
--> src/custom.rs
|
| / unsafe impl<'a, From, To> RefCastOkay<&'a From> for &'a To
| | where
| | From: ?Sized,
| | To: ?Sized + RefCastCustom<From>,
| |_____________________________________^ `&'a To` implements `ref_cast::custom::RefCastOkay<&'a From>`
...
| / unsafe impl<'a, From, To> RefCastOkay<&'a mut From> for &'a mut To
| | where
| | From: ?Sized,
| | To: ?Sized + RefCastCustom<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::__private25::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: ref_cast::__private25::RefCastCustom<String>` is not satisfied
--> tests/ui/no-custom.rs:8:41
|
8 | pub fn ref_cast(s: &String) -> &Self;
| ^ unsatisfied trait bound
|
help: the trait `ref_cast::__private25::RefCastCustom<String>` is not implemented for `Thing`
--> tests/ui/no-custom.rs:4:1
|
4 | pub struct Thing(String);
| ^^^^^^^^^^^^^^^^
help: the following other types implement trait `ref_cast::custom::RefCastOkay<From>`
--> src/custom.rs
|
| / unsafe impl<'a, From, To> RefCastOkay<&'a From> for &'a To
| | where
| | From: ?Sized,
| | To: ?Sized + RefCastCustom<From>,
| |_____________________________________^ `&'a To` implements `ref_cast::custom::RefCastOkay<&'a From>`
...
| / unsafe impl<'a, From, To> RefCastOkay<&'a mut From> for &'a mut To
| | where
| | From: ?Sized,
| | To: ?Sized + RefCastCustom<From>,
| |_____________________________________^ `&'a mut To` implements `ref_cast::custom::RefCastOkay<&'a mut From>`
= note: required for `&Thing` to implement `ref_cast::custom::RefCastOkay<&String>`
+8
View File
@@ -0,0 +1,8 @@
use ref_cast::RefCast;
#[derive(RefCast)]
struct Test {
s: String,
}
fn main() {}
+7
View File
@@ -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)
+11
View File
@@ -0,0 +1,11 @@
use ref_cast::RefCast;
#[derive(RefCast)]
#[repr(C)]
struct Test {
one: String,
#[trivial]
two: String,
}
fn main() {}
@@ -0,0 +1,21 @@
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`
--> src/trivial.rs
|
| impl Trivial for () {}
| ^^^^^^^^^^^^^^^^^^^ `()`
| impl<T: ?Sized> Trivial for PhantomData<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `PhantomData<T>`
...
| impl Trivial for PhantomPinned {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `PhantomPinned`
note: required by a bound in `ref_cast::__private25::assert_trivial`
--> src/trivial.rs
|
| pub fn assert_trivial<T: Trivial>() {}
| ^^^^^^^ required by this bound in `assert_trivial`
+19
View File
@@ -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() {}
+10
View File
@@ -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)
+9
View File
@@ -0,0 +1,9 @@
use ref_cast::RefCast;
#[derive(RefCast)]
#[repr(align(2), C, align = "2")]
struct Test {
s: String,
}
fn main() {}
@@ -0,0 +1,21 @@
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[E0539]: malformed `repr` attribute input
--> tests/ui/repr-align.rs:4:1
|
4 | #[repr(align(2), C, align = "2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^-----^^
| |
| expected this to be a list
|
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
@@ -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() {}
@@ -0,0 +1,10 @@
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`
|
9 | pub fn ref_cast<'a>(s: &'a String) -> &'a Self;
| ++
@@ -0,0 +1,9 @@
use ref_cast::RefCast;
#[derive(RefCast)]
#[repr(packed, C, usize, usize(0), usize = "0")]
struct Test {
s: String,
}
fn main() {}
@@ -0,0 +1,45 @@
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: `#[repr(usize)]` attribute cannot be used on structs
--> tests/ui/unrecognized-repr.rs:4:1
|
4 | #[repr(packed, C, usize, usize(0), usize = "0")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: `#[repr(usize)]` can only be applied to enums
error[E0565]: malformed `repr` attribute input
--> tests/ui/unrecognized-repr.rs:4:1
|
4 | #[repr(packed, C, usize, usize(0), usize = "0")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^^^^^^^^^^^^^
| |
| didn't expect any arguments here
|
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
error[E0565]: malformed `repr` attribute input
--> tests/ui/unrecognized-repr.rs:4:1
|
4 | #[repr(packed, C, usize, usize(0), usize = "0")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----^^
| |
| didn't expect any arguments here
|
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>