Skip to content

Commit 2e86485

Browse files
committed
Auto merge of #29140 - sorear:dst-document-on-sized, r=alexcrichton
This is for discoverability. If someone wants to know what `?Sized` means, then Sized will be the only keyword they can use to search; so even though this is technically a language matter, it makes sense to document it where it will be looked for.
2 parents 7275d3d + dc61d0f commit 2e86485

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libcore/marker.rs

+11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ impl<T> !Send for *const T { }
3636
impl<T> !Send for *mut T { }
3737

3838
/// Types with a constant size known at compile-time.
39+
///
40+
/// All type parameters which can be bounded have an implicit bound of `Sized`. The special syntax
41+
/// `?Sized` can be used to remove this bound if it is not appropriate.
42+
///
43+
/// ```
44+
/// struct Foo<T>(T);
45+
/// struct Bar<T: ?Sized>(T);
46+
///
47+
/// // struct FooUse(Foo<[i32]>); // error: Sized is not implemented for [i32]
48+
/// struct BarUse(Bar<[i32]>); // OK
49+
/// ```
3950
#[stable(feature = "rust1", since = "1.0.0")]
4051
#[lang = "sized"]
4152
#[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"]

0 commit comments

Comments
 (0)