Skip to content

Commit 03b089d

Browse files
committed
Rollup merge of #48210 - jacob-hughes:clarify_sized_trait_in_api_docs, r=QuietMisdreavus
Clarified why `Sized` bound not implicit on trait's implicit `Self` type. This part of the documentation was a little confusing to me on first read. I've added a couple lines for further explanation. Hopefully this makes things a bit clearer for new readers.
2 parents ce89c3d + 38064a9 commit 03b089d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/libcore/marker.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ impl<T: ?Sized> !Send for *mut T { }
6363
/// struct BarUse(Bar<[i32]>); // OK
6464
/// ```
6565
///
66-
/// The one exception is the implicit `Self` type of a trait, which does not
67-
/// get an implicit `Sized` bound. This is because a `Sized` bound prevents
68-
/// the trait from being used to form a [trait object]:
66+
/// The one exception is the implicit `Self` type of a trait. A trait does not
67+
/// have an implicit `Sized` bound as this is incompatible with [trait object]s
68+
/// where, by definition, the trait needs to work with all possible implementors,
69+
/// and thus could be any size.
70+
///
71+
/// Although Rust will let you bind `Sized` to a trait, you won't
72+
/// be able to use it to form a trait object later:
6973
///
7074
/// ```
7175
/// # #![allow(unused_variables)]

0 commit comments

Comments
 (0)