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

fix more clippy warnings #71562

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/liballoc/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ impl<'a, T: Ord> Drop for DrainSorted<'a, T> {

impl<'r, 'a, T: Ord> Drop for DropGuard<'r, 'a, T> {
fn drop(&mut self) {
while let Some(_) = self.0.inner.pop() {}
while self.0.inner.pop().is_some() {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ unsafe impl<#[may_dangle] T> Drop for LinkedList<T> {
fn drop(&mut self) {
// Continue the same loop we do below. This only runs when a destructor has
// panicked. If another one panics this will abort.
while let Some(_) = self.0.pop_front_node() {}
while self.0.pop_front_node().is_some() {}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,15 +618,15 @@ impl RustcDefaultCalls {
) -> Compilation {
let r = matches.opt_strs("Z");
if r.iter().any(|s| *s == "ls") {
match input {
&Input::File(ref ifile) => {
match *input {
Input::File(ref ifile) => {
let path = &(*ifile);
let mut v = Vec::new();
locator::list_file_metadata(&sess.target.target, path, metadata_loader, &mut v)
.unwrap();
println!("{}", String::from_utf8(v).unwrap());
}
&Input::Str { .. } => {
Input::Str { .. } => {
early_error(ErrorOutputType::default(), "cannot list metadata for stdin");
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_interface/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
| ast::TyKind::Rptr(_, ast::MutTy { ty: ref subty, .. })
| ast::TyKind::Paren(ref subty) => involves_impl_trait(subty),
ast::TyKind::Tup(ref tys) => any_involves_impl_trait(tys.iter()),
ast::TyKind::Path(_, ref path) => path.segments.iter().any(|seg| {
match seg.args.as_ref().map(|generic_arg| &**generic_arg) {
ast::TyKind::Path(_, ref path) => {
path.segments.iter().any(|seg| match seg.args.as_deref() {
None => false,
Some(&ast::GenericArgs::AngleBracketed(ref data)) => {
data.args.iter().any(|arg| match arg {
Expand All @@ -647,8 +647,8 @@ impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
any_involves_impl_trait(data.inputs.iter())
|| ReplaceBodyWithLoop::should_ignore_fn(&data.output)
}
}
}),
})
}
_ => false,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ impl CStore {
ident,
id: ast::DUMMY_NODE_ID,
span,
attrs: attrs.iter().cloned().collect(),
attrs: attrs.to_vec(),
kind: ast::ItemKind::MacroDef(data.get_macro(id.index, sess)),
vis: source_map::respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
tokens: None,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/transform/copy_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl<'tcx> Action<'tcx> {
}

fn constant(src_constant: &Constant<'tcx>) -> Option<Action<'tcx>> {
Some(Action::PropagateConstant((*src_constant).clone()))
Some(Action::PropagateConstant(*src_constant))
}

fn perform(
Expand Down Expand Up @@ -371,7 +371,7 @@ impl<'tcx> MutVisitor<'tcx> for ConstantPropagationVisitor<'tcx> {
_ => return,
}

*operand = Operand::Constant(box self.constant.clone());
*operand = Operand::Constant(box self.constant);
self.uses_replaced += 1
}
}
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let of_fld = Field::new(1);

let tcx = self.hir.tcx();
let val = tcx.mk_place_field(result_value.clone(), val_fld, ty);
let val = tcx.mk_place_field(result_value, val_fld, ty);
let of = tcx.mk_place_field(result_value, of_fld, bool_ty);

let err = AssertKind::Overflow(op);
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sync/mpsc/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl<T> Packet<T> {
);
cnt != DISCONNECTED && cnt != steals
} {
while let Some(_) = self.queue.pop() {
while self.queue.pop().is_some() {
steals += 1;
}
}
Expand Down