-
Notifications
You must be signed in to change notification settings - Fork 13.4k
A few cleanups #53246
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
A few cleanups #53246
Conversation
r? @KodrAus (rust_highfive has picked a reviewer for you, use r? to override) |
&LabelStr(ref s) => format!("\"{}\"", s.escape_default()), | ||
&EscStr(ref s) => format!("\"{}\"", LabelText::escape_str(&s)), | ||
&HtmlStr(ref s) => format!("<{}>", s), | ||
match *self { |
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 believe match_default_bindings has eliminated the need of *
like this.
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.
True, it would compile without it too; while it's certainly easier to let the compiler do the dereferencing on its own, I wonder if doing it manually isn't faster 🤔.
r? @kennytm |
src/librustc_apfloat/ieee.rs
Outdated
@@ -702,7 +700,7 @@ impl<S: Semantics> Float for IeeeFloat<S> { | |||
// exponent = 1..10 | |||
// significand = 1..1 | |||
IeeeFloat { | |||
sig: [!0 & ((1 << S::PRECISION) - 1)], | |||
sig: [((1 << S::PRECISION) - 1)], |
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.
The outer parenthesis can be removed.
sig: [(1 << S::PRECISION) - 1],
src/librustc_target/spec/mod.rs
Outdated
@@ -769,7 +769,7 @@ impl Target { | |||
.and_then(|os| os.map(|s| s.to_string())) { | |||
Some(val) => Ok(val), | |||
None => { | |||
return Err(format!("Field {} in target specification is required", name)) | |||
Err(format!("Field {} in target specification is required", name)) |
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.
The match should be entirely removed in favor of ok_or_else
.
obj.find(name)
.map(|s| s.as_string())
.and_then(|os| os.map(|s| s.to_string()))
.ok_or_else(|| format!("Field {} in target specification is required", name))
src/libserialize/json.rs
Outdated
if self.is_empty() { | ||
false | ||
} else { | ||
match *self.stack.last().unwrap() { |
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.
The entire function could be replaced with
if let Some(InternalIndex(_)) = self.stack.last() {
true
} else {
false
}
src/libterm/terminfo/parm.rs
Outdated
Digit, | ||
Octal, | ||
Hex, | ||
HEX, |
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.
... Could we make these LowerHex
/UpperHex
if you're going to rename it anyway.
28b08f5
to
535bd13
Compare
@kennytm Thanks, all done. |
@kennytm r? |
@bors r+ |
📌 Commit 535bd13 has been approved by |
A few cleanups - change `skip(1).next()` to `nth(1)` - collapse some `if-else` expressions - remove a few explicit `return`s - remove an unnecessary field name - dereference once instead of matching on multiple references - prefer `iter().enumerate()` to indexing with `for` - remove some unnecessary lifetime annotations - use `writeln!()` instead of `write!()`+`\n` - remove redundant parentheses - shorten some enum variant names - a few other cleanups suggested by `clippy`
A few cleanups - change `skip(1).next()` to `nth(1)` - collapse some `if-else` expressions - remove a few explicit `return`s - remove an unnecessary field name - dereference once instead of matching on multiple references - prefer `iter().enumerate()` to indexing with `for` - remove some unnecessary lifetime annotations - use `writeln!()` instead of `write!()`+`\n` - remove redundant parentheses - shorten some enum variant names - a few other cleanups suggested by `clippy`
Rollup of 11 pull requests Successful merges: - #53112 (pretty print BTreeSet) - #53208 (Don't panic on std::env::vars() when env is null.) - #53226 (driver: set the syntax edition in phase 1) - #53229 (Make sure rlimit is only ever increased) - #53233 (targets: aarch64: Add bare-metal aarch64 target) - #53239 (rustc_codegen_llvm: Restore the closure env alloca hack for LLVM 5.) - #53246 (A few cleanups) - #53257 (Idiomatic improvements to IP method) - #53274 (Remove statics field from CodegenCx) - #53290 (Make LLVM emit assembly comments with -Z asm-comments) - #53317 (Mark prior failure to avoid ICE)
skip(1).next()
tonth(1)
if-else
expressionsreturn
siter().enumerate()
to indexing withfor
writeln!()
instead ofwrite!()
+\n
clippy