-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misleading note message while trying to use a not object safe method on a trait object #103622
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
weiznich
added
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Oct 27, 2022
MRE (playground): struct Type;
pub trait Trait {
fn function(&mut self) where Self: Sized;
}
impl Trait for Type {
fn function(&mut self) {}
}
fn main() {
(&mut Type as &mut dyn Trait).function();
}
|
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this issue
Dec 13, 2022
Illegal sized bounds: only suggest mutability change if needed In a scenario like ```rust struct Type; pub trait Trait { fn function(&mut self) where Self: Sized; } impl Trait for Type { fn function(&mut self) {} } fn main() { (&mut Type as &mut dyn Trait).function(); } ``` the problem is Sized, not the mutability of self. Thus don't emit the "you need &T instead of &mut T" note, or the other way around, as all it does is just invert the mutability of whatever was supplied. Fixes rust-lang#103622.
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this issue
Dec 13, 2022
Illegal sized bounds: only suggest mutability change if needed In a scenario like ```rust struct Type; pub trait Trait { fn function(&mut self) where Self: Sized; } impl Trait for Type { fn function(&mut self) {} } fn main() { (&mut Type as &mut dyn Trait).function(); } ``` the problem is Sized, not the mutability of self. Thus don't emit the "you need &T instead of &mut T" note, or the other way around, as all it does is just invert the mutability of whatever was supplied. Fixes rust-lang#103622.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Dec 14, 2022
Illegal sized bounds: only suggest mutability change if needed In a scenario like ```rust struct Type; pub trait Trait { fn function(&mut self) where Self: Sized; } impl Trait for Type { fn function(&mut self) {} } fn main() { (&mut Type as &mut dyn Trait).function(); } ``` the problem is Sized, not the mutability of self. Thus don't emit the "you need &T instead of &mut T" note, or the other way around, as all it does is just invert the mutability of whatever was supplied. Fixes rust-lang#103622.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code: Playground
The current output is:
Ideally the output should not include a not telling me to use
&dyn PgMetadataLookup
instead of a&mut dyn PgMetadataLookup
as this is misleading. In addition following this suggestion only changes the note of the error message such that it now says "note: you need&mut dyn PgMetadataLookup
instead of&dyn PgMetadataLookup
" which is also wrong.The text was updated successfully, but these errors were encountered: