Skip to content
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

default_trait_access: Fix wrong suggestion #5993

Merged
merged 1 commit into from
Sep 1, 2020

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Aug 31, 2020

#5975 (comment)

I think the underlying problem is clippy suggests code with complete parameters, not clippy triggers this lint even for complex types. AFAIK, If code compiles with Default::default, it doesn't need to specify any parameters, as type inference is working. (So, in this case, default_trait_access should suggest RefCell::default.)

Fixes #5975 Fixes #5990

changelog: default_trait_access: fixed wrong suggestion

@rust-highfive
Copy link

r? @phansch

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 31, 2020
Comment on lines -27 to +35
error: calling `GenericDerivedDefault<std::string::String>::default()` is more clear than this expression
--> $DIR/default_trait_access.rs:28:46
error: calling `GenericDerivedDefault::default()` is more clear than this expression
--> $DIR/default_trait_access.rs:31:46
|
LL | let s11: GenericDerivedDefault<String> = Default::default();
| ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault<std::string::String>::default()`
| ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault::default()`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already had a test for this, but it seems that the broken suggestion was missed.

@phansch
Copy link
Member

phansch commented Sep 1, 2020

@bors r+ thanks!

@bors
Copy link
Collaborator

bors commented Sep 1, 2020

📌 Commit 8b0aa6a has been approved by phansch

@bors
Copy link
Collaborator

bors commented Sep 1, 2020

⌛ Testing commit 8b0aa6a with merge 67e18c2...

@bors
Copy link
Collaborator

bors commented Sep 1, 2020

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: phansch
Pushing 67e18c2 to master...

@bors bors merged commit 67e18c2 into rust-lang:master Sep 1, 2020
@taiki-e taiki-e deleted the default_trait_access branch September 1, 2020 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

default_trait_access suggests invalid syntax default_trait_access should only fire on simple types
5 participants