Skip to content

Commit 70efafa

Browse files
celinvaltedinski
authored andcommitted
Remove old vector / hash_map hook (rust-lang#40) (rust-lang#612)
We no longer plan to use these hooks so I am deleting them.
1 parent 77f21d3 commit 70efafa

File tree

14 files changed

+6
-566
lines changed

14 files changed

+6
-566
lines changed

compiler/rustc_codegen_rmc/src/codegen/statement.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl<'tcx> GotocCtx<'tcx> {
285285
};
286286

287287
// Unwrap as needed
288-
for (i, t) in tupled_args.iter().enumerate() {
288+
for (i, _) in tupled_args.iter().enumerate() {
289289
// Access the tupled parameters through the `member` operation
290290
let index_param = tupe.clone().member(&i.to_string(), &self.symbol_table);
291291
fargs.push(index_param);

compiler/rustc_codegen_rmc/src/codegen/typ.rs

-4
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,6 @@ impl<'tcx> GotocCtx<'tcx> {
489489
}
490490

491491
fn codegen_ty_inner(&mut self, ty: Ty<'tcx>) -> Type {
492-
if let Some(handler) = self.type_hooks.hook_applies(self.tcx, ty) {
493-
return handler.handle(self, ty);
494-
}
495-
496492
match ty.kind() {
497493
ty::Int(k) => self.codegen_iint(*k),
498494
ty::Bool => Type::c_bool(),

compiler/rustc_codegen_rmc/src/compiler_interface.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use rustc_session::cstore::MetadataLoaderDyn;
2222
use rustc_session::Session;
2323
use std::collections::BTreeMap;
2424
use std::iter::FromIterator;
25-
use std::path::PathBuf;
2625
use tracing::{debug, warn};
2726

2827
// #[derive(RustcEncodable, RustcDecodable)]

compiler/rustc_codegen_rmc/src/context/goto_ctx.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! this structure as input.
1616
1717
use super::current_fn::CurrentFnCtx;
18-
use crate::overrides::{type_and_fn_hooks, GotocHooks, GotocTypeHooks};
18+
use crate::overrides::{fn_hooks, GotocHooks};
1919
use crate::utils::full_crate_name;
2020
use cbmc::goto_program::{DatatypeComponent, Expr, Location, Stmt, Symbol, SymbolTable, Type};
2121
use cbmc::utils::aggr_name;
@@ -42,7 +42,6 @@ pub struct GotocCtx<'tcx> {
4242
/// the generated symbol table for gotoc
4343
pub symbol_table: SymbolTable,
4444
pub hooks: GotocHooks<'tcx>,
45-
pub type_hooks: GotocTypeHooks<'tcx>,
4645
/// the full crate name, including versioning info
4746
pub full_crate_name: String,
4847
/// a global counter for generating unique names for global variables
@@ -56,14 +55,13 @@ pub struct GotocCtx<'tcx> {
5655
/// Constructor
5756
impl<'tcx> GotocCtx<'tcx> {
5857
pub fn new(tcx: TyCtxt<'tcx>) -> GotocCtx<'tcx> {
59-
let (thks, fhks) = type_and_fn_hooks();
58+
let fhks = fn_hooks();
6059
let mm = machine_model_from_session(tcx.sess);
6160
let symbol_table = SymbolTable::new(mm);
6261
GotocCtx {
6362
tcx,
6463
symbol_table,
6564
hooks: fhks,
66-
type_hooks: thks,
6765
full_crate_name: full_crate_name(tcx),
6866
global_var_count: 0,
6967
alloc_map: FxHashMap::default(),

compiler/rustc_codegen_rmc/src/overrides/hooks.rs

+2-40
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,17 @@
88
//! It would be too nasty if we spread around these sort of undocumented hooks in place, so
99
//! this module addresses this issue.
1010
11-
use super::stubs::{HashMapStub, VecStub};
1211
use crate::utils::{instance_name_is, instance_name_starts_with};
1312
use crate::GotocCtx;
1413
use cbmc::goto_program::{BuiltinFn, Expr, Location, Stmt, Symbol, Type};
1514
use rustc_middle::mir::{BasicBlock, Place};
1615
use rustc_middle::ty::layout::LayoutOf;
1716
use rustc_middle::ty::print::with_no_trimmed_paths;
18-
use rustc_middle::ty::{self, Instance, InstanceDef, Ty, TyCtxt};
17+
use rustc_middle::ty::{self, Instance, InstanceDef, TyCtxt};
1918
use rustc_span::Span;
2019
use std::rc::Rc;
2120
use tracing::{debug, warn};
2221

23-
pub trait GotocTypeHook<'tcx> {
24-
fn hook_applies(&self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool;
25-
fn handle(&self, tcx: &mut GotocCtx<'tcx>, ty: Ty<'tcx>) -> Type;
26-
}
27-
2822
pub trait GotocHook<'tcx> {
2923
/// if the hook applies, it means the codegen would do something special to it
3024
fn hook_applies(&self, tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> bool;
@@ -654,7 +648,7 @@ impl<'tcx> GotocHook<'tcx> for SliceFromRawPart {
654648
}
655649
}
656650

657-
fn fn_hooks<'tcx>() -> GotocHooks<'tcx> {
651+
pub fn fn_hooks<'tcx>() -> GotocHooks<'tcx> {
658652
GotocHooks {
659653
hooks: vec![
660654
Rc::new(Panic), //Must go first, so it overrides Nevers
@@ -672,42 +666,10 @@ fn fn_hooks<'tcx>() -> GotocHooks<'tcx> {
672666
Rc::new(RustDealloc),
673667
Rc::new(RustRealloc),
674668
Rc::new(SliceFromRawPart),
675-
Rc::new(VecStub::new()),
676-
Rc::new(HashMapStub::new()),
677669
],
678670
}
679671
}
680672

681-
pub fn type_and_fn_hooks<'tcx>() -> (GotocTypeHooks<'tcx>, GotocHooks<'tcx>) {
682-
let thks = GotocTypeHooks { hooks: vec![Rc::new(HashMapStub::new()), Rc::new(VecStub::new())] };
683-
let fhks = fn_hooks();
684-
(thks, fhks)
685-
}
686-
687-
pub struct GotocTypeHooks<'tcx> {
688-
hooks: Vec<Rc<dyn GotocTypeHook<'tcx> + 'tcx>>,
689-
}
690-
691-
impl<'tcx> GotocTypeHooks<'tcx> {
692-
#[allow(dead_code)]
693-
pub fn default() -> GotocTypeHooks<'tcx> {
694-
type_and_fn_hooks().0
695-
}
696-
697-
pub fn hook_applies(
698-
&self,
699-
tcx: TyCtxt<'tcx>,
700-
ty: Ty<'tcx>,
701-
) -> Option<Rc<dyn GotocTypeHook<'tcx> + 'tcx>> {
702-
for h in &self.hooks {
703-
if h.hook_applies(tcx, ty) {
704-
return Some(h.clone());
705-
}
706-
}
707-
None
708-
}
709-
}
710-
711673
pub struct GotocHooks<'tcx> {
712674
hooks: Vec<Rc<dyn GotocHook<'tcx> + 'tcx>>,
713675
}

compiler/rustc_codegen_rmc/src/overrides/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
//! Instead, we use a "hook" to generate the correct CBMC intrinsic.
88
99
mod hooks;
10-
mod stubs;
1110

12-
pub use hooks::{skip_monomorphize, type_and_fn_hooks, GotocHooks, GotocTypeHooks};
11+
pub use hooks::{fn_hooks, skip_monomorphize, GotocHooks};

compiler/rustc_codegen_rmc/src/overrides/stubs/hash_map_stub.rs

-88
This file was deleted.

compiler/rustc_codegen_rmc/src/overrides/stubs/mod.rs

-8
This file was deleted.

0 commit comments

Comments
 (0)