Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 84dd15f

Browse files
authoredOct 25, 2024··
Update toolchain to 10/25 (#3648)
Culprit PR: rust-lang/rust#131985 The automatic PR failed because the culprit PR removed the `host_param_index` field that we used in the `contract_host_param` function. We needed the `contract_host_param` function in the first place because previously, Rust would add a `<const HOST: bool>` parameter to a function's `GenericArgs` to handle trait constness (c.f. #3258). The culprit PR [removed that argument](https://github.com/rust-lang/rust/pull/131985/files#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394L1527), so our logic to find and remove this parameter during stubbing is no longer necessary. Resolves #3645 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 68415ff commit 84dd15f

File tree

3 files changed

+4
-29
lines changed

3 files changed

+4
-29
lines changed
 

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

+1-22
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,6 @@ pub fn harness_stub_map(
3737
stub_pairs
3838
}
3939

40-
/// Retrieve the index of the host parameter if old definition has one, but not the new definition.
41-
///
42-
/// This is to allow constant functions to be stubbed by non-constant functions when the
43-
/// `effect` feature is on.
44-
///
45-
/// Note that the opposite is not supported today, but users should be able to change their stubs.
46-
///
47-
/// Note that this has no effect at runtime.
48-
pub fn contract_host_param(tcx: TyCtxt, old_def: FnDef, new_def: FnDef) -> Option<usize> {
49-
let old_generics = tcx.generics_of(rustc_internal::internal(tcx, old_def.def_id()));
50-
let new_generics = tcx.generics_of(rustc_internal::internal(tcx, new_def.def_id()));
51-
if old_generics.host_effect_index.is_some() && new_generics.host_effect_index.is_none() {
52-
old_generics.host_effect_index
53-
} else {
54-
None
55-
}
56-
}
57-
5840
/// Checks whether the stub is compatible with the original function/method: do
5941
/// the arities and types (of the parameters and return values) match up? This
6042
/// does **NOT** check whether the type variables are constrained to implement
@@ -81,15 +63,12 @@ pub fn check_compatibility(tcx: TyCtxt, old_def: FnDef, new_def: FnDef) -> Resul
8163
let new_def_id = rustc_internal::internal(tcx, new_def.def_id());
8264
let old_ty = rustc_internal::stable(tcx.type_of(old_def_id)).value;
8365
let new_ty = rustc_internal::stable(tcx.type_of(new_def_id)).value;
84-
let TyKind::RigidTy(RigidTy::FnDef(_, mut old_args)) = old_ty.kind() else {
66+
let TyKind::RigidTy(RigidTy::FnDef(_, old_args)) = old_ty.kind() else {
8567
unreachable!("Expected function, but found {old_ty}")
8668
};
8769
let TyKind::RigidTy(RigidTy::FnDef(_, new_args)) = new_ty.kind() else {
8870
unreachable!("Expected function, but found {new_ty}")
8971
};
90-
if let Some(idx) = contract_host_param(tcx, old_def, new_def) {
91-
old_args.0.remove(idx);
92-
}
9372

9473
// TODO: We should check for the parameter type too or replacement will fail.
9574
if old_args.0.len() != new_args.0.len() {

‎kani-compiler/src/kani_middle/transform/stubs.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! This module contains code related to the MIR-to-MIR pass that performs the
44
//! stubbing of functions and methods.
55
use crate::kani_middle::codegen_units::Stubs;
6-
use crate::kani_middle::stubbing::{contract_host_param, validate_stub_const};
6+
use crate::kani_middle::stubbing::validate_stub_const;
77
use crate::kani_middle::transform::body::{MutMirVisitor, MutableBody};
88
use crate::kani_middle::transform::{TransformPass, TransformationType};
99
use crate::kani_queries::QueryDb;
@@ -46,12 +46,8 @@ impl TransformPass for FnStubPass {
4646
fn transform(&mut self, tcx: TyCtxt, body: Body, instance: Instance) -> (bool, Body) {
4747
trace!(function=?instance.name(), "transform");
4848
let ty = instance.ty();
49-
if let TyKind::RigidTy(RigidTy::FnDef(fn_def, mut args)) = ty.kind() {
49+
if let TyKind::RigidTy(RigidTy::FnDef(fn_def, args)) = ty.kind() {
5050
if let Some(replace) = self.stubs.get(&fn_def) {
51-
if let Some(idx) = contract_host_param(tcx, fn_def, *replace) {
52-
debug!(?idx, "FnStubPass::transform remove_host_param");
53-
args.0.remove(idx);
54-
}
5551
let new_instance = Instance::resolve(*replace, &args).unwrap();
5652
debug!(from=?instance.name(), to=?new_instance.name(), "FnStubPass::transform");
5753
if let Some(body) = FnStubValidator::validate(tcx, (fn_def, *replace), new_instance)

‎rust-toolchain.toml

+1-1
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-10-24"
5+
channel = "nightly-2024-10-25"
66
components = ["llvm-tools", "rustc-dev", "rust-src", "rustfmt"]

0 commit comments

Comments
 (0)
Please sign in to comment.