diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2020-03-04 15:53:14 +0100 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2020-03-04 20:41:03 +0100 |
| commit | d8d2004c6ffb8b66eac90e75aa23012130adf9f9 (patch) | |
| tree | 3f827a8f9ab5363f24cc85cecc91a8318551cbf3 | |
| parent | 38f5db72681289f6ebbcb3c89081f021aa6fdc63 (diff) | |
| download | rust-d8d2004c6ffb8b66eac90e75aa23012130adf9f9.tar.gz rust-d8d2004c6ffb8b66eac90e75aa23012130adf9f9.zip | |
Don't use "if let" bindings to only check a value and not actually bind anything.
For example: `if let Some(_) = foo() {}` can be reduced to `if foo().is_some() {}` (clippy::redundant_pattern_matching)
| -rw-r--r-- | src/librustc_codegen_llvm/back/write.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/back/write.rs | 2 | ||||
| -rw-r--r-- | src/librustc_errors/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustc_interface/util.rs | 2 | ||||
| -rw-r--r-- | src/librustc_lint/context.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/type_check/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/type_check/relate_tys.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/memory.rs | 2 | ||||
| -rw-r--r-- | src/librustc_passes/entry.rs | 2 |
9 files changed, 9 insertions, 9 deletions
diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index a215ef81bc9..0c243128104 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -725,7 +725,7 @@ pub(crate) unsafe fn codegen( Err(_) => return 0, }; - if let Err(_) = write!(cursor, "{:#}", demangled) { + if write!(cursor, "{:#}", demangled).is_err() { // Possible only if provided buffer is not big enough return 0; } diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 76728e98406..b313bf57d4a 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -1257,7 +1257,7 @@ fn start_executing_work<B: ExtraBackendMethods>( if main_thread_worker_state == MainThreadWorkerState::Idle { if !queue_full_enough(work_items.len(), running, max_workers) { // The queue is not full enough, codegen more items: - if let Err(_) = codegen_worker_send.send(Message::CodegenItem) { + if codegen_worker_send.send(Message::CodegenItem).is_err() { panic!("Could not send Message::CodegenItem to main thread") } main_thread_worker_state = MainThreadWorkerState::Codegenning; diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 5b00087de6f..f0e388a597b 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -163,7 +163,7 @@ impl CodeSuggestion { None => buf.push_str(&line[lo..]), } } - if let None = hi_opt { + if hi_opt.is_none() { buf.push('\n'); } } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 10a8c0a63f1..7866ddbd4cc 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -426,7 +426,7 @@ pub(crate) fn check_attr_crate_type(attrs: &[ast::Attribute], lint_buffer: &mut for a in attrs.iter() { if a.check_name(sym::crate_type) { if let Some(n) = a.value_str() { - if let Some(_) = categorize_crate_type(n) { + if categorize_crate_type(n).is_some() { return; } diff --git a/src/librustc_lint/context.rs b/src/librustc_lint/context.rs index 29a6b8c693f..a6e8a0ab930 100644 --- a/src/librustc_lint/context.rs +++ b/src/librustc_lint/context.rs @@ -335,7 +335,7 @@ impl LintStore { lint_name.to_string() }; // If the lint was scoped with `tool::` check if the tool lint exists - if let Some(_) = tool_name { + if tool_name.is_some() { match self.by_name.get(&complete_name) { None => match self.lint_groups.get(&*complete_name) { None => return CheckLintNameResult::Tool(Err((None, String::new()))), diff --git a/src/librustc_mir/borrow_check/type_check/mod.rs b/src/librustc_mir/borrow_check/type_check/mod.rs index f4e1bce462f..652de6c7b6f 100644 --- a/src/librustc_mir/borrow_check/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/type_check/mod.rs @@ -1905,7 +1905,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // expressions evaluate through `as_temp` or `into` a return // slot or local, so to find all unsized rvalues it is enough // to check all temps, return slots and locals. - if let None = self.reported_errors.replace((ty, span)) { + if self.reported_errors.replace((ty, span)).is_none() { let mut diag = struct_span_err!( self.tcx().sess, span, diff --git a/src/librustc_mir/borrow_check/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/type_check/relate_tys.rs index 31507a184d8..b0f048ff1a6 100644 --- a/src/librustc_mir/borrow_check/type_check/relate_tys.rs +++ b/src/librustc_mir/borrow_check/type_check/relate_tys.rs @@ -64,7 +64,7 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> { } fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> { - if let Some(_) = &mut self.borrowck_context { + if self.borrowck_context.is_some() { let origin = NLLRegionVariableOrigin::Existential { from_forall }; self.infcx.next_nll_region_var(origin) } else { diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 6517ae5d0f3..3c4a1857f96 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -565,7 +565,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { // # Function pointers // (both global from `alloc_map` and local from `extra_fn_ptr_map`) - if let Some(_) = self.get_fn_alloc(id) { + if self.get_fn_alloc(id).is_some() { return if let AllocCheck::Dereferenceable = liveness { // The caller requested no function pointers. throw_unsup!(DerefFunctionPointer) diff --git a/src/librustc_passes/entry.rs b/src/librustc_passes/entry.rs index f2239ad16ee..86596e20556 100644 --- a/src/librustc_passes/entry.rs +++ b/src/librustc_passes/entry.rs @@ -196,7 +196,7 @@ fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) { // The file may be empty, which leads to the diagnostic machinery not emitting this // note. This is a relatively simple way to detect that case and emit a span-less // note instead. - if let Ok(_) = tcx.sess.source_map().lookup_line(sp.lo()) { + if tcx.sess.source_map().lookup_line(sp.lo()).is_ok() { err.set_span(sp); err.span_label(sp, ¬e); } else { |
