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

clippy fixes for librustdoc #80546

Merged
merged 1 commit into from
Jan 2, 2021
Merged

Conversation

matthiaskrgr
Copy link
Member

fixes clippy warnings of type:
match_like_matches_macro
or_fun_call
op_ref
needless_return
let_and_return
single_char_add_str
useless_format
unnecessary_sort_by
match_ref_pats
redundant_field_names

@rust-highfive
Copy link
Collaborator

Some changes occurred in intra-doc-links.

cc @jyn514

@rust-highfive
Copy link
Collaborator

r? @ollie27

(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 Dec 31, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 31, 2020

r? @jyn514

@rust-highfive rust-highfive assigned jyn514 and unassigned ollie27 Dec 31, 2020
src/librustdoc/clean/cfg.rs Outdated Show resolved Hide resolved
Cfg::Cfg(..) => true,
_ => false,
},
Cfg::Not(ref child) => matches!(**child, Cfg::Cfg(..)),
Copy link
Member

Choose a reason for hiding this comment

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

Can you match on this in Cfg::Not directly instead of having two nested matches?

Copy link
Member Author

Choose a reason for hiding this comment

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

Cfg::Not contains a Box<Cfg>, I'm not sure how to match on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cfg::Not(box Cfg::Cfg(..))

Copy link
Member Author

Choose a reason for hiding this comment

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

interesting, thanks :D

src/librustdoc/clean/types.rs Show resolved Hide resolved
src/librustdoc/passes/check_code_block_syntax.rs Outdated Show resolved Hide resolved
src/librustdoc/passes/check_code_block_syntax.rs Outdated Show resolved Hide resolved
src/librustdoc/passes/collect_intra_doc_links.rs Outdated Show resolved Hide resolved
src/librustdoc/passes/doc_test_lints.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 31, 2020
Cfg::Cfg(name, _) if name == sym::target_feature => true,
_ => false,
}
matches!(*self, Cfg::Cfg(name, _) if name == sym::target_feature)
Copy link
Contributor

@LingMan LingMan Dec 31, 2020

Choose a reason for hiding this comment

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

Unnecessary deref of self. Can that guard be turned into a direct match like Cfg::Cfg(sym::target_feature, _))?

Copy link
Member

Choose a reason for hiding this comment

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

@LingMan no, target_feature is a constant, not an enum variant.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jyn514 Why would that be a problem?

fn should_use_with_in_description(&self) -> bool {
    matches!(self , Cfg::Cfg(sym::target_feature, _))
}

passes ./x.py check just fine. Is there a semantic difference I'm not aware of?

Copy link
Member

Choose a reason for hiding this comment

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

I didn't know that was a valid pattern 👀 I found that it works even if there's no path in front, but I could have sworn that meant a variable binding instead ... I'm really confused 😕

Copy link
Contributor

Choose a reason for hiding this comment

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

It becomes a variable binding if you remove the use inner::C;.

ItemKind::TypedefItem(_, _) | ItemKind::AssocTypeItem(_, _) => true,
_ => false,
}
matches!(*self, ItemKind::TypedefItem(_, _) | ItemKind::AssocTypeItem(_, _))
Copy link
Contributor

Choose a reason for hiding this comment

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

Those _, _ could be replaced by ...
Unnecessary deref. Same for other instances below.

src/librustdoc/html/format.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 31, 2020
fixes clippy warnings of type:
match_like_matches_macro
or_fun_call
op_ref
needless_return
let_and_return
single_char_add_str
useless_format
unnecessary_sort_by
match_ref_pats
redundant_field_names
@jyn514
Copy link
Member

jyn514 commented Jan 1, 2021

@bors delegate=LingMan

@bors
Copy link
Contributor

bors commented Jan 1, 2021

✌️ @LingMan can now approve this pull request

@LingMan
Copy link
Contributor

LingMan commented Jan 1, 2021

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 1, 2021

📌 Commit a5807ac has been approved by LingMan

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 1, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 2, 2021
Rollup of 6 pull requests

Successful merges:

 - rust-lang#80546 (clippy fixes for librustdoc)
 - rust-lang#80555 (Improve library tracking issue template)
 - rust-lang#80574 (Clean bootstrap artifacts on `x.py clean`)
 - rust-lang#80578 (improve unconditional_panic description)
 - rust-lang#80599 (`const_generics_defaults`: don't ICE in the unimplemented parts)
 - rust-lang#80613 (Diag: print enum variant instead of enum type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 29c1bc9 into rust-lang:master Jan 2, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants