From 590405b002aab9e7c88a585130fc531530f4b7a1 Mon Sep 17 00:00:00 2001 From: Nico Lehmann Date: Thu, 4 Jan 2024 09:41:14 -0800 Subject: [PATCH] Remove some unused functions --- crates/flux-fhir-analysis/src/wf/sortck.rs | 2 +- crates/flux-middle/src/fhir.rs | 28 --------------- crates/flux-middle/src/rty/expr.rs | 41 +--------------------- crates/flux-middle/src/rty/mod.rs | 24 ------------- crates/flux-middle/src/rustc/mir.rs | 20 +---------- 5 files changed, 3 insertions(+), 112 deletions(-) diff --git a/crates/flux-fhir-analysis/src/wf/sortck.rs b/crates/flux-fhir-analysis/src/wf/sortck.rs index dbe716faf5..66c304137e 100644 --- a/crates/flux-fhir-analysis/src/wf/sortck.rs +++ b/crates/flux-fhir-analysis/src/wf/sortck.rs @@ -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; diff --git a/crates/flux-middle/src/fhir.rs b/crates/flux-middle/src/fhir.rs index 2808bd06c3..0b1966f10a 100644 --- a/crates/flux-middle/src/fhir.rs +++ b/crates/flux-middle/src/fhir.rs @@ -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) } @@ -1123,10 +1115,6 @@ impl Map { self.trusted.insert(def_id); } - pub fn fn_sigs(&self) -> impl Iterator { - 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) @@ -1173,10 +1161,6 @@ impl Map { self.type_aliases.insert(def_id, alias); } - pub fn type_aliases(&self) -> impl Iterator { - self.type_aliases.values() - } - pub fn get_type_alias(&self, def_id: impl Borrow) -> &TyAlias { &self.type_aliases[def_id.borrow()] } @@ -1187,10 +1171,6 @@ impl Map { self.structs.insert(def_id, struct_def); } - pub fn structs(&self) -> impl Iterator { - self.structs.values() - } - pub fn get_struct(&self, def_id: impl Borrow) -> &StructDef { &self.structs[def_id.borrow()] } @@ -1201,10 +1181,6 @@ impl Map { self.enums.insert(def_id, enum_def); } - pub fn enums(&self) -> impl Iterator { - self.enums.values() - } - pub fn get_enum(&self, def_id: impl Borrow) -> &EnumDef { &self.enums[def_id.borrow()] } @@ -1371,10 +1347,6 @@ impl Map { &self.sort_decls } - pub fn sort_decl(&self, name: impl Borrow) -> Option<&SortDecl> { - self.sort_decls.get(name.borrow()) - } - pub fn get_flux_item(&self, name: impl Borrow) -> Option<&FluxItem> { self.flux_items.get(name.borrow()) } diff --git a/crates/flux-middle/src/rty/expr.rs b/crates/flux-middle/src/rty/expr.rs index 5741ef79b1..ab98a19027 100644 --- a/crates/flux-middle/src/rty/expr.rs +++ b/crates/flux-middle/src/rty/expr.rs @@ -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}; @@ -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; @@ -229,12 +228,6 @@ impl Expr { .clone() } - pub fn one() -> Expr { - static ONE: OnceLock = 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() @@ -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 @@ -527,14 +512,6 @@ impl Expr { self.fold_with(&mut Simplify) } - pub fn to_var(&self) -> Option { - if let ExprKind::Var(var) = self.kind() { - Some(*var) - } else { - None - } - } - pub fn to_loc(&self) -> Option { match self.kind() { ExprKind::Local(local) => Some(Loc::Local(*local)), @@ -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 { let args = (0..sorts.len()) .map(|idx| Expr::late_bvar(INNERMOST, idx as u32)) @@ -606,18 +579,6 @@ impl Path { Path { loc, projection: projection.into() } } - pub fn from_place(place: &Place) -> Option { - 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[..] } diff --git a/crates/flux-middle/src/rty/mod.rs b/crates/flux-middle/src/rty/mod.rs index 5b71b20a6b..450f58d9ea 100644 --- a/crates/flux-middle/src/rty/mod.rs +++ b/crates/flux-middle/src/rty/mod.rs @@ -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() } @@ -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) @@ -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(..)) } diff --git a/crates/flux-middle/src/rustc/mir.rs b/crates/flux-middle/src/rustc/mir.rs index f9bc4e5000..aa313e93c4 100644 --- a/crates/flux-middle/src/rustc/mir.rs +++ b/crates/flux-middle/src/rustc/mir.rs @@ -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; @@ -321,11 +321,6 @@ impl<'tcx> Body<'tcx> { &self.body_with_facts.body } - /// see (NOTE:YIELD) - pub fn resume_local(&self) -> Option { - self.args_iter().nth(1) - } - #[inline] pub fn args_iter(&self) -> impl ExactSizeIterator { (1..self.body_with_facts.body.arg_count + 1).map(Local::new) @@ -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 @@ -459,15 +450,6 @@ impl PlaceTy { } } -impl PlaceElem { - pub fn as_field(&self) -> Option { - 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` ///