-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Invalid dyn
suggestions
#88113
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
Comments
There seems to be two issues here. Duplicate diagnostic causes extra brackets.use std::fmt;
#[derive(Debug)]
pub struct Foo;
impl fmt::Display for Foo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<fmt::Debug>::fmt(self, f) // bare_trait_objects
}
} The above will trigger two warnings for Transition from associated trait path to qualified path requires type parameterstrait Foo<T> {}
impl<T> dyn Foo<T> {
fn hi(_x: T) {}
}
fn main() {
Foo::hi(123); // bare_trait_objects
} Here, the suggestion wants to fix it to |
The first case doesn't seem to be a case of doubly-applied suggestions: rust/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs Lines 936 to 941 in 6cfa773
Changing the
|
I've split the |
I'll note that the error that is reported if you apply the
|
Triage:
Consider the above solved, as the suggestion is now more targeted.
Applying the suggestion results in
Changing This is the same situation we originally had. I consider two "hops" of suggestions resulting in working code to be fairly good. Better if it is in a single "hop", but that's not always possible (otherwise we'd have to teach the parser to typeck, for example). To fix that suggestion, we need to modify this bit of code rust/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs Lines 48 to 57 in f617130
to check that |
In a small crater run for the 2021 edition migrations, a few problems turned up with the suggestions we give for missing
dyn
keywords:Trait::thing
to<dyn Trait>::thing
without generic args:<Trait>::..
to<<dyn Trait>>::..
: https://crater-reports.s3.amazonaws.com/pr-87190-2/try%23d8627d19850b63702b76089d7b055730e9ddca14/reg/extended-primitives-0.3.5/log.txtThe text was updated successfully, but these errors were encountered: