From d7791f485ba51a4eda241a0ec70d7933858b124b Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 9 Oct 2020 11:20:28 +0200 Subject: [PATCH 1/8] Remove unused code from rustc_middle --- compiler/rustc_middle/src/middle/privacy.rs | 5 -- .../rustc_middle/src/mir/interpret/value.rs | 9 --- compiler/rustc_middle/src/mir/mod.rs | 56 +------------------ compiler/rustc_middle/src/mir/query.rs | 12 ---- compiler/rustc_middle/src/mir/visit.rs | 10 ---- compiler/rustc_middle/src/ty/codec.rs | 8 --- compiler/rustc_middle/src/ty/context.rs | 4 -- compiler/rustc_middle/src/ty/fold.rs | 51 ++--------------- .../rustc_middle/src/ty/inhabitedness/mod.rs | 8 --- compiler/rustc_middle/src/ty/mod.rs | 32 ----------- .../src/ty/query/on_disk_cache.rs | 23 -------- compiler/rustc_middle/src/ty/subst.rs | 3 - 12 files changed, 7 insertions(+), 214 deletions(-) diff --git a/compiler/rustc_middle/src/middle/privacy.rs b/compiler/rustc_middle/src/middle/privacy.rs index 4756e83b5e9..254b57a005e 100644 --- a/compiler/rustc_middle/src/middle/privacy.rs +++ b/compiler/rustc_middle/src/middle/privacy.rs @@ -3,7 +3,6 @@ //! which are available for use externally when compiled as a library. use rustc_data_structures::fx::FxHashMap; -use rustc_hir::def_id::DefIdSet; use rustc_hir::HirId; use rustc_macros::HashStable; use std::fmt; @@ -59,7 +58,3 @@ impl fmt::Debug for AccessLevels { fmt::Debug::fmt(&self.map, f) } } - -/// A set containing all exported definitions from external crates. -/// The set does not contain any entries from local crates. -pub type ExternalExports = DefIdSet; diff --git a/compiler/rustc_middle/src/mir/interpret/value.rs b/compiler/rustc_middle/src/mir/interpret/value.rs index 893ab79f4f5..cb8782ce817 100644 --- a/compiler/rustc_middle/src/mir/interpret/value.rs +++ b/compiler/rustc_middle/src/mir/interpret/value.rs @@ -56,15 +56,6 @@ impl<'tcx> ConstValue<'tcx> { } } - pub fn try_to_str_slice(&self) -> Option<&'tcx str> { - if let ConstValue::Slice { data, start, end } = *self { - std::str::from_utf8(data.inspect_with_uninit_and_ptr_outside_interpreter(start..end)) - .ok() - } else { - None - } - } - pub fn try_to_bits(&self, size: Size) -> Option { self.try_to_scalar()?.to_bits(size).ok() } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index ef0639bcd79..16472c78757 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -3,7 +3,7 @@ //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html use crate::mir::coverage::{CodeRegion, CoverageKind}; -use crate::mir::interpret::{Allocation, ConstValue, GlobalAlloc, Scalar}; +use crate::mir::interpret::{Allocation, GlobalAlloc, Scalar}; use crate::mir::visit::MirVisitable; use crate::ty::adjustment::PointerCast; use crate::ty::codec::{TyDecoder, TyEncoder}; @@ -460,17 +460,6 @@ impl<'tcx> Body<'tcx> { } } - /// Checks if `sub` is a sub scope of `sup` - pub fn is_sub_scope(&self, mut sub: SourceScope, sup: SourceScope) -> bool { - while sub != sup { - match self.source_scopes[sub].parent_scope { - None => return false, - Some(p) => sub = p, - } - } - true - } - /// Returns the return type; it always return first element from `local_decls` array. #[inline] pub fn return_ty(&self) -> Ty<'tcx> { @@ -1978,45 +1967,6 @@ impl<'tcx> Operand<'tcx> { }) } - /// Convenience helper to make a `Scalar` from the given `Operand`, assuming that `Operand` - /// wraps a constant literal value. Panics if this is not the case. - pub fn scalar_from_const(operand: &Operand<'tcx>) -> Scalar { - match operand { - Operand::Constant(constant) => match constant.literal.val.try_to_scalar() { - Some(scalar) => scalar, - _ => panic!("{:?}: Scalar value expected", constant.literal.val), - }, - _ => panic!("{:?}: Constant expected", operand), - } - } - - /// Convenience helper to make a literal-like constant from a given `&str` slice. - /// Since this is used to synthesize MIR, assumes `user_ty` is None. - pub fn const_from_str(tcx: TyCtxt<'tcx>, val: &str, span: Span) -> Operand<'tcx> { - let tcx = tcx; - let allocation = Allocation::from_byte_aligned_bytes(val.as_bytes()); - let allocation = tcx.intern_const_alloc(allocation); - let const_val = ConstValue::Slice { data: allocation, start: 0, end: val.len() }; - let ty = tcx.mk_imm_ref(tcx.lifetimes.re_erased, tcx.types.str_); - Operand::Constant(box Constant { - span, - user_ty: None, - literal: ty::Const::from_value(tcx, const_val, ty), - }) - } - - /// Convenience helper to make a `ConstValue` from the given `Operand`, assuming that `Operand` - /// wraps a constant value (such as a `&str` slice). Panics if this is not the case. - pub fn value_from_const(operand: &Operand<'tcx>) -> ConstValue<'tcx> { - match operand { - Operand::Constant(constant) => match constant.literal.val.try_to_value() { - Some(const_value) => const_value, - _ => panic!("{:?}: ConstValue expected", constant.literal.val), - }, - _ => panic!("{:?}: Constant expected", operand), - } - } - pub fn to_copy(&self) -> Self { match *self { Operand::Copy(_) | Operand::Constant(_) => self.clone(), @@ -2413,10 +2363,6 @@ impl<'tcx> UserTypeProjections { self.contents.is_empty() } - pub fn from_projections(projs: impl Iterator) -> Self { - UserTypeProjections { contents: projs.collect() } - } - pub fn projections_and_spans( &self, ) -> impl Iterator + ExactSizeIterator { diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index b5cdd7edb8d..6022194342d 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -413,18 +413,6 @@ pub struct CoverageInfo { /// For more information on why this is needed, consider looking /// at the docs for `WithOptConstParam` itself. impl<'tcx> TyCtxt<'tcx> { - #[inline] - pub fn mir_borrowck_opt_const_arg( - self, - def: ty::WithOptConstParam, - ) -> &'tcx BorrowCheckResult<'tcx> { - if let Some(param_did) = def.const_param_did { - self.mir_borrowck_const_arg((def.did, param_did)) - } else { - self.mir_borrowck(def.did) - } - } - #[inline] pub fn mir_const_qualif_opt_const_arg( self, diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 1adebe30b5e..58dd0bc00d2 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -1186,16 +1186,6 @@ impl PlaceContext { ) } - /// Returns `true` if this place context represents a storage live marker. - pub fn is_storage_live_marker(&self) -> bool { - matches!(self, PlaceContext::NonUse(NonUseContext::StorageLive)) - } - - /// Returns `true` if this place context represents a storage dead marker. - pub fn is_storage_dead_marker(&self) -> bool { - matches!(self, PlaceContext::NonUse(NonUseContext::StorageDead)) - } - /// Returns `true` if this place context represents a use that potentially changes the value. pub fn is_mutating_use(&self) -> bool { matches!(self, PlaceContext::MutatingUse(..)) diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index 8ea34f9161a..aaf6a857043 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -182,14 +182,6 @@ pub trait TyDecoder<'tcx>: Decoder { where F: FnOnce(&mut Self) -> Result, Self::Error>; - fn cached_predicate_for_shorthand( - &mut self, - shorthand: usize, - or_insert_with: F, - ) -> Result, Self::Error> - where - F: FnOnce(&mut Self) -> Result, Self::Error>; - fn with_position(&mut self, pos: usize, f: F) -> R where F: FnOnce(&mut Self) -> R; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index e67a76f0111..2e794128eac 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -534,10 +534,6 @@ impl<'tcx> TypeckResults<'tcx> { self.node_type(pat.hir_id) } - pub fn pat_ty_opt(&self, pat: &hir::Pat<'_>) -> Option> { - self.node_type_opt(pat.hir_id) - } - // Returns the type of an expression as a monotype. // // NB (1): This is the PRE-ADJUSTMENT TYPE for the expression. That is, in diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index 84134bedef0..5524d91a6d5 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -97,9 +97,6 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone { fn has_infer_types_or_consts(&self) -> bool { self.has_type_flags(TypeFlags::HAS_TY_INFER | TypeFlags::HAS_CT_INFER) } - fn has_infer_consts(&self) -> bool { - self.has_type_flags(TypeFlags::HAS_CT_INFER) - } fn needs_infer(&self) -> bool { self.has_type_flags(TypeFlags::NEEDS_INFER) } @@ -113,9 +110,6 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone { fn needs_subst(&self) -> bool { self.has_type_flags(TypeFlags::NEEDS_SUBST) } - fn has_re_placeholders(&self) -> bool { - self.has_type_flags(TypeFlags::HAS_RE_PLACEHOLDER) - } /// "Free" regions in this context means that it has any region /// that is not (a) erased or (b) late-bound. fn has_free_regions(&self) -> bool { @@ -719,21 +713,15 @@ impl<'tcx> TyCtxt<'tcx> { // vars. See comment on `shift_vars_through_binders` method in // `subst.rs` for more details. -enum Direction { - In, - Out, -} - struct Shifter<'tcx> { tcx: TyCtxt<'tcx>, current_index: ty::DebruijnIndex, amount: u32, - direction: Direction, } impl Shifter<'tcx> { - pub fn new(tcx: TyCtxt<'tcx>, amount: u32, direction: Direction) -> Self { - Shifter { tcx, current_index: ty::INNERMOST, amount, direction } + pub fn new(tcx: TyCtxt<'tcx>, amount: u32) -> Self { + Shifter { tcx, current_index: ty::INNERMOST, amount } } } @@ -755,13 +743,7 @@ impl TypeFolder<'tcx> for Shifter<'tcx> { if self.amount == 0 || debruijn < self.current_index { r } else { - let debruijn = match self.direction { - Direction::In => debruijn.shifted_in(self.amount), - Direction::Out => { - assert!(debruijn.as_u32() >= self.amount); - debruijn.shifted_out(self.amount) - } - }; + let debruijn = debruijn.shifted_in(self.amount); let shifted = ty::ReLateBound(debruijn, br); self.tcx.mk_region(shifted) } @@ -776,13 +758,7 @@ impl TypeFolder<'tcx> for Shifter<'tcx> { if self.amount == 0 || debruijn < self.current_index { ty } else { - let debruijn = match self.direction { - Direction::In => debruijn.shifted_in(self.amount), - Direction::Out => { - assert!(debruijn.as_u32() >= self.amount); - debruijn.shifted_out(self.amount) - } - }; + let debruijn = debruijn.shifted_in(self.amount); self.tcx.mk_ty(ty::Bound(debruijn, bound_ty)) } } @@ -796,13 +772,7 @@ impl TypeFolder<'tcx> for Shifter<'tcx> { if self.amount == 0 || debruijn < self.current_index { ct } else { - let debruijn = match self.direction { - Direction::In => debruijn.shifted_in(self.amount), - Direction::Out => { - assert!(debruijn.as_u32() >= self.amount); - debruijn.shifted_out(self.amount) - } - }; + let debruijn = debruijn.shifted_in(self.amount); self.tcx.mk_const(ty::Const { val: ty::ConstKind::Bound(debruijn, bound_ct), ty }) } } else { @@ -830,16 +800,7 @@ where { debug!("shift_vars(value={:?}, amount={})", value, amount); - value.fold_with(&mut Shifter::new(tcx, amount, Direction::In)) -} - -pub fn shift_out_vars<'tcx, T>(tcx: TyCtxt<'tcx>, value: &T, amount: u32) -> T -where - T: TypeFoldable<'tcx>, -{ - debug!("shift_out_vars(value={:?}, amount={})", value, amount); - - value.fold_with(&mut Shifter::new(tcx, amount, Direction::Out)) + value.fold_with(&mut Shifter::new(tcx, amount)) } /// An "escaping var" is a bound var whose binder is not part of `t`. A bound var can be a diff --git a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs index 2c1179c21fb..bf1f5b81c9f 100644 --- a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs +++ b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs @@ -104,14 +104,6 @@ impl<'tcx> TyCtxt<'tcx> { // ``` ty.uninhabited_from(self, param_env).contains(self, module) } - - pub fn is_ty_uninhabited_from_any_module( - self, - ty: Ty<'tcx>, - param_env: ty::ParamEnv<'tcx>, - ) -> bool { - !ty.uninhabited_from(self, param_env).is_empty() - } } impl<'tcx> AdtDef { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index cccfc5eced9..275888b0ce2 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -7,7 +7,6 @@ pub use self::Variance::*; use crate::hir::exports::ExportMap; use crate::ich::StableHashingContext; -use crate::infer::canonical::Canonical; use crate::middle::cstore::CrateStoreDyn; use crate::middle::resolve_lifetime::ObjectLifetimeDefault; use crate::mir::interpret::ErrorHandled; @@ -656,8 +655,6 @@ impl<'a, 'tcx> HashStable> for TyS<'tcx> { #[rustc_diagnostic_item = "Ty"] pub type Ty<'tcx> = &'tcx TyS<'tcx>; -pub type CanonicalTy<'tcx> = Canonical<'tcx, Ty<'tcx>>; - #[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)] pub struct UpvarPath { pub hir_id: hir::HirId, @@ -767,10 +764,6 @@ pub enum IntVarValue { pub struct FloatVarValue(pub ast::FloatTy); impl ty::EarlyBoundRegion { - pub fn to_bound_region(&self) -> ty::BoundRegion { - ty::BoundRegion::BrNamed(self.def_id, self.name) - } - /// Does this early bound region have a name? Early bound regions normally /// always have names except when using anonymous lifetimes (`'_`). pub fn has_name(&self) -> bool { @@ -821,14 +814,6 @@ impl GenericParamDef { bug!("cannot convert a non-lifetime parameter def to an early bound region") } } - - pub fn to_bound_region(&self) -> ty::BoundRegion { - if let GenericParamDefKind::Lifetime = self.kind { - self.to_early_bound_region_data().to_bound_region() - } else { - bug!("cannot convert a non-lifetime parameter def to an early bound region") - } - } } #[derive(Default)] @@ -1003,22 +988,6 @@ impl<'tcx> GenericPredicates<'tcx> { instantiated.predicates.extend(self.predicates.iter().map(|(p, _)| p)); instantiated.spans.extend(self.predicates.iter().map(|(_, s)| s)); } - - pub fn instantiate_supertrait( - &self, - tcx: TyCtxt<'tcx>, - poly_trait_ref: &ty::PolyTraitRef<'tcx>, - ) -> InstantiatedPredicates<'tcx> { - assert_eq!(self.parent, None); - InstantiatedPredicates { - predicates: self - .predicates - .iter() - .map(|(pred, _)| pred.subst_supertrait(tcx, poly_trait_ref)) - .collect(), - spans: self.predicates.iter().map(|(_, sp)| *sp).collect(), - } - } } #[derive(Debug)] @@ -1303,7 +1272,6 @@ impl<'tcx> PolyTraitPredicate<'tcx> { #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] #[derive(HashStable, TypeFoldable)] pub struct OutlivesPredicate(pub A, pub B); // `A: B` -pub type PolyOutlivesPredicate = ty::Binder>; pub type RegionOutlivesPredicate<'tcx> = OutlivesPredicate, ty::Region<'tcx>>; pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate, ty::Region<'tcx>>; pub type PolyRegionOutlivesPredicate<'tcx> = ty::Binder>; diff --git a/compiler/rustc_middle/src/ty/query/on_disk_cache.rs b/compiler/rustc_middle/src/ty/query/on_disk_cache.rs index 6cfa6dbeccd..173e9a31928 100644 --- a/compiler/rustc_middle/src/ty/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/ty/query/on_disk_cache.rs @@ -601,29 +601,6 @@ impl<'a, 'tcx> TyDecoder<'tcx> for CacheDecoder<'a, 'tcx> { Ok(ty) } - fn cached_predicate_for_shorthand( - &mut self, - shorthand: usize, - or_insert_with: F, - ) -> Result, Self::Error> - where - F: FnOnce(&mut Self) -> Result, Self::Error>, - { - let tcx = self.tcx(); - - let cache_key = - ty::CReaderCacheKey { cnum: CrateNum::ReservedForIncrCompCache, pos: shorthand }; - - if let Some(&pred) = tcx.pred_rcache.borrow().get(&cache_key) { - return Ok(pred); - } - - let pred = or_insert_with(self)?; - // This may overwrite the entry, but it should overwrite with the same value. - tcx.pred_rcache.borrow_mut().insert_same(cache_key, pred); - Ok(pred) - } - fn with_position(&mut self, pos: usize, f: F) -> R where F: FnOnce(&mut Self) -> R, diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index 1bd3bcb6a4d..7d96adb7c8b 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -1,6 +1,5 @@ // Type substitutions. -use crate::infer::canonical::Canonical; use crate::ty::codec::{TyDecoder, TyEncoder}; use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use crate::ty::sty::{ClosureSubsts, GeneratorSubsts}; @@ -648,8 +647,6 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> { } } -pub type CanonicalUserSubsts<'tcx> = Canonical<'tcx, UserSubsts<'tcx>>; - /// Stores the user-given substs to reach some fully qualified path /// (e.g., `::Item` or `::Item`). #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] From 49d4a756f1138d8246abb1c027490d1ea37be920 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 9 Oct 2020 11:20:56 +0200 Subject: [PATCH 2/8] Remove unused code from rustc_ast --- compiler/rustc_ast/src/ast.rs | 38 --------------------------- compiler/rustc_ast/src/attr/mod.rs | 9 ------- compiler/rustc_ast/src/token.rs | 10 ------- compiler/rustc_ast/src/tokenstream.rs | 6 ----- compiler/rustc_ast/src/util/parser.rs | 1 - 5 files changed, 64 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 245353c2e07..8f156aea2ff 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -167,13 +167,6 @@ pub enum GenericArgs { } impl GenericArgs { - pub fn is_parenthesized(&self) -> bool { - match *self { - Parenthesized(..) => true, - _ => false, - } - } - pub fn is_angle_bracketed(&self) -> bool { match *self { AngleBracketed(..) => true, @@ -857,13 +850,6 @@ impl BinOpKind { } } - pub fn is_shift(&self) -> bool { - match *self { - BinOpKind::Shl | BinOpKind::Shr => true, - _ => false, - } - } - pub fn is_comparison(&self) -> bool { use BinOpKind::*; // Note for developers: please keep this as is; @@ -873,11 +859,6 @@ impl BinOpKind { And | Or | Add | Sub | Mul | Div | Rem | BitXor | BitAnd | BitOr | Shl | Shr => false, } } - - /// Returns `true` if the binary operator takes its arguments by value - pub fn is_by_value(&self) -> bool { - !self.is_comparison() - } } pub type BinOp = Spanned; @@ -896,14 +877,6 @@ pub enum UnOp { } impl UnOp { - /// Returns `true` if the unary operator takes its argument by value - pub fn is_by_value(u: UnOp) -> bool { - match u { - UnOp::Neg | UnOp::Not => true, - _ => false, - } - } - pub fn to_string(op: UnOp) -> &'static str { match op { UnOp::Deref => "*", @@ -1753,13 +1726,6 @@ impl IntTy { } } - pub fn val_to_string(&self, val: i128) -> String { - // Cast to a `u128` so we can correctly print `INT128_MIN`. All integral types - // are parsed as `u128`, so we wouldn't want to print an extra negative - // sign. - format!("{}{}", val as u128, self.name_str()) - } - pub fn bit_width(&self) -> Option { Some(match *self { IntTy::Isize => return None, @@ -1818,10 +1784,6 @@ impl UintTy { } } - pub fn val_to_string(&self, val: u128) -> String { - format!("{}{}", val, self.name_str()) - } - pub fn bit_width(&self) -> Option { Some(match *self { UintTy::Usize => return None, diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 2782869fb88..8351be222f6 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -101,11 +101,6 @@ impl NestedMetaItem { self.meta_item().is_some() } - /// Returns `true` if the variant is `Literal`. - pub fn is_literal(&self) -> bool { - self.literal().is_some() - } - /// Returns `true` if `self` is a `MetaItem` and the meta item is a word. pub fn is_word(&self) -> bool { self.meta_item().map_or(false, |meta_item| meta_item.is_word()) @@ -232,10 +227,6 @@ impl MetaItem { pub fn is_value_str(&self) -> bool { self.value_str().is_some() } - - pub fn is_meta_item_list(&self) -> bool { - self.meta_item_list().is_some() - } } impl AttrItem { diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index d5b3e87adc3..e3992582c0b 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -54,16 +54,6 @@ pub enum DelimToken { NoDelim, } -impl DelimToken { - pub fn len(self) -> usize { - if self == NoDelim { 0 } else { 1 } - } - - pub fn is_empty(self) -> bool { - self == NoDelim - } -} - #[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] pub enum LitKind { Bool, // AST only, must never appear in a `Token` diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index f201f0b5c66..8acb6b2f375 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -295,12 +295,6 @@ impl TokenStream { .collect(), )) } - - pub fn map TokenTree>(self, mut f: F) -> TokenStream { - TokenStream(Lrc::new( - self.0.iter().map(|(tree, is_joint)| (f(tree.clone()), *is_joint)).collect(), - )) - } } // 99.5%+ of the time we have 1 or 2 elements in this vector. diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index 2ee94965756..be5516ef471 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -231,7 +231,6 @@ impl AssocOp { } } -pub const PREC_RESET: i8 = -100; pub const PREC_CLOSURE: i8 = -40; pub const PREC_JUMP: i8 = -30; pub const PREC_RANGE: i8 = -10; From feaac592a303f7407d604b52aa2abf42be68b40b Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 9 Oct 2020 11:21:30 +0200 Subject: [PATCH 3/8] Remove unused code from rustc_codegen_* --- compiler/rustc_codegen_llvm/src/llvm/mod.rs | 5 ----- compiler/rustc_codegen_ssa/src/back/write.rs | 2 -- compiler/rustc_codegen_ssa/src/base.rs | 2 -- 3 files changed, 9 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index ed9b99188bb..53a404ee019 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -118,11 +118,6 @@ pub fn SetUnnamedAddress(global: &'a Value, unnamed: UnnamedAddr) { } } -pub fn set_thread_local(global: &'a Value, is_thread_local: bool) { - unsafe { - LLVMSetThreadLocal(global, is_thread_local as Bool); - } -} pub fn set_thread_local_mode(global: &'a Value, mode: ThreadLocalMode) { unsafe { LLVMSetThreadLocalMode(global, mode); diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 69a94d8f795..600487d1b7a 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1531,8 +1531,6 @@ fn start_executing_work( } } -pub const CODEGEN_WORKER_ID: usize = usize::MAX; - /// `FatalError` is explicitly not `Send`. #[must_use] pub struct WorkerFatalError; diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 7f918bd168e..9181f3b51a5 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -479,8 +479,6 @@ fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( } } -pub const CODEGEN_WORKER_ID: usize = usize::MAX; - pub fn codegen_crate( backend: B, tcx: TyCtxt<'tcx>, From 6897619d6d7c530d071cb8587d12c5de3353aa75 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 9 Oct 2020 11:22:08 +0200 Subject: [PATCH 4/8] Remove unused code from rustc_hir --- compiler/rustc_hir/src/definitions.rs | 4 --- compiler/rustc_hir/src/hir.rs | 52 --------------------------- compiler/rustc_hir/src/hir_id.rs | 2 -- compiler/rustc_hir/src/pat_util.rs | 28 --------------- 4 files changed, 86 deletions(-) diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index 8f76551677c..3f109376a3e 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -188,10 +188,6 @@ pub struct DefPath { } impl DefPath { - pub fn is_local(&self) -> bool { - self.krate == LOCAL_CRATE - } - pub fn make(krate: CrateNum, start_index: DefIndex, mut get_key: FN) -> DefPath where FN: FnMut(DefIndex) -> DefKey, diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 636f67a77c8..2141d5b1ee7 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3,7 +3,6 @@ use crate::def_id::DefId; crate use crate::hir_id::HirId; use crate::{itemlikevisit, LangItem}; -use rustc_ast::node_id::NodeMap; use rustc_ast::util::parser::ExprPrecedence; use rustc_ast::{self as ast, CrateSugar, LlvmAsmDialect}; use rustc_ast::{AttrVec, Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, UintTy}; @@ -306,10 +305,6 @@ impl GenericArgs<'_> { Self { args: &[], bindings: &[], parenthesized: false } } - pub fn is_empty(&self) -> bool { - self.args.is_empty() && self.bindings.is_empty() && !self.parenthesized - } - pub fn inputs(&self) -> &[Ty<'_>] { if self.parenthesized { for arg in self.args { @@ -467,23 +462,6 @@ impl Generics<'hir> { } } - pub fn own_counts(&self) -> GenericParamCount { - // We could cache this as a property of `GenericParamCount`, but - // the aim is to refactor this away entirely eventually and the - // presence of this method will be a constant reminder. - let mut own_counts: GenericParamCount = Default::default(); - - for param in self.params { - match param.kind { - GenericParamKind::Lifetime { .. } => own_counts.lifetimes += 1, - GenericParamKind::Type { .. } => own_counts.types += 1, - GenericParamKind::Const { .. } => own_counts.consts += 1, - }; - } - - own_counts - } - pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'_>> { for param in self.params { if name == param.name.ident().name { @@ -2679,8 +2657,6 @@ pub struct Upvar { pub span: Span, } -pub type CaptureModeMap = NodeMap; - // The TraitCandidate's import_ids is empty if the trait is defined in the same module, and // has length > 0 if the trait is found through an chain of imports, starting with the // import/use statement in the scope where the trait is used. @@ -2766,32 +2742,4 @@ impl<'hir> Node<'hir> { _ => None, } } - - pub fn hir_id(&self) -> Option { - match self { - Node::Item(Item { hir_id, .. }) - | Node::ForeignItem(ForeignItem { hir_id, .. }) - | Node::TraitItem(TraitItem { hir_id, .. }) - | Node::ImplItem(ImplItem { hir_id, .. }) - | Node::Field(StructField { hir_id, .. }) - | Node::AnonConst(AnonConst { hir_id, .. }) - | Node::Expr(Expr { hir_id, .. }) - | Node::Stmt(Stmt { hir_id, .. }) - | Node::Ty(Ty { hir_id, .. }) - | Node::Binding(Pat { hir_id, .. }) - | Node::Pat(Pat { hir_id, .. }) - | Node::Arm(Arm { hir_id, .. }) - | Node::Block(Block { hir_id, .. }) - | Node::Local(Local { hir_id, .. }) - | Node::MacroDef(MacroDef { hir_id, .. }) - | Node::Lifetime(Lifetime { hir_id, .. }) - | Node::Param(Param { hir_id, .. }) - | Node::GenericParam(GenericParam { hir_id, .. }) => Some(*hir_id), - Node::TraitRef(TraitRef { hir_ref_id, .. }) => Some(*hir_ref_id), - Node::PathSegment(PathSegment { hir_id, .. }) => *hir_id, - Node::Variant(Variant { id, .. }) => Some(*id), - Node::Ctor(variant) => variant.ctor_hir_id(), - Node::Crate(_) | Node::Visibility(_) => None, - } - } } diff --git a/compiler/rustc_hir/src/hir_id.rs b/compiler/rustc_hir/src/hir_id.rs index fea850c12d9..cc8ac4cf5be 100644 --- a/compiler/rustc_hir/src/hir_id.rs +++ b/compiler/rustc_hir/src/hir_id.rs @@ -45,5 +45,3 @@ pub const CRATE_HIR_ID: HirId = HirId { owner: LocalDefId { local_def_index: CRATE_DEF_INDEX }, local_id: ItemLocalId::from_u32(0), }; - -pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX; diff --git a/compiler/rustc_hir/src/pat_util.rs b/compiler/rustc_hir/src/pat_util.rs index 2f1b5da8e13..c05d3e44423 100644 --- a/compiler/rustc_hir/src/pat_util.rs +++ b/compiler/rustc_hir/src/pat_util.rs @@ -58,25 +58,6 @@ impl EnumerateAndAdjustIterator for T { } impl hir::Pat<'_> { - pub fn is_refutable(&self) -> bool { - match self.kind { - PatKind::Lit(_) - | PatKind::Range(..) - | PatKind::Path(hir::QPath::Resolved(Some(..), _) | hir::QPath::TypeRelative(..)) => { - true - } - - PatKind::Path(hir::QPath::Resolved(_, ref path)) - | PatKind::TupleStruct(hir::QPath::Resolved(_, ref path), ..) - | PatKind::Struct(hir::QPath::Resolved(_, ref path), ..) => match path.res { - Res::Def(DefKind::Variant, _) => true, - _ => false, - }, - PatKind::Slice(..) => true, - _ => false, - } - } - /// Call `f` on every "binding" in a pattern, e.g., on `a` in /// `match foo() { Some(a) => (), None => () }` pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, Ident)) { @@ -117,15 +98,6 @@ impl hir::Pat<'_> { }) } - /// Checks if the pattern contains any patterns that bind something to - /// an ident or wildcard, e.g., `foo`, or `Foo(_)`, `foo @ Bar(..)`, - pub fn contains_bindings_or_wild(&self) -> bool { - self.satisfies(|p| match p.kind { - PatKind::Binding(..) | PatKind::Wild => true, - _ => false, - }) - } - /// Checks if the pattern satisfies the given predicate on some sub-pattern. fn satisfies(&self, pred: impl Fn(&hir::Pat<'_>) -> bool) -> bool { let mut satisfies = false; From 9ed2177d86f7d80dbd6ce23ab009cd3dc716492c Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 9 Oct 2020 11:22:34 +0200 Subject: [PATCH 5/8] Remove unused code from rustc_infer --- compiler/rustc_infer/src/infer/mod.rs | 31 ------------------- .../rustc_infer/src/infer/nll_relate/mod.rs | 7 ----- compiler/rustc_infer/src/traits/mod.rs | 2 -- 3 files changed, 40 deletions(-) diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 9742f5e2346..ff7bbf0562f 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -113,13 +113,6 @@ impl Default for RegionckMode { } impl RegionckMode { - pub fn suppressed(self) -> bool { - match self { - Self::Solve => false, - Self::Erase { suppress_errors } => suppress_errors, - } - } - /// Indicates that the MIR borrowck will repeat these region /// checks, so we should ignore errors if NLL is (unconditionally) /// enabled. @@ -420,15 +413,6 @@ pub enum SubregionOrigin<'tcx> { #[cfg(target_arch = "x86_64")] static_assert_size!(SubregionOrigin<'_>, 32); -/// Places that type/region parameters can appear. -#[derive(Clone, Copy, Debug)] -pub enum ParameterOrigin { - Path, // foo::bar - MethodCall, // foo.bar() <-- parameters on impl providing bar() - OverloadedOperator, // a + b when overloaded - OverloadedDeref, // *a when overloaded -} - /// Times when we replace late-bound regions with variables: #[derive(Clone, Copy, Debug)] pub enum LateBoundRegionConversionTime { @@ -508,21 +492,6 @@ pub enum NLLRegionVariableOrigin { }, } -impl NLLRegionVariableOrigin { - pub fn is_universal(self) -> bool { - match self { - NLLRegionVariableOrigin::FreeRegion => true, - NLLRegionVariableOrigin::Placeholder(..) => true, - NLLRegionVariableOrigin::Existential { .. } => false, - NLLRegionVariableOrigin::RootEmptyRegion => false, - } - } - - pub fn is_existential(self) -> bool { - !self.is_universal() - } -} - // FIXME(eddyb) investigate overlap between this and `TyOrConstInferVar`. #[derive(Copy, Clone, Debug)] pub enum FixupError<'tcx> { diff --git a/compiler/rustc_infer/src/infer/nll_relate/mod.rs b/compiler/rustc_infer/src/infer/nll_relate/mod.rs index 5295ebfafa8..2fb9f638e36 100644 --- a/compiler/rustc_infer/src/infer/nll_relate/mod.rs +++ b/compiler/rustc_infer/src/infer/nll_relate/mod.rs @@ -28,7 +28,6 @@ use rustc_data_structures::fx::FxHashMap; use rustc_middle::ty::error::TypeError; use rustc_middle::ty::fold::{TypeFoldable, TypeVisitor}; use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation}; -use rustc_middle::ty::subst::GenericArg; use rustc_middle::ty::{self, InferConst, Ty, TyCtxt}; use std::fmt::Debug; @@ -119,12 +118,6 @@ pub trait TypeRelatingDelegate<'tcx> { fn forbid_inference_vars() -> bool; } -#[derive(Clone, Debug)] -struct ScopesAndKind<'tcx> { - scopes: Vec>, - kind: GenericArg<'tcx>, -} - #[derive(Clone, Debug, Default)] struct BoundRegionScope<'tcx> { map: FxHashMap>, diff --git a/compiler/rustc_infer/src/traits/mod.rs b/compiler/rustc_infer/src/traits/mod.rs index a3c4920fa8a..aaf5e958c26 100644 --- a/compiler/rustc_infer/src/traits/mod.rs +++ b/compiler/rustc_infer/src/traits/mod.rs @@ -59,9 +59,7 @@ pub type TraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>; #[cfg(target_arch = "x86_64")] static_assert_size!(PredicateObligation<'_>, 32); -pub type Obligations<'tcx, O> = Vec>; pub type PredicateObligations<'tcx> = Vec>; -pub type TraitObligations<'tcx> = Vec>; pub type Selection<'tcx> = ImplSource<'tcx, PredicateObligation<'tcx>>; From 338fad21621638ed93e4f6cb05c55105b617af71 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 9 Oct 2020 11:22:54 +0200 Subject: [PATCH 6/8] Remove unused code from rustc_query_system --- .../src/dep_graph/dep_node.rs | 4 ---- .../rustc_query_system/src/dep_graph/graph.rs | 5 ----- .../rustc_query_system/src/dep_graph/query.rs | 19 +------------------ 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/compiler/rustc_query_system/src/dep_graph/dep_node.rs b/compiler/rustc_query_system/src/dep_graph/dep_node.rs index e302784cc3e..7808a28dff0 100644 --- a/compiler/rustc_query_system/src/dep_graph/dep_node.rs +++ b/compiler/rustc_query_system/src/dep_graph/dep_node.rs @@ -165,10 +165,6 @@ impl WorkProductId { cgu_name.hash(&mut hasher); WorkProductId { hash: hasher.finish() } } - - pub fn from_fingerprint(fingerprint: Fingerprint) -> WorkProductId { - WorkProductId { hash: fingerprint } - } } impl HashStable for WorkProductId { diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index d70306b4869..85335f0ba50 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -402,11 +402,6 @@ impl DepGraph { self.data.as_ref().unwrap().previous.fingerprint_of(dep_node) } - #[inline] - pub fn prev_dep_node_index_of(&self, dep_node: &DepNode) -> SerializedDepNodeIndex { - self.data.as_ref().unwrap().previous.node_to_index(dep_node) - } - /// Checks whether a previous work product exists for `v` and, if /// so, return the path that leads to it. Used to skip doing work. pub fn previous_work_product(&self, v: &WorkProductId) -> Option { diff --git a/compiler/rustc_query_system/src/dep_graph/query.rs b/compiler/rustc_query_system/src/dep_graph/query.rs index fb313d2658f..a27b716b95a 100644 --- a/compiler/rustc_query_system/src/dep_graph/query.rs +++ b/compiler/rustc_query_system/src/dep_graph/query.rs @@ -1,7 +1,5 @@ use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::graph::implementation::{ - Direction, Graph, NodeIndex, INCOMING, OUTGOING, -}; +use rustc_data_structures::graph::implementation::{Direction, Graph, NodeIndex, INCOMING}; use super::{DepKind, DepNode}; @@ -52,23 +50,8 @@ impl DepGraphQuery { } } - /// All nodes reachable from `node`. In other words, things that - /// will have to be recomputed if `node` changes. - pub fn transitive_successors(&self, node: &DepNode) -> Vec<&DepNode> { - self.reachable_nodes(node, OUTGOING) - } - /// All nodes that can reach `node`. pub fn transitive_predecessors(&self, node: &DepNode) -> Vec<&DepNode> { self.reachable_nodes(node, INCOMING) } - - /// Just the outgoing edges from `node`. - pub fn immediate_successors(&self, node: &DepNode) -> Vec<&DepNode> { - if let Some(&index) = self.indices.get(&node) { - self.graph.successor_nodes(index).map(|s| self.graph.node_data(s)).collect() - } else { - vec![] - } - } } From 58b3923ad377e79a0517ec15a672e3f8f90b10b4 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 9 Oct 2020 11:23:24 +0200 Subject: [PATCH 7/8] Remove unused code from rustc_span --- compiler/rustc_span/src/hygiene.rs | 8 -------- compiler/rustc_span/src/lib.rs | 6 ------ compiler/rustc_span/src/source_map.rs | 9 --------- 3 files changed, 23 deletions(-) diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index fb80dcb7561..31f3d8e3791 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -619,14 +619,6 @@ impl SyntaxContext { HygieneData::with(|data| data.outer_mark(self)) } - #[inline] - pub fn outer_mark_with_data(self) -> (ExpnId, Transparency, ExpnData) { - HygieneData::with(|data| { - let (expn_id, transparency) = data.outer_mark(self); - (expn_id, transparency, data.expn_data(expn_id).clone()) - }) - } - pub fn dollar_crate_name(self) -> Symbol { HygieneData::with(|data| data.syntax_context_data[self.0 as usize].dollar_crate_name) } diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 925f1bd33cb..d036c078049 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -223,12 +223,6 @@ impl FileName { } } - pub fn quote_expansion_source_code(src: &str) -> FileName { - let mut hasher = StableHasher::new(); - src.hash(&mut hasher); - FileName::QuoteExpansion(hasher.finish()) - } - pub fn macro_expansion_source_code(src: &str) -> FileName { let mut hasher = StableHasher::new(); src.hash(&mut hasher); diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index fdb031fd9b3..3b929c4acb9 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -451,15 +451,6 @@ impl SourceMap { } } - /// Returns a new `Span` covering the start and end `BytePos`s of the file containing the given - /// `pos`. This can be used to quickly determine if another `BytePos` or `Span` is from the same - /// file. - pub fn lookup_file_span(&self, pos: BytePos) -> Span { - let idx = self.lookup_source_file_idx(pos); - let SourceFile { start_pos, end_pos, .. } = *(*self.files.borrow().source_files)[idx]; - Span::with_root_ctxt(start_pos, end_pos) - } - /// Returns `Some(span)`, a union of the LHS and RHS span. The LHS must precede the RHS. If /// there are gaps between LHS and RHS, the resulting union will cross these gaps. /// For this to work, From 215cd36e1cff1806429806cb5be81f6d1a5f98b0 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 9 Oct 2020 11:23:40 +0200 Subject: [PATCH 8/8] Remove unused code from remaining compiler crates --- .../rustc_data_structures/src/work_queue.rs | 6 -- compiler/rustc_errors/src/diagnostic.rs | 13 --- compiler/rustc_errors/src/emitter.rs | 2 - compiler/rustc_expand/src/base.rs | 14 --- compiler/rustc_expand/src/build.rs | 97 ------------------- compiler/rustc_fs_util/src/lib.rs | 27 ------ compiler/rustc_hir_pretty/src/lib.rs | 6 -- compiler/rustc_lint/src/context.rs | 4 - compiler/rustc_metadata/src/rmeta/decoder.rs | 21 ---- .../src/dataflow/framework/engine.rs | 9 -- compiler/rustc_parse/src/lib.rs | 16 --- compiler/rustc_session/src/session.rs | 2 - .../src/traits/select/mod.rs | 4 - 13 files changed, 221 deletions(-) diff --git a/compiler/rustc_data_structures/src/work_queue.rs b/compiler/rustc_data_structures/src/work_queue.rs index 0c848eb144d..cc562bc1e4d 100644 --- a/compiler/rustc_data_structures/src/work_queue.rs +++ b/compiler/rustc_data_structures/src/work_queue.rs @@ -14,12 +14,6 @@ pub struct WorkQueue { } impl WorkQueue { - /// Creates a new work queue with all the elements from (0..len). - #[inline] - pub fn with_all(len: usize) -> Self { - WorkQueue { deque: (0..len).map(T::new).collect(), set: BitSet::new_filled(len) } - } - /// Creates a new work queue that starts empty, where elements range from (0..len). #[inline] pub fn with_none(len: usize) -> Self { diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 870f7b81e21..91bfc6296b1 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -121,11 +121,6 @@ impl Diagnostic { self.level == Level::Cancelled } - /// Set the sorting span. - pub fn set_sort_span(&mut self, sp: Span) { - self.sort_span = sp; - } - /// Adds a span/label to be included in the resulting snippet. /// /// This is pushed onto the [`MultiSpan`] that was created when the diagnostic @@ -535,14 +530,6 @@ impl Diagnostic { &self.message } - /// Used by a lint. Copies over all details *but* the "main - /// message". - pub fn copy_details_not_message(&mut self, from: &Diagnostic) { - self.span = from.span.clone(); - self.code = from.code.clone(); - self.children.extend(from.children.iter().cloned()) - } - /// Convenience function for internal use, clients should use one of the /// public methods above. pub fn sub( diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 98cbf98df92..b5155f8e910 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -510,8 +510,6 @@ impl Emitter for SilentEmitter { fn emit_diagnostic(&mut self, _: &Diagnostic) {} } -/// Maximum number of lines we will print for each error; arbitrary. -pub const MAX_HIGHLIGHT_LINES: usize = 6; /// Maximum number of lines we will print for a multiline suggestion; arbitrary. /// /// This should be replaced with a more involved mechanism to output multiline suggestions that diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index f7651ca0ba6..b0e43a260e9 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -148,17 +148,6 @@ impl Annotatable { } } - pub fn map_item_or(self, mut f: F, mut or: G) -> Annotatable - where - F: FnMut(P) -> P, - G: FnMut(Annotatable) -> Annotatable, - { - match self { - Annotatable::Item(i) => Annotatable::Item(f(i)), - _ => or(self), - } - } - pub fn expect_trait_item(self) -> P { match self { Annotatable::TraitItem(i) => i, @@ -1052,9 +1041,6 @@ impl<'a> ExtCtxt<'a> { .chain(components.iter().map(|&s| Ident::with_dummy_span(s))) .collect() } - pub fn name_of(&self, st: &str) -> Symbol { - Symbol::intern(st) - } pub fn check_unused_macros(&mut self) { self.resolver.check_unused_macros(); diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index a5a7ee6c9a3..1c9bfb902d6 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -139,24 +139,6 @@ impl<'a> ExtCtxt<'a> { ast::Lifetime { id: ast::DUMMY_NODE_ID, ident: ident.with_span_pos(span) } } - pub fn lifetime_def( - &self, - span: Span, - ident: Ident, - attrs: Vec, - bounds: ast::GenericBounds, - ) -> ast::GenericParam { - let lifetime = self.lifetime(span, ident); - ast::GenericParam { - ident: lifetime.ident, - id: lifetime.id, - attrs: attrs.into(), - bounds, - kind: ast::GenericParamKind::Lifetime, - is_placeholder: false, - } - } - pub fn stmt_expr(&self, expr: P) -> ast::Stmt { ast::Stmt { id: ast::DUMMY_NODE_ID, @@ -465,24 +447,6 @@ impl<'a> ExtCtxt<'a> { self.pat_tuple_struct(span, path, vec![pat]) } - pub fn pat_none(&self, span: Span) -> P { - let some = self.std_path(&[sym::option, sym::Option, sym::None]); - let path = self.path_global(span, some); - self.pat_path(span, path) - } - - pub fn pat_ok(&self, span: Span, pat: P) -> P { - let some = self.std_path(&[sym::result, sym::Result, sym::Ok]); - let path = self.path_global(span, some); - self.pat_tuple_struct(span, path, vec![pat]) - } - - pub fn pat_err(&self, span: Span, pat: P) -> P { - let some = self.std_path(&[sym::result, sym::Result, sym::Err]); - let path = self.path_global(span, some); - self.pat_tuple_struct(span, path, vec![pat]) - } - pub fn arm(&self, span: Span, pat: P, expr: P) -> ast::Arm { ast::Arm { attrs: vec![], @@ -514,26 +478,6 @@ impl<'a> ExtCtxt<'a> { self.expr(span, ast::ExprKind::If(cond, self.block_expr(then), els)) } - pub fn lambda_fn_decl( - &self, - span: Span, - fn_decl: P, - body: P, - fn_decl_span: Span, - ) -> P { - self.expr( - span, - ast::ExprKind::Closure( - ast::CaptureBy::Ref, - ast::Async::No, - ast::Movability::Movable, - fn_decl, - body, - fn_decl_span, - ), - ) - } - pub fn lambda(&self, span: Span, ids: Vec, body: P) -> P { let fn_decl = self.fn_decl( ids.iter().map(|id| self.param(span, *id, self.ty(span, ast::TyKind::Infer))).collect(), @@ -610,47 +554,6 @@ impl<'a> ExtCtxt<'a> { }) } - pub fn variant(&self, span: Span, ident: Ident, tys: Vec>) -> ast::Variant { - let vis_span = span.shrink_to_lo(); - let fields: Vec<_> = tys - .into_iter() - .map(|ty| ast::StructField { - span: ty.span, - ty, - ident: None, - vis: ast::Visibility { - span: vis_span, - kind: ast::VisibilityKind::Inherited, - tokens: None, - }, - attrs: Vec::new(), - id: ast::DUMMY_NODE_ID, - is_placeholder: false, - }) - .collect(); - - let vdata = if fields.is_empty() { - ast::VariantData::Unit(ast::DUMMY_NODE_ID) - } else { - ast::VariantData::Tuple(fields, ast::DUMMY_NODE_ID) - }; - - ast::Variant { - attrs: Vec::new(), - data: vdata, - disr_expr: None, - id: ast::DUMMY_NODE_ID, - ident, - vis: ast::Visibility { - span: vis_span, - kind: ast::VisibilityKind::Inherited, - tokens: None, - }, - span, - is_placeholder: false, - } - } - pub fn item_static( &self, span: Span, diff --git a/compiler/rustc_fs_util/src/lib.rs b/compiler/rustc_fs_util/src/lib.rs index 289b9f30c3b..7742961e65d 100644 --- a/compiler/rustc_fs_util/src/lib.rs +++ b/compiler/rustc_fs_util/src/lib.rs @@ -75,33 +75,6 @@ pub fn link_or_copy, Q: AsRef>(p: P, q: Q) -> io::Result
  • , Q: AsRef>( - p: P, - q: Q, -) -> io::Result { - let p = p.as_ref(); - let q = q.as_ref(); - match fs::rename(p, q) { - Ok(()) => Ok(RenameOrCopyRemove::Rename), - Err(_) => match fs::copy(p, q) { - Ok(_) => { - fs::remove_file(p)?; - Ok(RenameOrCopyRemove::CopyRemove) - } - Err(e) => Err(e), - }, - } -} - #[cfg(unix)] pub fn path_to_c_string(p: &Path) -> CString { use std::ffi::OsStr; diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index f6e4b1fb418..5a5efce37e5 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -44,9 +44,6 @@ pub trait PpAnn { fn nested(&self, _state: &mut State<'_>, _nested: Nested) {} fn pre(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {} fn post(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {} - fn try_fetch_item(&self, _: hir::HirId) -> Option<&hir::Item<'_>> { - None - } } pub struct NoAnn; @@ -54,9 +51,6 @@ impl PpAnn for NoAnn {} pub const NO_ANN: &dyn PpAnn = &NoAnn; impl PpAnn for hir::Crate<'_> { - fn try_fetch_item(&self, item: hir::HirId) -> Option<&hir::Item<'_>> { - Some(self.item(item)) - } fn nested(&self, state: &mut State<'_>, nested: Nested) { match nested { Nested::Item(id) => state.print_item(self.item(id.id)), diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 7a3035e5b46..48270eb59a0 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -711,10 +711,6 @@ impl<'tcx> LateContext<'tcx> { } } - pub fn current_lint_root(&self) -> hir::HirId { - self.last_node_with_lint_attrs - } - /// Check if a `DefId`'s path matches the given absolute type path usage. /// /// Anonymous scopes such as `extern` imports are matched with `kw::Invalid`; diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 2662f6b6ed6..b01a55b48da 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -313,27 +313,6 @@ impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> { Ok(ty) } - fn cached_predicate_for_shorthand( - &mut self, - shorthand: usize, - or_insert_with: F, - ) -> Result, Self::Error> - where - F: FnOnce(&mut Self) -> Result, Self::Error>, - { - let tcx = self.tcx(); - - let key = ty::CReaderCacheKey { cnum: self.cdata().cnum, pos: shorthand }; - - if let Some(&pred) = tcx.pred_rcache.borrow().get(&key) { - return Ok(pred); - } - - let pred = or_insert_with(self)?; - tcx.pred_rcache.borrow_mut().insert(key, pred); - Ok(pred) - } - fn with_position(&mut self, pos: usize, f: F) -> R where F: FnOnce(&mut Self) -> R, diff --git a/compiler/rustc_mir/src/dataflow/framework/engine.rs b/compiler/rustc_mir/src/dataflow/framework/engine.rs index c1e500d01b1..1b7264f86a2 100644 --- a/compiler/rustc_mir/src/dataflow/framework/engine.rs +++ b/compiler/rustc_mir/src/dataflow/framework/engine.rs @@ -62,15 +62,6 @@ where let blocks = mir::traversal::reachable(body); visit_results(body, blocks.map(|(bb, _)| bb), self, vis) } - - pub fn visit_in_rpo_with( - &self, - body: &'mir mir::Body<'tcx>, - vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = A::Domain>, - ) { - let blocks = mir::traversal::reverse_postorder(body); - visit_results(body, blocks.map(|(bb, _)| bb), self, vis) - } } /// A solver for dataflow problems. diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index b68d36c9a8e..e952d5d7bfc 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -114,16 +114,6 @@ pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Option( - sess: &'a ParseSess, - path: &Path, -) -> Result, Vec> { - let file = try_file_to_source_file(sess, path, None).map_err(|db| vec![db])?; - maybe_source_file_to_parser(sess, file) -} - /// Given a `source_file` and config, returns a parser. fn source_file_to_parser(sess: &ParseSess, source_file: Lrc) -> Parser<'_> { panictry_buffer!(&sess.span_diagnostic, maybe_source_file_to_parser(sess, source_file)) @@ -146,12 +136,6 @@ fn maybe_source_file_to_parser( Ok(parser) } -// Must preserve old name for now, because `quote!` from the *existing* -// compiler expands into it. -pub fn new_parser_from_tts(sess: &ParseSess, tts: Vec) -> Parser<'_> { - stream_to_parser(sess, tts.into_iter().collect(), crate::MACRO_ARGUMENTS) -} - // Base abstractions /// Given a session and a path and an optional span (for error reporting), diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index ff5e6156d84..9143d0a0f5b 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1586,5 +1586,3 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) { let handler = rustc_errors::Handler::with_emitter(true, None, emitter); handler.struct_warn(msg).emit(); } - -pub type CompileResult = Result<(), ErrorReported>; diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 57b680b0e53..0308e9bcdeb 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -290,10 +290,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.infcx.tcx } - pub fn closure_typer(&self) -> &'cx InferCtxt<'cx, 'tcx> { - self.infcx - } - /////////////////////////////////////////////////////////////////////////// // Selection //