Skip to content

Commit e6f6d7d

Browse files
authored
Upgrade toolchain to 2024-12-15 (#3784)
Culprit PRs: - rust-lang/rust#133938, specifically rust-lang/rust@1d56943 - rust-lang/rust#134295 For coroutine closures, I opened #3783 to track feature support--adding support for this appears non-trivial, and I didn't want to block toolchain upgrades on it. Resolves #3781 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent d253bda commit e6f6d7d

File tree

8 files changed

+36
-9
lines changed

8 files changed

+36
-9
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@ impl GotocCtx<'_> {
283283
.member("direct_fields", &self.symbol_table)
284284
.member(field_name, &self.symbol_table))
285285
}
286+
TyKind::RigidTy(RigidTy::CoroutineClosure(def, args)) => {
287+
let typ = Ty::new_coroutine_closure(def, args);
288+
let goto_typ = self.codegen_ty_stable(typ);
289+
Err(UnimplementedData::new(
290+
"Coroutine closures",
291+
"https://github.com/model-checking/kani/issues/3783",
292+
goto_typ,
293+
*parent_expr.location(),
294+
))
295+
}
286296
TyKind::RigidTy(RigidTy::Str)
287297
| TyKind::RigidTy(RigidTy::Array(_, _))
288298
| TyKind::RigidTy(RigidTy::Slice(_))

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,15 @@ impl GotocCtx<'_> {
729729
}
730730
}
731731
AggregateKind::Coroutine(_, _, _) => self.codegen_rvalue_coroutine(&operands, res_ty),
732+
AggregateKind::CoroutineClosure(_, _) => {
733+
let ty = self.codegen_ty_stable(res_ty);
734+
self.codegen_unimplemented_expr(
735+
"CoroutineClosure",
736+
ty,
737+
loc,
738+
"https://github.com/model-checking/kani/issues/3783",
739+
)
740+
}
732741
}
733742
}
734743

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,9 @@ impl<'tcx> GotocCtx<'tcx> {
590590
}
591591
ty::Closure(_, subst) => self.codegen_ty_closure(ty, subst),
592592
ty::Coroutine(..) => self.codegen_ty_coroutine(ty),
593+
ty::CoroutineClosure(..) => unimplemented!(
594+
"Kani does not yet support coroutine closures. Please post your example at https://github.com/model-checking/kani/issues/3783"
595+
),
593596
ty::Never => self.ensure_struct(NEVER_TYPE_EMPTY_STRUCT_NAME, "!", |_, _| vec![]),
594597
ty::Tuple(ts) => {
595598
if ts.is_empty() {
@@ -619,11 +622,7 @@ impl<'tcx> GotocCtx<'tcx> {
619622
ty::Bound(_, _) | ty::Param(_) => unreachable!("monomorphization bug"),
620623

621624
// type checking remnants which shouldn't be reachable
622-
ty::CoroutineWitness(_, _)
623-
| ty::CoroutineClosure(_, _)
624-
| ty::Infer(_)
625-
| ty::Placeholder(_)
626-
| ty::Error(_) => {
625+
ty::CoroutineWitness(_, _) | ty::Infer(_) | ty::Placeholder(_) | ty::Error(_) => {
627626
unreachable!("remnants of type checking")
628627
}
629628
}
@@ -879,7 +878,7 @@ impl<'tcx> GotocCtx<'tcx> {
879878

880879
/// Generates a struct for a variant of the coroutine.
881880
///
882-
/// The field `discriminant_field` should be `Some(idx)` when generating the variant for the direct (top-[evel) fields of the coroutine.
881+
/// The field `discriminant_field` should be `Some(idx)` when generating the variant for the direct (top-level) fields of the coroutine.
883882
/// Then the field with the index `idx` will be treated as the discriminant and will be given a special name to work with the rest of the code.
884883
/// The field `discriminant_field` should be `None` when generating an actual variant of the coroutine because those don't contain the discriminant as a field.
885884
fn codegen_coroutine_variant_struct(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'tcx> Analysis<'tcx> for PointsToAnalysis<'_, 'tcx> {
136136

137137
/// Update current dataflow state based on the information we can infer from the given
138138
/// statement.
139-
fn apply_statement_effect(
139+
fn apply_primary_statement_effect(
140140
&mut self,
141141
state: &mut Self::Domain,
142142
statement: &Statement<'tcx>,
@@ -184,7 +184,7 @@ impl<'tcx> Analysis<'tcx> for PointsToAnalysis<'_, 'tcx> {
184184
}
185185
}
186186

187-
fn apply_terminator_effect<'mir>(
187+
fn apply_primary_terminator_effect<'mir>(
188188
&mut self,
189189
state: &mut Self::Domain,
190190
terminator: &'mir Terminator<'tcx>,

kani-compiler/src/kani_middle/transform/check_uninit/ty_layout.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ fn data_bytes_for_ty(
393393
| RigidTy::FnPtr(_)
394394
| RigidTy::Closure(_, _)
395395
| RigidTy::Coroutine(_, _, _)
396+
| RigidTy::CoroutineClosure(_, _)
396397
| RigidTy::CoroutineWitness(_, _)
397398
| RigidTy::Foreign(_)
398399
| RigidTy::Dynamic(_, _, _) => Err(LayoutComputationError::UnsupportedType(ty)),

kani-compiler/src/kani_middle/transform/check_values.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ impl MirVisitor for CheckValueVisitor<'_, '_> {
640640
AggregateKind::Array(_)
641641
| AggregateKind::Closure(_, _)
642642
| AggregateKind::Coroutine(_, _, _)
643+
| AggregateKind::CoroutineClosure(_, _)
643644
| AggregateKind::RawPtr(_, _)
644645
| AggregateKind::Tuple => {}
645646
},
@@ -981,6 +982,7 @@ pub fn ty_validity_per_offset(
981982
| RigidTy::FnPtr(_)
982983
| RigidTy::Closure(_, _)
983984
| RigidTy::Coroutine(_, _, _)
985+
| RigidTy::CoroutineClosure(_, _)
984986
| RigidTy::CoroutineWitness(_, _)
985987
| RigidTy::Foreign(_)
986988
| RigidTy::Dynamic(_, _, _) => Err(format!("Unsupported {ty:?}")),

kani-compiler/src/kani_middle/transform/internal_mir.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ impl RustcInternalMir for AggregateKind {
5656
internal(tcx, generic_args),
5757
)
5858
}
59+
AggregateKind::CoroutineClosure(coroutine_def, generic_args) => {
60+
rustc_middle::mir::AggregateKind::CoroutineClosure(
61+
internal(tcx, coroutine_def.0),
62+
internal(tcx, generic_args),
63+
)
64+
}
5965
AggregateKind::RawPtr(ty, mutability) => rustc_middle::mir::AggregateKind::RawPtr(
6066
internal(tcx, ty),
6167
internal(tcx, mutability),

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-12-14"
5+
channel = "nightly-2024-12-15"
66
components = ["llvm-tools", "rustc-dev", "rust-src", "rustfmt"]

0 commit comments

Comments
 (0)