-
Notifications
You must be signed in to change notification settings - Fork 539
Labels
A-typesArea: TypesArea: TypesLanguage CleanupImprovements to existing language which is correct but not clear, or missing examples, or the like.Improvements to existing language which is correct but not clear, or missing examples, or the like.
Description
In the Object Safety section, it says:
- Explicitly non-dispatchable functions require:
- Have a
where Self: Sized
bound (receiver type ofSelf
(i.e.self
) implies this).
This implies that if you have any associated function with receiver of self
should be counted as non-dispatchable function. However, it is not the case. See the following code:
trait Foo {
fn a(self);
// fn b(self, x: &Self);
// fn c(self) -> Self;
}
fn test() -> Box<dyn Foo> { todo!() }
Uncommenting b
or c
would make the code fail to compile, unless explicit where Self: Sized
is added, but the rule in the reference indicates that having a receiver self
already implies that bound exists.
Not sure whether it's something that should be fixed in the reference or the compiler.
uamrws, zzhaolei and steffahnuamrws
Metadata
Metadata
Assignees
Labels
A-typesArea: TypesArea: TypesLanguage CleanupImprovements to existing language which is correct but not clear, or missing examples, or the like.Improvements to existing language which is correct but not clear, or missing examples, or the like.