-
Notifications
You must be signed in to change notification settings - Fork 13.3k
clippy fixes for librustdoc #80546
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
clippy fixes for librustdoc #80546
Conversation
Some changes occurred in intra-doc-links. cc @jyn514 |
r? @ollie27 (rust-highfive has picked a reviewer for you, use r? to override) |
r? @jyn514 |
src/librustdoc/clean/cfg.rs
Outdated
Cfg::Cfg(..) => true, | ||
_ => false, | ||
}, | ||
Cfg::Not(ref child) => matches!(**child, Cfg::Cfg(..)), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(..))
There was a problem hiding this comment.
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/cfg.rs
Outdated
Cfg::Cfg(name, _) if name == sym::target_feature => true, | ||
_ => false, | ||
} | ||
matches!(*self, Cfg::Cfg(name, _) if name == sym::target_feature) |
There was a problem hiding this comment.
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, _))
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😕
There was a problem hiding this comment.
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;
.
src/librustdoc/clean/types.rs
Outdated
ItemKind::TypedefItem(_, _) | ItemKind::AssocTypeItem(_, _) => true, | ||
_ => false, | ||
} | ||
matches!(*self, ItemKind::TypedefItem(_, _) | ItemKind::AssocTypeItem(_, _)) |
There was a problem hiding this comment.
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.
a3a44e4
to
4d9a6b0
Compare
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
4d9a6b0
to
a5807ac
Compare
@bors delegate=LingMan |
✌️ @LingMan can now approve this pull request |
@bors r+ rollup |
📌 Commit a5807ac has been approved by |
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
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