mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
Remove a false statement from Unsize docs, add a test
This commit is contained in:
parent
50be229640
commit
6af30ec720
@ -158,7 +158,6 @@ pub trait Sized {
|
||||
/// - Types implementing a trait `Trait` also implement `Unsize<dyn Trait>`.
|
||||
/// - Structs `Foo<..., T, ...>` implement `Unsize<Foo<..., U, ...>>` if all of these conditions
|
||||
/// are met:
|
||||
/// - `T: Unsize<U>`.
|
||||
/// - Only the last field of `Foo` has a type involving `T`.
|
||||
/// - `Bar<T>: Unsize<Bar<U>>`, where `Bar<T>` stands for the actual type of that last field.
|
||||
///
|
||||
|
29
tests/ui/unsized/unsize-coerce-multiple-adt-params.rs
Normal file
29
tests/ui/unsized/unsize-coerce-multiple-adt-params.rs
Normal file
@ -0,0 +1,29 @@
|
||||
// check-pass
|
||||
|
||||
struct Foo<T, U>
|
||||
where
|
||||
(T, U): Trait,
|
||||
{
|
||||
f: <(T, U) as Trait>::Assoc,
|
||||
}
|
||||
|
||||
trait Trait {
|
||||
type Assoc: ?Sized;
|
||||
}
|
||||
|
||||
struct Count<const N: usize>;
|
||||
|
||||
impl<const N: usize> Trait for (i32, Count<N>) {
|
||||
type Assoc = [(); N];
|
||||
}
|
||||
|
||||
impl<'a> Trait for (u32, ()) {
|
||||
type Assoc = [()];
|
||||
}
|
||||
|
||||
// Test that we can unsize several trait params in creative ways.
|
||||
fn unsize<const N: usize>(x: &Foo<i32, Count<N>>) -> &Foo<u32, ()> {
|
||||
x
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user