Skip to content

Commit

Permalink
Remove some unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nilehmann committed Jan 4, 2024
1 parent 5ec4c76 commit 590405b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 112 deletions.
2 changes: 1 addition & 1 deletion crates/flux-fhir-analysis/src/wf/sortck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use flux_middle::{
use itertools::izip;
use rustc_data_structures::unord::UnordMap;
use rustc_errors::IntoDiagnostic;
use rustc_span::Span;
use rustc_span::{def_id::DefId, Span};

use super::errors;

Expand Down
28 changes: 0 additions & 28 deletions crates/flux-middle/src/fhir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,14 +920,6 @@ impl Sort {
matches!(self, Self::Bool)
}

/// Returns `true` if the sort is [`Wildcard`].
///
/// [`Wildcard`]: Sort::Wildcard
#[must_use]
pub fn is_wildcard(&self) -> bool {
matches!(self, Self::Wildcard)
}

pub fn is_numeric(&self) -> bool {
matches!(self, Self::Int | Self::Real)
}
Expand Down Expand Up @@ -1123,10 +1115,6 @@ impl Map {
self.trusted.insert(def_id);
}

pub fn fn_sigs(&self) -> impl Iterator<Item = (LocalDefId, &FnSig)> {
self.fns.iter().map(|(def_id, fn_sig)| (*def_id, fn_sig))
}

pub fn get_fn_sig(&self, def_id: LocalDefId) -> &FnSig {
self.fns
.get(&def_id)
Expand Down Expand Up @@ -1173,10 +1161,6 @@ impl Map {
self.type_aliases.insert(def_id, alias);
}

pub fn type_aliases(&self) -> impl Iterator<Item = &TyAlias> {
self.type_aliases.values()
}

pub fn get_type_alias(&self, def_id: impl Borrow<LocalDefId>) -> &TyAlias {
&self.type_aliases[def_id.borrow()]
}
Expand All @@ -1187,10 +1171,6 @@ impl Map {
self.structs.insert(def_id, struct_def);
}

pub fn structs(&self) -> impl Iterator<Item = &StructDef> {
self.structs.values()
}

pub fn get_struct(&self, def_id: impl Borrow<LocalDefId>) -> &StructDef {
&self.structs[def_id.borrow()]
}
Expand All @@ -1201,10 +1181,6 @@ impl Map {
self.enums.insert(def_id, enum_def);
}

pub fn enums(&self) -> impl Iterator<Item = &EnumDef> {
self.enums.values()
}

pub fn get_enum(&self, def_id: impl Borrow<LocalDefId>) -> &EnumDef {
&self.enums[def_id.borrow()]
}
Expand Down Expand Up @@ -1371,10 +1347,6 @@ impl Map {
&self.sort_decls
}

pub fn sort_decl(&self, name: impl Borrow<Symbol>) -> Option<&SortDecl> {
self.sort_decls.get(name.borrow())
}

pub fn get_flux_item(&self, name: impl Borrow<Symbol>) -> Option<&FluxItem> {
self.flux_items.get(name.borrow())
}
Expand Down
41 changes: 1 addition & 40 deletions crates/flux-middle/src/rty/expr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fmt, slice, sync::OnceLock};
use std::{fmt, sync::OnceLock};

use flux_common::bug;
pub use flux_fixpoint::{BinOp, Constant, UnOp};
Expand All @@ -16,7 +16,6 @@ use crate::{
fhir::FuncKind,
intern::{impl_internable, impl_slice_internable, Interned, List},
rty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable},
rustc::mir::{Place, PlaceElem},
};

pub type Expr = Interned<ExprS>;
Expand Down Expand Up @@ -229,12 +228,6 @@ impl Expr {
.clone()
}

pub fn one() -> Expr {
static ONE: OnceLock<Expr> = OnceLock::new();
ONE.get_or_init(|| ExprKind::Constant(Constant::ONE).intern())
.clone()
}

pub fn int_max(int_ty: IntTy) -> Expr {
let bit_width: u64 = int_ty
.bit_width()
Expand All @@ -260,14 +253,6 @@ impl Expr {
Expr::late_bvar(INNERMOST, 0)
}

pub fn as_tuple(&self) -> &[Expr] {
if let ExprKind::Tuple(tup) = self.kind() {
tup
} else {
slice::from_ref(self)
}
}

pub fn expect_tuple(&self) -> &[Expr] {
if let ExprKind::Tuple(tup) = self.kind() {
tup
Expand Down Expand Up @@ -527,14 +512,6 @@ impl Expr {
self.fold_with(&mut Simplify)
}

pub fn to_var(&self) -> Option<Var> {
if let ExprKind::Var(var) = self.kind() {
Some(*var)
} else {
None
}
}

pub fn to_loc(&self) -> Option<Loc> {
match self.kind() {
ExprKind::Local(local) => Some(Loc::Local(*local)),
Expand All @@ -558,10 +535,6 @@ impl Expr {
matches!(self.kind(), ExprKind::Abs(..))
}

pub fn is_tuple(&self) -> bool {
matches!(self.kind(), ExprKind::Tuple(..))
}

pub fn eta_expand_abs(&self, sorts: &[Sort]) -> Binder<Expr> {
let args = (0..sorts.len())
.map(|idx| Expr::late_bvar(INNERMOST, idx as u32))
Expand Down Expand Up @@ -606,18 +579,6 @@ impl Path {
Path { loc, projection: projection.into() }
}

pub fn from_place(place: &Place) -> Option<Path> {
let mut proj = vec![];
for elem in &place.projection {
if let PlaceElem::Field(field) = elem {
proj.push(*field);
} else {
return None;
}
}
Some(Path::new(Loc::Local(place.local), proj))
}

pub fn projection(&self) -> &[FieldIdx] {
&self.projection[..]
}
Expand Down
24 changes: 0 additions & 24 deletions crates/flux-middle/src/rty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,10 +1173,6 @@ impl Ty {
TyKind::Blocked(ty).intern()
}

pub fn usize() -> Ty {
Ty::uint(UintTy::Usize)
}

pub fn str() -> Ty {
BaseTy::Str.into_ty()
}
Expand Down Expand Up @@ -1318,18 +1314,6 @@ impl TyS {
.unwrap_or_default()
}

pub fn is_closure(&self) -> bool {
self.as_bty_skipping_existentials()
.map(BaseTy::is_closure)
.unwrap_or_default()
}

pub fn is_tuple(&self) -> bool {
self.as_bty_skipping_existentials()
.map(BaseTy::is_tuple)
.unwrap_or_default()
}

pub fn is_array(&self) -> bool {
self.as_bty_skipping_existentials()
.map(BaseTy::is_array)
Expand Down Expand Up @@ -1388,14 +1372,6 @@ impl BaseTy {
matches!(self, BaseTy::Adt(adt_def, _) if adt_def.is_struct())
}

fn is_closure(&self) -> bool {
matches!(self, BaseTy::Closure(..))
}

fn is_tuple(&self) -> bool {
matches!(self, BaseTy::Tuple(..))
}

fn is_array(&self) -> bool {
matches!(self, BaseTy::Array(..))
}
Expand Down
20 changes: 1 addition & 19 deletions crates/flux-middle/src/rustc/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use flux_common::{
};
use itertools::Itertools;
pub use rustc_borrowck::borrow_set::BorrowData;
use rustc_borrowck::consumers::{BodyWithBorrowckFacts, BorrowIndex, RegionInferenceContext};
use rustc_borrowck::consumers::{BodyWithBorrowckFacts, BorrowIndex};
use rustc_data_structures::{fx::FxIndexMap, graph::dominators::Dominators};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::IndexSlice;
Expand Down Expand Up @@ -321,11 +321,6 @@ impl<'tcx> Body<'tcx> {
&self.body_with_facts.body
}

/// see (NOTE:YIELD)
pub fn resume_local(&self) -> Option<Local> {
self.args_iter().nth(1)
}

#[inline]
pub fn args_iter(&self) -> impl ExactSizeIterator<Item = Local> {
(1..self.body_with_facts.body.arg_count + 1).map(Local::new)
Expand Down Expand Up @@ -364,10 +359,6 @@ impl<'tcx> Body<'tcx> {
)
}

pub fn region_inference_context(&self) -> &RegionInferenceContext<'tcx> {
&self.body_with_facts.region_inference_context
}

pub fn borrow_data(&self, idx: BorrowIndex) -> &BorrowData<'tcx> {
self.body_with_facts
.borrow_set
Expand Down Expand Up @@ -459,15 +450,6 @@ impl PlaceTy {
}
}

impl PlaceElem {
pub fn as_field(&self) -> Option<FieldIdx> {
match self {
PlaceElem::Field(field) => Some(*field),
_ => None,
}
}
}

/// Replicate the [`InferCtxt`] used for mir typeck by generating region variables for every region in
/// the `RegionInferenceContext`
///
Expand Down

0 comments on commit 590405b

Please sign in to comment.