Skip to content

Commit 6af30ec

Browse files
Remove a false statement from Unsize docs, add a test
1 parent 50be229 commit 6af30ec

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

library/core/src/marker.rs

-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ pub trait Sized {
158158
/// - Types implementing a trait `Trait` also implement `Unsize<dyn Trait>`.
159159
/// - Structs `Foo<..., T, ...>` implement `Unsize<Foo<..., U, ...>>` if all of these conditions
160160
/// are met:
161-
/// - `T: Unsize<U>`.
162161
/// - Only the last field of `Foo` has a type involving `T`.
163162
/// - `Bar<T>: Unsize<Bar<U>>`, where `Bar<T>` stands for the actual type of that last field.
164163
///
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// check-pass
2+
3+
struct Foo<T, U>
4+
where
5+
(T, U): Trait,
6+
{
7+
f: <(T, U) as Trait>::Assoc,
8+
}
9+
10+
trait Trait {
11+
type Assoc: ?Sized;
12+
}
13+
14+
struct Count<const N: usize>;
15+
16+
impl<const N: usize> Trait for (i32, Count<N>) {
17+
type Assoc = [(); N];
18+
}
19+
20+
impl<'a> Trait for (u32, ()) {
21+
type Assoc = [()];
22+
}
23+
24+
// Test that we can unsize several trait params in creative ways.
25+
fn unsize<const N: usize>(x: &Foo<i32, Count<N>>) -> &Foo<u32, ()> {
26+
x
27+
}
28+
29+
fn main() {}

0 commit comments

Comments
 (0)