You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new_without_default lint (indirectly) points at an impl block containing the new() method and suggests something to insert. However because the name is "fully qualified" if you insert the suggested impl Default alongside the impl block, it will not compile.
Stumbled into this today as well. As pointed out by @estebank in this Twitter thread, this is bad because rustc does not suggest a fix for the incorrect path qualification ("I'm ok if you get a suggestion that gets you another suggestion that fixes your code, but if it leads to a dead end I'm not ok with it.").
Not sure if I should open a separate issue at for rustc (it probably already exists, haven't looked extensively).
The issue is most likely a result of code in Clippy. The code for new_without_default calls format!(".. {} ..", ..) on the type, and this is probably the reason why the complete path is prefixed.
A possible solution could be to snip the type part from the original new impl block. Meaning this:
The
new_without_default
lint (indirectly) points at an impl block containing thenew()
method and suggests something to insert. However because the name is "fully qualified" if you insert the suggestedimpl Default
alongside the impl block, it will not compile.I tried this code:
I expected to see this happen:
Instead, this happened (specifically note the qualified
submod::Foo
in the suggested impl):Meta
cargo clippy -V
: clippy 0.1.54 (5c02926 2021-05-11)rustc -Vv
:rustc 1.54.0-nightly (5c02926 2021-05-11)
binary: rustc
commit-hash: 5c02926
commit-date: 2021-05-11
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1
The text was updated successfully, but these errors were encountered: