From e42d5eed314463c751836e452769991b5d71e30b Mon Sep 17 00:00:00 2001 From: LingMan Date: Wed, 16 Jun 2021 01:48:44 +0200 Subject: [PATCH] Stop returning a value from `report_assert_as_lint` This function only ever returns `None`. Make that explicity by not returning a value at all. --- .../rustc_mir/src/transform/const_prop.rs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_mir/src/transform/const_prop.rs b/compiler/rustc_mir/src/transform/const_prop.rs index 681d63c6fc9..73a0f5537c3 100644 --- a/compiler/rustc_mir/src/transform/const_prop.rs +++ b/compiler/rustc_mir/src/transform/const_prop.rs @@ -528,14 +528,14 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { source_info: SourceInfo, message: &'static str, panic: AssertKind, - ) -> Option<()> { - let lint_root = self.lint_root(source_info)?; - self.tcx.struct_span_lint_hir(lint, lint_root, source_info.span, |lint| { - let mut err = lint.build(message); - err.span_label(source_info.span, format!("{:?}", panic)); - err.emit() - }); - None + ) { + if let Some(lint_root) = self.lint_root(source_info) { + self.tcx.struct_span_lint_hir(lint, lint_root, source_info.span, |lint| { + let mut err = lint.build(message); + err.span_label(source_info.span, format!("{:?}", panic)); + err.emit() + }); + } } fn check_unary_op( @@ -557,7 +557,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { source_info, "this arithmetic operation will overflow", AssertKind::OverflowNeg(val.to_const_int()), - )?; + ); + return None; } Some(()) @@ -602,7 +603,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { }, r.to_const_int(), ), - )?; + ); + return None; } } @@ -617,7 +619,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { source_info, "this arithmetic operation will overflow", AssertKind::Overflow(op, l.to_const_int(), r.to_const_int()), - )?; + ); + return None; } } Some(())