Closed
Description
Given the following code:
trait Modify {
fn modify(&mut self) ;
}
impl<T> Modify for T {
fn modify(&mut self) {
// ...
}
}
trait Foo {
fn mute(&mut self) {
self.modify();
}
}
The current output is:
self.modify();
^^^^^^^^^^^^^ cannot borrow as mutable
Ideally the output should look like:
the size for values of type `Self` cannot be known at compilation time
add Sized
trait bound and the code compiles successfully:
trait Modify {
fn modify(&mut self) ;
}
impl<T> Modify for T {
fn modify(&mut self) {
// ...
}
}
trait Foo: Sized {
fn mute(&mut self) {
self.modify();
}
}
rust version: rustc 1.58.0 (02072b4 2022-01-11)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.