From b349137a68c6d22bc752c14fdea4e397b2c462f4 Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Thu, 18 Jan 2024 07:46:03 -0800 Subject: [PATCH] Upgrade toolchain to nightly-2024-01-17 (#2976) Fixes were done to address the following upstream changes: - https://github.com/rust-lang/rust/pull/119606 - https://github.com/rust-lang/rust/pull/119751 - https://github.com/rust-lang/rust/pull/120025 - https://github.com/rust-lang/rust/pull/116520 Resolves #2971 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --- .../src/codegen_cprover_gotoc/codegen/typ.rs | 6 +++++- .../src/codegen_cprover_gotoc/utils/debug.rs | 2 +- kani-compiler/src/kani_middle/attributes.rs | 14 +++++++------- kani-compiler/src/kani_middle/intrinsics.rs | 5 +++-- rust-toolchain.toml | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs b/kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs index bdddd8ce9f26..7694feb0dbbf 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs @@ -302,7 +302,11 @@ impl<'tcx> GotocCtx<'tcx> { kind: ty::BoundRegionKind::BrEnv, }; let env_region = ty::Region::new_bound(self.tcx, ty::INNERMOST, br); - let env_ty = self.tcx.closure_env_ty(def_id, args, env_region).unwrap(); + let env_ty = self.tcx.closure_env_ty( + Ty::new_closure(self.tcx, def_id, args), + args.as_closure().kind(), + env_region, + ); let sig = sig.skip_binder(); diff --git a/kani-compiler/src/codegen_cprover_gotoc/utils/debug.rs b/kani-compiler/src/codegen_cprover_gotoc/utils/debug.rs index c30d1539bda2..aeaf8e0e2d10 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/utils/debug.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/utils/debug.rs @@ -16,7 +16,7 @@ use tracing::debug; // Use a thread-local global variable to track the current codegen item for debugging. // If Kani panics during codegen, we can grab this item to include the problematic // codegen item in the panic trace. -thread_local!(static CURRENT_CODEGEN_ITEM: RefCell<(Option, Option)> = RefCell::new((None, None))); +thread_local!(static CURRENT_CODEGEN_ITEM: RefCell<(Option, Option)> = const { RefCell::new((None, None)) }); pub fn init() { // Install panic hook diff --git a/kani-compiler/src/kani_middle/attributes.rs b/kani-compiler/src/kani_middle/attributes.rs index 3bfef9a409f4..bfc36360270e 100644 --- a/kani-compiler/src/kani_middle/attributes.rs +++ b/kani-compiler/src/kani_middle/attributes.rs @@ -348,12 +348,12 @@ impl<'tcx> KaniAttributes<'tcx> { "Use of unstable feature `{}`: {}", unstable_attr.feature, unstable_attr.reason )) - .span_note( + .with_span_note( self.tcx.def_span(self.item), format!("the function `{fn_name}` is unstable:"), ) - .note(format!("see issue {} for more information", unstable_attr.issue)) - .help(format!("use `-Z {}` to enable using this function.", unstable_attr.feature)) + .with_note(format!("see issue {} for more information", unstable_attr.issue)) + .with_help(format!("use `-Z {}` to enable using this function.", unstable_attr.feature)) .emit() } @@ -422,7 +422,7 @@ impl<'tcx> KaniAttributes<'tcx> { self.item_name(), ), ) - .span_note(self.tcx.def_span(id), "Try adding a contract to this function.") + .with_span_note(self.tcx.def_span(id), "Try adding a contract to this function.") .emit(); return; }; @@ -448,7 +448,7 @@ impl<'tcx> KaniAttributes<'tcx> { self.item_name(), ), ) - .span_note( + .with_span_note( self.tcx.def_span(def_id), format!( "Try adding a contract to this function or use the unsound `{}` attribute instead.", @@ -624,7 +624,7 @@ impl<'a> UnstableAttrParseError<'a> { self.attr.span, format!("failed to parse `#[kani::unstable]`: {}", self.reason), ) - .note(format!( + .with_note(format!( "expected format: #[kani::unstable({}, {}, {})]", r#"feature="""#, r#"issue="""#, r#"reason="""# )) @@ -665,7 +665,7 @@ fn expect_no_args(tcx: TyCtxt, kind: KaniAttributeKind, attr: &Attribute) { if !attr.is_word() { tcx.dcx() .struct_span_err(attr.span, format!("unexpected argument for `{}`", kind.as_ref())) - .help("remove the extra argument") + .with_help("remove the extra argument") .emit(); } } diff --git a/kani-compiler/src/kani_middle/intrinsics.rs b/kani-compiler/src/kani_middle/intrinsics.rs index c4785ac98b81..8a7fc16d8e9f 100644 --- a/kani-compiler/src/kani_middle/intrinsics.rs +++ b/kani-compiler/src/kani_middle/intrinsics.rs @@ -7,6 +7,7 @@ use rustc_middle::mir::{Body, Const as mirConst, ConstValue, Operand, Terminator use rustc_middle::mir::{Local, LocalDecl}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{Const, GenericArgsRef}; +use rustc_span::source_map::Spanned; use rustc_span::symbol::{sym, Symbol}; use tracing::{debug, trace}; @@ -48,12 +49,12 @@ impl<'tcx> ModelIntrinsics<'tcx> { fn replace_simd_bitmask( &self, func: &mut Operand<'tcx>, - args: &[Operand<'tcx>], + args: &[Spanned>], gen_args: GenericArgsRef<'tcx>, ) { assert_eq!(args.len(), 1); let tcx = self.tcx; - let arg_ty = args[0].ty(&self.local_decls, tcx); + let arg_ty = args[0].node.ty(&self.local_decls, tcx); if arg_ty.is_simd() { // Get the stub definition. let stub_id = tcx.get_diagnostic_item(Symbol::intern("KaniModelSimdBitmask")).unwrap(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 620fdc1efa29..2914c0609c1a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,5 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT [toolchain] -channel = "nightly-2024-01-08" +channel = "nightly-2024-01-17" components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]