Closed
Description
There are not a lot of those around, according to a quick grep. The vast majority are in core::ptr. Anyways, in e.g. core::ptr
, there is:
impl<T: ?Sized> *mut T {
...
pub unsafe fn offset(self, count: isize) -> *const T where T: Sized {
intrinsics::offset(self, count)
}
....
}
Note that the impl has a T: ?Sized
bound, but the offset method has an additional T: Sized
bound.
But the corresponding doc says nothing about that bound:
https://doc.rust-lang.org/std/primitive.pointer.html#method.offset-1
which ends up being misleading, since the only bound shown on the page is T: ?Sized
.
I hit a surprising
14 | if ptr.is_null() {
| ^^^^^^^ `T` does not have a constant size known at compile-time
|
= help: the trait `core::marker::Sized` is not implemented for `T`
= help: consider adding a `where T: core::marker::Sized` bound
because of that discrepancy (but didn't pick is_null
above because it changed in beta/nightly, it doesn't have the T: Sized
bound anymore ; offset still does)
Metadata
Metadata
Assignees
Labels
No labels