Skip to content

Commit 4f5e53e

Browse files
Update toolchain to nightly-2024-11-26 (#3740)
Fix required due to the following changes to Rust's internal API: - rust-lang/rust#132460 - rust-lang/rust#133212 - rust-lang/rust#131326 Resolves #3731 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Zyad Hassan <[email protected]>
1 parent 69b8b37 commit 4f5e53e

File tree

13 files changed

+74
-48
lines changed

13 files changed

+74
-48
lines changed

kani-compiler/src/codegen_aeneas_llbc/mir_to_ullbc/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use charon_lib::ullbc_ast::{
4646
use charon_lib::{error_assert, error_or_panic};
4747
use core::panic;
4848
use rustc_data_structures::fx::FxHashMap;
49-
use rustc_middle::ty::TyCtxt;
49+
use rustc_middle::ty::{TyCtxt, TypingEnv};
5050
use rustc_smir::rustc_internal;
5151
use stable_mir::abi::PassMode;
5252
use stable_mir::mir::mono::{Instance, InstanceDef};
@@ -226,7 +226,8 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
226226
GenericArgKind::Const(tc) => match tc.kind() {
227227
TyConstKind::Param(paramtc) => {
228228
let def_id_internal = rustc_internal::internal(self.tcx, adtdef.def_id());
229-
let paramenv = self.tcx.param_env(def_id_internal);
229+
let paramenv =
230+
TypingEnv::post_analysis(self.tcx, def_id_internal).param_env;
230231
let pc_internal = rustc_middle::ty::ParamConst {
231232
index: paramtc.index,
232233
name: rustc_span::Symbol::intern(&paramtc.name),

kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::unwrap_or_return_codegen_unimplemented_stmt;
1010
use cbmc::goto_program::{
1111
ArithmeticOverflowResult, BinaryOperator, BuiltinFn, Expr, Location, Stmt, Type,
1212
};
13-
use rustc_middle::ty::ParamEnv;
13+
use rustc_middle::ty::TypingEnv;
1414
use rustc_middle::ty::layout::ValidityRequirement;
1515
use rustc_smir::rustc_internal;
1616
use stable_mir::mir::mono::Instance;
@@ -730,15 +730,15 @@ impl GotocCtx<'_> {
730730
);
731731
}
732732

733-
let param_env_and_type =
734-
ParamEnv::reveal_all().and(rustc_internal::internal(self.tcx, target_ty));
733+
let typing_env_and_type = TypingEnv::fully_monomorphized()
734+
.as_query_input(rustc_internal::internal(self.tcx, target_ty));
735735

736736
// Then we check if the type allows "raw" initialization for the cases
737737
// where memory is zero-initialized or entirely uninitialized
738738
if intrinsic == "assert_zero_valid"
739739
&& !self
740740
.tcx
741-
.check_validity_requirement((ValidityRequirement::Zero, param_env_and_type))
741+
.check_validity_requirement((ValidityRequirement::Zero, typing_env_and_type))
742742
.unwrap()
743743
{
744744
return self.codegen_fatal_error(
@@ -756,7 +756,7 @@ impl GotocCtx<'_> {
756756
.tcx
757757
.check_validity_requirement((
758758
ValidityRequirement::UninitMitigated0x01Fill,
759-
param_env_and_type,
759+
typing_env_and_type,
760760
))
761761
.unwrap()
762762
{

kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cbmc::goto_program::{
1818
};
1919
use cbmc::{InternString, InternedString, btree_string_map};
2020
use num::bigint::BigInt;
21-
use rustc_middle::ty::{ParamEnv, TyCtxt, VtblEntry};
21+
use rustc_middle::ty::{TyCtxt, TypingEnv, VtblEntry};
2222
use rustc_smir::rustc_internal;
2323
use rustc_target::abi::{FieldsShape, TagEncoding, Variants};
2424
use stable_mir::abi::{Primitive, Scalar, ValueAbi};
@@ -832,7 +832,7 @@ impl GotocCtx<'_> {
832832
NullOp::OffsetOf(fields) => Expr::int_constant(
833833
self.tcx
834834
.offset_of_subfield(
835-
ParamEnv::reveal_all(),
835+
TypingEnv::fully_monomorphized(),
836836
layout,
837837
fields.iter().map(|(var_idx, field_idx)| {
838838
(

kani-compiler/src/codegen_cprover_gotoc/codegen/statement.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::codegen_cprover_gotoc::{GotocCtx, VtableCtx};
88
use crate::unwrap_or_return_codegen_unimplemented_stmt;
99
use cbmc::goto_program::{Expr, Location, Stmt, Type};
1010
use rustc_middle::ty::layout::LayoutOf;
11-
use rustc_middle::ty::{List, ParamEnv};
11+
use rustc_middle::ty::{List, TypingEnv};
1212
use rustc_smir::rustc_internal;
1313
use rustc_target::abi::{FieldsShape, Primitive, TagEncoding, Variants};
1414
use stable_mir::abi::{ArgAbi, FnAbi, PassMode};
@@ -663,7 +663,8 @@ impl GotocCtx<'_> {
663663
let fn_ptr_abi = rustc_internal::stable(
664664
self.tcx
665665
.fn_abi_of_fn_ptr(
666-
ParamEnv::reveal_all().and((fn_sig_internal, &List::empty())),
666+
TypingEnv::fully_monomorphized()
667+
.as_query_input((fn_sig_internal, &List::empty())),
667668
)
668669
.unwrap(),
669670
);

kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<'tcx> GotocCtx<'tcx> {
229229
if let Some(current_fn) = &self.current_fn {
230230
current_fn.instance().instantiate_mir_and_normalize_erasing_regions(
231231
self.tcx,
232-
ty::ParamEnv::reveal_all(),
232+
ty::TypingEnv::fully_monomorphized(),
233233
ty::EarlyBinder::bind(value),
234234
)
235235
} else {
@@ -251,7 +251,7 @@ impl<'tcx> GotocCtx<'tcx> {
251251
pub fn is_unsized(&self, t: Ty<'tcx>) -> bool {
252252
!self
253253
.monomorphize(t)
254-
.is_sized(*self.tcx.at(rustc_span::DUMMY_SP), ty::ParamEnv::reveal_all())
254+
.is_sized(*self.tcx.at(rustc_span::DUMMY_SP), ty::TypingEnv::fully_monomorphized())
255255
}
256256

257257
/// Generates the type for a single field for a dynamic vtable.
@@ -523,7 +523,8 @@ impl<'tcx> GotocCtx<'tcx> {
523523
/// c.f. <https://rust-lang.github.io/unsafe-code-guidelines/introduction.html>
524524
pub fn codegen_ty(&mut self, ty: Ty<'tcx>) -> Type {
525525
// TODO: Remove all monomorphize calls
526-
let normalized = self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty);
526+
let normalized =
527+
self.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty);
527528
let goto_typ = self.codegen_ty_inner(normalized);
528529
if let Some(tag) = goto_typ.tag() {
529530
self.type_map.entry(tag).or_insert_with(|| {
@@ -573,10 +574,14 @@ impl<'tcx> GotocCtx<'tcx> {
573574
ty::Str => Type::unsigned_int(8).flexible_array_of(),
574575
ty::Ref(_, t, _) | ty::RawPtr(t, _) => self.codegen_ty_ref(*t),
575576
ty::FnDef(def_id, args) => {
576-
let instance =
577-
Instance::try_resolve(self.tcx, ty::ParamEnv::reveal_all(), *def_id, args)
578-
.unwrap()
579-
.unwrap();
577+
let instance = Instance::try_resolve(
578+
self.tcx,
579+
ty::TypingEnv::fully_monomorphized(),
580+
*def_id,
581+
args,
582+
)
583+
.unwrap()
584+
.unwrap();
580585
self.codegen_fndef_type(instance)
581586
}
582587
ty::FnPtr(sig_tys, hdr) => {
@@ -980,7 +985,7 @@ impl<'tcx> GotocCtx<'tcx> {
980985
// Normalize pointee_type to remove projection and opaque types
981986
trace!(?pointee_type, "codegen_ty_ref");
982987
let pointee_type =
983-
self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), pointee_type);
988+
self.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), pointee_type);
984989

985990
if !self.use_thin_pointer(pointee_type) {
986991
return self.codegen_fat_ptr(pointee_type);
@@ -1076,7 +1081,9 @@ impl<'tcx> GotocCtx<'tcx> {
10761081
/// one can only apply this function to a monomorphized signature
10771082
pub fn codegen_function_sig(&mut self, sig: PolyFnSig<'tcx>) -> Type {
10781083
let sig = self.monomorphize(sig);
1079-
let sig = self.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig);
1084+
let sig = self
1085+
.tcx
1086+
.normalize_erasing_late_bound_regions(ty::TypingEnv::fully_monomorphized(), sig);
10801087
self.codegen_function_sig_stable(rustc_internal::stable(sig))
10811088
}
10821089

kani-compiler/src/codegen_cprover_gotoc/context/goto_ctx.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use cbmc::{InternedString, MachineModel};
2929
use rustc_data_structures::fx::FxHashMap;
3030
use rustc_middle::span_bug;
3131
use rustc_middle::ty::layout::{
32-
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, LayoutOfHelpers,
33-
TyAndLayout,
32+
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError,
33+
LayoutOfHelpers, TyAndLayout,
3434
};
3535
use rustc_middle::ty::{self, Ty, TyCtxt};
3636
use rustc_span::Span;
@@ -337,9 +337,9 @@ impl<'tcx> LayoutOfHelpers<'tcx> for GotocCtx<'tcx> {
337337
}
338338
}
339339

340-
impl<'tcx> HasParamEnv<'tcx> for GotocCtx<'tcx> {
341-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
342-
ty::ParamEnv::reveal_all()
340+
impl<'tcx> HasTypingEnv<'tcx> for GotocCtx<'tcx> {
341+
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
342+
ty::TypingEnv::fully_monomorphized()
343343
}
344344
}
345345

kani-compiler/src/kani_middle/coercion.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hir::lang_items::LangItem;
1717
use rustc_middle::traits::{ImplSource, ImplSourceUserDefinedData};
1818
use rustc_middle::ty::TraitRef;
1919
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
20-
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
20+
use rustc_middle::ty::{PseudoCanonicalInput, Ty, TyCtxt, TypingEnv};
2121
use rustc_smir::rustc_internal;
2222
use stable_mir::Symbol;
2323
use stable_mir::ty::{RigidTy, Ty as TyStable, TyKind};
@@ -102,7 +102,7 @@ pub fn extract_unsize_casting<'tcx>(
102102
let (src_base_ty, dst_base_ty) = tcx.struct_lockstep_tails_for_codegen(
103103
src_pointee_ty,
104104
dst_pointee_ty,
105-
ParamEnv::reveal_all(),
105+
TypingEnv::fully_monomorphized(),
106106
);
107107
trace!(?src_base_ty, ?dst_base_ty, "extract_unsize_casting result");
108108
assert!(
@@ -251,7 +251,10 @@ fn custom_coerce_unsize_info<'tcx>(
251251

252252
let trait_ref = TraitRef::new(tcx, def_id, tcx.mk_args_trait(source_ty, [target_ty.into()]));
253253

254-
match tcx.codegen_select_candidate((ParamEnv::reveal_all(), trait_ref)) {
254+
match tcx.codegen_select_candidate(PseudoCanonicalInput {
255+
typing_env: TypingEnv::fully_monomorphized(),
256+
value: trait_ref,
257+
}) {
255258
Ok(ImplSource::UserDefined(ImplSourceUserDefinedData { impl_def_id, .. })) => {
256259
tcx.coerce_unsized_info(impl_def_id).unwrap().custom_kind.unwrap()
257260
}

kani-compiler/src/kani_middle/points_to/points_to_analysis.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use rustc_middle::{
3838
ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorEdges,
3939
TerminatorKind,
4040
},
41-
ty::{Instance, InstanceKind, List, ParamEnv, TyCtxt, TyKind},
41+
ty::{Instance, InstanceKind, List, TyCtxt, TyKind, TypingEnv},
4242
};
4343
use rustc_mir_dataflow::{Analysis, Forward, JoinSemiLattice};
4444
use rustc_smir::rustc_internal;
@@ -179,6 +179,7 @@ impl<'tcx> Analysis<'tcx> for PointsToAnalysis<'_, 'tcx> {
179179
| StatementKind::AscribeUserType(..)
180180
| StatementKind::Coverage(..)
181181
| StatementKind::ConstEvalCounter
182+
| StatementKind::BackwardIncompatibleDropHint { .. }
182183
| StatementKind::Nop => { /* This is a no-op with regard to aliasing. */ }
183184
}
184185
}
@@ -356,7 +357,13 @@ fn try_resolve_instance<'tcx>(
356357
TyKind::FnDef(def, args) => {
357358
// Span here is used for error-reporting, which we don't expect to encounter anyway, so
358359
// it is ok to use a dummy.
359-
Ok(Instance::expect_resolve(tcx, ParamEnv::reveal_all(), *def, &args, DUMMY_SP))
360+
Ok(Instance::expect_resolve(
361+
tcx,
362+
TypingEnv::fully_monomorphized(),
363+
*def,
364+
&args,
365+
DUMMY_SP,
366+
))
360367
}
361368
_ => Err(format!(
362369
"Kani was not able to resolve the instance of the function operand `{ty:?}`. Currently, memory initialization checks in presence of function pointers and vtable calls are not supported. For more information about planned support, see https://github.com/model-checking/kani/issues/3300."

kani-compiler/src/kani_middle/stubbing/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tracing::{debug, trace};
1212
use kani_metadata::HarnessMetadata;
1313
use rustc_hir::def_id::DefId;
1414
use rustc_middle::mir::Const;
15-
use rustc_middle::ty::{self, EarlyBinder, ParamEnv, TyCtxt, TypeFoldable};
15+
use rustc_middle::ty::{self, EarlyBinder, TyCtxt, TypeFoldable, TypingEnv};
1616
use rustc_smir::rustc_internal;
1717
use stable_mir::mir::ConstOperand;
1818
use stable_mir::mir::mono::Instance;
@@ -152,7 +152,7 @@ impl<'tcx> StubConstChecker<'tcx> {
152152
trace!(instance=?self.instance, ?value, "monomorphize");
153153
self.instance.instantiate_mir_and_normalize_erasing_regions(
154154
self.tcx,
155-
ParamEnv::reveal_all(),
155+
TypingEnv::fully_monomorphized(),
156156
EarlyBinder::bind(value),
157157
)
158158
}
@@ -171,7 +171,11 @@ impl MirVisitor for StubConstChecker<'_> {
171171
Const::Val(..) | Const::Ty(..) => {}
172172
Const::Unevaluated(un_eval, _) => {
173173
// Thread local fall into this category.
174-
if self.tcx.const_eval_resolve(ParamEnv::reveal_all(), un_eval, DUMMY_SP).is_err() {
174+
if self
175+
.tcx
176+
.const_eval_resolve(TypingEnv::fully_monomorphized(), un_eval, DUMMY_SP)
177+
.is_err()
178+
{
175179
// The `monomorphize` call should have evaluated that constant already.
176180
let tcx = self.tcx;
177181
let mono_const = &un_eval;

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# SPDX-License-Identifier: Apache-2.0 OR MIT
33

44
[toolchain]
5-
channel = "nightly-2024-11-19"
5+
channel = "nightly-2024-11-26"
66
components = ["llvm-tools", "rustc-dev", "rust-src", "rustfmt"]

tests/expected/llbc/enum/expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ fn test::main()
2929
let i@2: i32; // local
3030

3131
e@1 := test::MyEnum::A { 0: const (1 : i32) }
32-
i@2 := @Fun0(move (e@1))
32+
i@2 := @Fun1(move (e@1))
3333
drop i@2
3434
@0 := ()
3535
return
3636
}
37+

tests/expected/llbc/projection/expected

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ struct test::MyStruct =
55
}
66

77
enum test::MyEnum0 =
8-
| A(0: @Adt1, 1: i32)
8+
| A(0: @Adt0, 1: i32)
99
| B()
1010

1111

1212
enum test::MyEnum =
13-
| A(0: @Adt1, 1: @Adt2)
13+
| A(0: @Adt0, 1: @Adt2)
1414
| B(0: (i32, i32))
1515

1616

17-
fn test::enum_match(@1: @Adt0) -> i32
17+
fn test::enum_match(@1: @Adt1) -> i32
1818
{
1919
let @0: i32; // return
20-
let e@1: @Adt0; // arg #1
21-
let s@2: @Adt1; // local
20+
let e@1: @Adt1; // arg #1
21+
let s@2: @Adt0; // local
2222
let e0@3: @Adt2; // local
23-
let s1@4: @Adt1; // local
23+
let s1@4: @Adt0; // local
2424
let b@5: i32; // local
2525
let @6: i32; // anonymous local
2626
let @7: i32; // anonymous local
@@ -66,19 +66,20 @@ fn test::enum_match(@1: @Adt0) -> i32
6666
fn test::main()
6767
{
6868
let @0: (); // return
69-
let s@1: @Adt1; // local
70-
let s0@2: @Adt1; // local
71-
let e@3: @Adt0; // local
69+
let s@1: @Adt0; // local
70+
let s0@2: @Adt0; // local
71+
let e@3: @Adt1; // local
7272
let @4: @Adt2; // anonymous local
7373
let i@5: i32; // local
7474

75-
s@1 := @Adt1 { a: const (1 : i32), b: const (2 : i32) }
76-
s0@2 := @Adt1 { a: const (1 : i32), b: const (2 : i32) }
75+
s@1 := @Adt0 { a: const (1 : i32), b: const (2 : i32) }
76+
s0@2 := @Adt0 { a: const (1 : i32), b: const (2 : i32) }
7777
@4 := test::MyEnum0::A { 0: move (s0@2), 1: const (1 : i32) }
7878
e@3 := test::MyEnum::A { 0: move (s@1), 1: move (@4) }
7979
drop @4
80-
i@5 := @Fun0(move (e@3))
80+
i@5 := @Fun1(move (e@3))
8181
drop i@5
8282
@0 := ()
8383
return
8484
}
85+

tests/expected/llbc/struct/expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ fn test::main()
2020
let a@2: i32; // local
2121

2222
s@1 := @Adt0 { a: const (1 : i32), b: const (true) }
23-
a@2 := @Fun1(move (s@1))
23+
a@2 := @Fun0(move (s@1))
2424
drop a@2
2525
@0 := ()
2626
return
2727
}
28+

0 commit comments

Comments
 (0)