From ac9bd832d0060a9830488c8c503e4da6658350f6 Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Fri, 24 Nov 2023 19:03:03 -0800 Subject: [PATCH] Update toolchain and fix clippy errors --- kani-compiler/src/kani_middle/reachability.rs | 15 ++++----- kani-compiler/src/kani_middle/stubbing/mod.rs | 33 +++++++++---------- rust-toolchain.toml | 2 +- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/kani-compiler/src/kani_middle/reachability.rs b/kani-compiler/src/kani_middle/reachability.rs index 777b29e2542e..1e5a231f3382 100644 --- a/kani-compiler/src/kani_middle/reachability.rs +++ b/kani-compiler/src/kani_middle/reachability.rs @@ -85,14 +85,11 @@ where .iter() .filter_map(|item| { // Only collect monomorphic items. - Instance::try_from(*item) - .ok() - .map(|instance| { - let def_id = rustc_internal::internal(item); - predicate(tcx, def_id) - .then_some(InternalMonoItem::Fn(rustc_internal::internal(&instance))) - }) - .flatten() + Instance::try_from(*item).ok().and_then(|instance| { + let def_id = rustc_internal::internal(item); + predicate(tcx, def_id) + .then_some(InternalMonoItem::Fn(rustc_internal::internal(&instance))) + }) }) .collect::>() }) @@ -500,7 +497,7 @@ fn to_fingerprint(tcx: TyCtxt, item: &InternalMonoItem) -> Fingerprint { } /// Return whether we should include the item into codegen. -fn should_codegen_locally<'tcx>(instance: &Instance) -> bool { +fn should_codegen_locally(instance: &Instance) -> bool { !instance.is_foreign_item() } diff --git a/kani-compiler/src/kani_middle/stubbing/mod.rs b/kani-compiler/src/kani_middle/stubbing/mod.rs index 21c381598b92..748365a6d653 100644 --- a/kani-compiler/src/kani_middle/stubbing/mod.rs +++ b/kani-compiler/src/kani_middle/stubbing/mod.rs @@ -92,27 +92,24 @@ impl<'tcx> MirVisitor for StubConstChecker<'tcx> { Const::Val(..) | Const::Ty(..) => {} Const::Unevaluated(un_eval, _) => { // Thread local fall into this category. - match self.tcx.const_eval_resolve(ParamEnv::reveal_all(), un_eval, None) { + if self.tcx.const_eval_resolve(ParamEnv::reveal_all(), un_eval, None).is_err() { // The `monomorphize` call should have evaluated that constant already. - Err(_) => { - let tcx = self.tcx; - let mono_const = &un_eval; - let implementor = match mono_const.args.as_slice() { - [one] => one.as_type().unwrap(), - _ => unreachable!(), - }; - let trait_ = tcx.trait_of_item(mono_const.def).unwrap(); - let msg = format!( - "Type `{implementor}` does not implement trait `{}`. \ + let tcx = self.tcx; + let mono_const = &un_eval; + let implementor = match mono_const.args.as_slice() { + [one] => one.as_type().unwrap(), + _ => unreachable!(), + }; + let trait_ = tcx.trait_of_item(mono_const.def).unwrap(); + let msg = format!( + "Type `{implementor}` does not implement trait `{}`. \ This is likely because `{}` is used as a stub but its \ generic bounds are not being met.", - tcx.def_path_str(trait_), - self.source.name() - ); - tcx.sess.span_err(rustc_internal::internal(location.span()), msg); - self.is_valid = false; - } - _ => {} + tcx.def_path_str(trait_), + self.source.name() + ); + tcx.sess.span_err(rustc_internal::internal(location.span()), msg); + self.is_valid = false; } } }; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e3af7b80e8f6..4d3bc4304a0b 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,5 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT [toolchain] -channel = "nightly-2023-11-21" +channel = "nightly-2023-11-25" components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]