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

Do not suggest to derive Default on generics with implicit arguments #10399

Merged
merged 1 commit into from
Feb 27, 2023

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Feb 25, 2023

Fixes #10396

changelog: FP: [derivable_impls]: do not suggest to derive Default on generics with implicit arguments

@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2023

r? @Manishearth

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 25, 2023
@samueltardieu samueltardieu changed the title Do not suggest to derive Default on generics with implicit arguments Do not suggest to derive Default on generics with implicit arguments Feb 25, 2023
Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

looks good, needs a rebase

}
if let Some(PathSegment { args, .. }) = p.segments.last() {
let args = args.map(|a| a.args).unwrap_or(&[]);
if substs.len() != args.len() || args.iter().any(|arg| !matches!(arg, GenericArg::Lifetime(_))) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: comment explaining what this is checking (and why checking against substs solves the problem)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do while rebasing.

Copy link
Member

Choose a reason for hiding this comment

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

This hasn't addressed my parenthetical:

Please make it clear why substs.len() != args.len() is sufficient to check that if there are defaults involved, so someone reading this code without a clear idea of substs can still understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully this is better now.

@bors
Copy link
Contributor

bors commented Feb 26, 2023

☔ The latest upstream changes (presumably #10401) made this pull request unmergeable. Please resolve the merge conflicts.

@samueltardieu
Copy link
Contributor Author

looks good, needs a rebase

Done.

@samueltardieu samueltardieu force-pushed the issue-10396 branch 2 times, most recently from 8a08279 to f7042b5 Compare February 26, 2023 02:17
@samueltardieu
Copy link
Contributor Author

(noticed a typo in the explanation and fixed it)

@Manishearth
Copy link
Member

@bors r+

thanks for working on this!

@bors
Copy link
Contributor

bors commented Feb 27, 2023

📌 Commit c82ff00 has been approved by Manishearth

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 27, 2023

⌛ Testing commit c82ff00 with merge 2742ac0...

@bors
Copy link
Contributor

bors commented Feb 27, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Manishearth
Pushing 2742ac0 to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Feb 27, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Manishearth
Pushing 2742ac0 to master...

@bors bors merged commit 2742ac0 into rust-lang:master Feb 27, 2023
@samueltardieu samueltardieu deleted the issue-10396 branch March 5, 2023 19:18
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.

False positive derivable_impls for type parameters with defaults
4 participants