Skip to content

Commit 0d8675d

Browse files
authored
Remove support for the unstable argument --function (rust-lang#3278)
This is a legacy argument that we have very limited support to. We kept it around for bookrunner tests, which has been removed already. Resolves rust-lang#2129
1 parent 12ff35f commit 0d8675d

File tree

28 files changed

+93
-292
lines changed

28 files changed

+93
-292
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'tcx> GotocCtx<'tcx> {
9595
vec![]
9696
});
9797
self.attach_modifies_contract(instance_of_check, assigns_contract);
98-
let wrapper_name = self.symbol_name_stable(instance_of_check);
98+
let wrapper_name = instance_of_check.mangled_name();
9999

100100
AssignsContract {
101101
recursion_tracker: full_recursion_tracker_name,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> GotocCtx<'tcx> {
4949
/// handled later.
5050
pub fn codegen_foreign_fn(&mut self, instance: Instance) -> &Symbol {
5151
debug!(?instance, "codegen_foreign_function");
52-
let fn_name = self.symbol_name_stable(instance).intern();
52+
let fn_name = instance.mangled_name().intern();
5353
let loc = self.codegen_span_stable(instance.def.span());
5454
if self.symbol_table.contains(fn_name) {
5555
// Symbol has been added (either a built-in CBMC function or a Rust allocation function).
@@ -134,7 +134,7 @@ impl<'tcx> GotocCtx<'tcx> {
134134

135135
/// Generate type for the given foreign instance.
136136
fn codegen_ffi_type(&mut self, instance: Instance) -> Type {
137-
let fn_name = self.symbol_name_stable(instance);
137+
let fn_name = instance.mangled_name();
138138
let fn_abi = instance.fn_abi().unwrap();
139139
let loc = self.codegen_span_stable(instance.def.span());
140140
let params = fn_abi
@@ -166,7 +166,7 @@ impl<'tcx> GotocCtx<'tcx> {
166166
/// This will behave like `codegen_unimplemented_stmt` but print a message that includes
167167
/// the name of the function not supported and the calling convention.
168168
fn codegen_ffi_unsupported(&mut self, instance: Instance, loc: Location) -> Stmt {
169-
let fn_name = &self.symbol_name_stable(instance);
169+
let fn_name = &instance.mangled_name();
170170
debug!(?fn_name, ?loc, "codegen_ffi_unsupported");
171171

172172
// Save this occurrence so we can emit a warning in the compilation report.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'tcx> GotocCtx<'tcx> {
5252
}
5353

5454
pub fn codegen_function(&mut self, instance: Instance) {
55-
let name = self.symbol_name_stable(instance);
55+
let name = instance.mangled_name();
5656
let old_sym = self.symbol_table.lookup(&name).unwrap();
5757

5858
let _trace_span = debug_span!("CodegenFunction", name = instance.name()).entered();
@@ -204,7 +204,7 @@ impl<'tcx> GotocCtx<'tcx> {
204204
let body = self.transformer.body(self.tcx, instance);
205205
self.set_current_fn(instance, &body);
206206
debug!(krate=?instance.def.krate(), is_std=self.current_fn().is_std(), "declare_function");
207-
self.ensure(self.symbol_name_stable(instance), |ctx, fname| {
207+
self.ensure(instance.mangled_name(), |ctx, fname| {
208208
Symbol::function(
209209
fname,
210210
ctx.fn_typ(instance, &body),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ impl<'tcx> GotocCtx<'tcx> {
628628
} else {
629629
// All non-foreign functions should've been declared beforehand.
630630
trace!(func=?instance, "codegen_func_symbol");
631-
let func = self.symbol_name_stable(instance);
631+
let func = instance.mangled_name();
632632
self.symbol_table
633633
.lookup(&func)
634634
.unwrap_or_else(|| panic!("Function `{func}` should've been declared before usage"))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ impl<'tcx> GotocCtx<'tcx> {
12991299
debug!(?vtable_field_name, ?vtable_type, "codegen_vtable_method_field");
13001300

13011301
// Lookup in the symbol table using the full symbol table name/key
1302-
let fn_name = self.symbol_name_stable(instance);
1302+
let fn_name = instance.mangled_name();
13031303

13041304
if let Some(fn_symbol) = self.symbol_table.lookup(&fn_name) {
13051305
if self.vtable_ctx.emit_vtable_restrictions {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'tcx> GotocCtx<'tcx> {
4444
}
4545

4646
pub fn codegen_fndef_type_stable(&mut self, instance: Instance) -> Type {
47-
let func = self.symbol_name_stable(instance);
47+
let func = instance.mangled_name();
4848
self.ensure_struct(
4949
format!("{func}::FnDefStruct"),
5050
format!("{}::FnDefStruct", instance.name()),

kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl GotocCodegenBackend {
133133
format!(
134134
"codegen_function: {}\n{}",
135135
instance.name(),
136-
gcx.symbol_name_stable(instance)
136+
instance.mangled_name()
137137
),
138138
instance.def,
139139
);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ impl<'tcx> CurrentFnCtx<'tcx> {
3939
pub fn new(instance: Instance, gcx: &GotocCtx<'tcx>, body: &Body) -> Self {
4040
let instance_internal = rustc_internal::internal(gcx.tcx, instance);
4141
let readable_name = instance.name();
42-
let name =
43-
if &readable_name == "main" { readable_name.clone() } else { instance.mangled_name() };
42+
let name = instance.mangled_name();
4443
let locals = body.locals().to_vec();
4544
let local_names = body
4645
.var_debug_info

kani-compiler/src/codegen_cprover_gotoc/utils/names.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use cbmc::InternedString;
88
use rustc_hir::def_id::LOCAL_CRATE;
99
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
1010
use rustc_middle::ty::TyCtxt;
11-
use stable_mir::mir::mono::Instance;
1211
use stable_mir::mir::Local;
1312

1413
impl<'tcx> GotocCtx<'tcx> {
@@ -50,15 +49,6 @@ impl<'tcx> GotocCtx<'tcx> {
5049
format!("{var_name}_init")
5150
}
5251

53-
/// Return the mangled name to be used in the symbol table.
54-
///
55-
/// We special case main function in order to support `--function main`.
56-
// TODO: Get rid of this: https://github.com/model-checking/kani/issues/2129
57-
pub fn symbol_name_stable(&self, instance: Instance) -> String {
58-
let pretty = instance.name();
59-
if pretty == "main" { pretty } else { instance.mangled_name() }
60-
}
61-
6252
/// The name for a tuple field
6353
pub fn tuple_fld_name(n: usize) -> String {
6454
format!("{n}")

kani-compiler/src/kani_middle/metadata.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,12 @@ use stable_mir::CrateDef;
1313

1414
use super::{attributes::KaniAttributes, SourceLocation};
1515

16-
pub fn canonical_mangled_name(instance: Instance) -> String {
17-
let pretty_name = instance.name();
18-
// Main function a special case in order to support `--function main`
19-
// TODO: Get rid of this: https://github.com/model-checking/kani/issues/2129
20-
if pretty_name == "main" { pretty_name } else { instance.mangled_name() }
21-
}
22-
2316
/// Create the harness metadata for a proof harness for a given function.
2417
pub fn gen_proof_metadata(tcx: TyCtxt, instance: Instance, base_name: &Path) -> HarnessMetadata {
2518
let def = instance.def;
2619
let kani_attributes = KaniAttributes::for_instance(tcx, instance);
2720
let pretty_name = instance.name();
28-
let mangled_name = canonical_mangled_name(instance);
21+
let mangled_name = instance.mangled_name();
2922

3023
// We get the body span to include the entire function definition.
3124
// This is required for concrete playback to properly position the generated test.

0 commit comments

Comments
 (0)