Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove (lots of) dead code #83185

Merged
merged 6 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,26 +236,6 @@ impl<T> TypedArena<T> {
start_ptr
}

/// Allocates a slice of objects that are copied into the `TypedArena`, returning a mutable
/// reference to it. Will panic if passed a zero-sized types.
///
/// Panics:
///
/// - Zero-sized types
/// - Zero-length slices
#[inline]
pub fn alloc_slice(&self, slice: &[T]) -> &mut [T]
where
T: Copy,
{
unsafe {
let len = slice.len();
let start_ptr = self.alloc_raw_slice(len);
slice.as_ptr().copy_to_nonoverlapping(start_ptr, len);
slice::from_raw_parts_mut(start_ptr, len)
}
}

#[inline]
pub fn alloc_from_iter<I: IntoIterator<Item = T>>(&self, iter: I) -> &mut [T] {
assert!(mem::size_of::<T>() != 0);
Expand Down
64 changes: 0 additions & 64 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,14 +762,6 @@ pub enum Mutability {
}

impl Mutability {
/// Returns `MutMutable` only if both `self` and `other` are mutable.
pub fn and(self, other: Self) -> Self {
match self {
Mutability::Mut => other,
Mutability::Not => Mutability::Not,
}
}

pub fn invert(self) -> Self {
match self {
Mutability::Mut => Mutability::Not,
Expand Down Expand Up @@ -1722,13 +1714,6 @@ impl FloatTy {
FloatTy::F64 => sym::f64,
}
}

pub fn bit_width(self) -> u64 {
match self {
FloatTy::F32 => 32,
FloatTy::F64 => 64,
}
}
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
Expand Down Expand Up @@ -1764,29 +1749,6 @@ impl IntTy {
IntTy::I128 => sym::i128,
}
}

pub fn bit_width(&self) -> Option<u64> {
Some(match *self {
IntTy::Isize => return None,
IntTy::I8 => 8,
IntTy::I16 => 16,
IntTy::I32 => 32,
IntTy::I64 => 64,
IntTy::I128 => 128,
})
}

pub fn normalize(&self, target_width: u32) -> Self {
match self {
IntTy::Isize => match target_width {
16 => IntTy::I16,
32 => IntTy::I32,
64 => IntTy::I64,
_ => unreachable!(),
},
_ => *self,
}
}
}

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Debug)]
Expand Down Expand Up @@ -1822,29 +1784,6 @@ impl UintTy {
UintTy::U128 => sym::u128,
}
}

pub fn bit_width(&self) -> Option<u64> {
Some(match *self {
UintTy::Usize => return None,
UintTy::U8 => 8,
UintTy::U16 => 16,
UintTy::U32 => 32,
UintTy::U64 => 64,
UintTy::U128 => 128,
})
}

pub fn normalize(&self, target_width: u32) -> Self {
match self {
UintTy::Usize => match target_width {
16 => UintTy::U16,
32 => UintTy::U32,
64 => UintTy::U64,
_ => unreachable!(),
},
_ => *self,
}
}
}

/// A constraint on an associated type (e.g., `A = Bar` in `Foo<A = Bar>` or
Expand Down Expand Up @@ -2215,9 +2154,6 @@ pub struct FnDecl {
}

impl FnDecl {
pub fn get_self(&self) -> Option<ExplicitSelf> {
self.inputs.get(0).and_then(Param::to_self)
}
pub fn has_self(&self) -> bool {
self.inputs.get(0).map_or(false, Param::is_self)
}
Expand Down
40 changes: 1 addition & 39 deletions compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,7 @@ impl NestedMetaItem {
self.meta_item().map_or(false, |meta_item| meta_item.is_word())
}

/// Returns `true` if `self` is a `MetaItem` and the meta item is a `ValueString`.
pub fn is_value_str(&self) -> bool {
self.value_str().is_some()
}

/// Returns `true` if `self` is a `MetaItem` and the meta item is a list.
pub fn is_meta_item_list(&self) -> bool {
self.meta_item_list().is_some()
}

/// See [`MetaItem::name_value_literal_span`].
pub fn name_value_literal_span(&self) -> Option<Span> {
self.meta_item()?.name_value_literal_span()
}
Expand Down Expand Up @@ -165,31 +156,6 @@ impl Attribute {
false
}
}

pub fn is_meta_item_list(&self) -> bool {
self.meta_item_list().is_some()
}

/// Indicates if the attribute is a `ValueString`.
pub fn is_value_str(&self) -> bool {
self.value_str().is_some()
}

/// This is used in case you want the value span instead of the whole attribute. Example:
///
/// ```text
/// #[doc(alias = "foo")]
/// ```
///
/// In here, it'll return a span for `"foo"`.
pub fn name_value_literal_span(&self) -> Option<Span> {
match self.kind {
AttrKind::Normal(ref item, _) => {
item.meta(self.span).and_then(|meta| meta.name_value_literal_span())
}
AttrKind::DocComment(..) => None,
}
}
}

impl MetaItem {
Expand Down Expand Up @@ -236,10 +202,6 @@ impl MetaItem {
self.path == name
}

pub fn is_value_str(&self) -> bool {
self.value_str().is_some()
}

/// This is used in case you want the value span instead of the whole attribute. Example:
///
/// ```text
Expand Down
20 changes: 0 additions & 20 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ impl TokenTree {
}
}

pub fn joint(self) -> TokenStream {
TokenStream::new(vec![(self, Spacing::Joint)])
}

pub fn token(kind: TokenKind, span: Span) -> TokenTree {
TokenTree::Token(Token::new(kind, span))
}
Expand Down Expand Up @@ -278,14 +274,6 @@ impl TokenStream {
self.0.len()
}

pub fn span(&self) -> Option<Span> {
match &**self.0 {
[] => None,
[(tt, _)] => Some(tt.span()),
[(tt_start, _), .., (tt_end, _)] => Some(tt_start.span().to(tt_end.span())),
}
}

pub fn from_streams(mut streams: SmallVec<[TokenStream; 2]>) -> TokenStream {
match streams.len() {
0 => TokenStream::default(),
Expand Down Expand Up @@ -325,10 +313,6 @@ impl TokenStream {
}
}

pub fn trees_ref(&self) -> CursorRef<'_> {
CursorRef::new(self)
}

pub fn trees(&self) -> Cursor {
self.clone().into_trees()
}
Expand Down Expand Up @@ -427,10 +411,6 @@ pub struct CursorRef<'t> {
}

impl<'t> CursorRef<'t> {
fn new(stream: &TokenStream) -> CursorRef<'_> {
CursorRef { stream, index: 0 }
}

fn next_with_spacing(&mut self) -> Option<&'t TreeAndSpacing> {
self.stream.0.get(self.index).map(|tree| {
self.index += 1;
Expand Down
24 changes: 0 additions & 24 deletions compiler/rustc_ast_pretty/src/pprust/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ pub fn token_to_string(token: &Token) -> String {
State::new().token_to_string(token)
}

pub fn token_to_string_ext(token: &Token, convert_dollar_crate: bool) -> String {
State::new().token_to_string_ext(token, convert_dollar_crate)
}

pub fn ty_to_string(ty: &ast::Ty) -> String {
State::new().ty_to_string(ty)
}
Expand All @@ -50,18 +46,10 @@ pub fn tts_to_string(tokens: &TokenStream) -> String {
State::new().tts_to_string(tokens)
}

pub fn stmt_to_string(stmt: &ast::Stmt) -> String {
State::new().stmt_to_string(stmt)
}

pub fn item_to_string(i: &ast::Item) -> String {
State::new().item_to_string(i)
}

pub fn generic_params_to_string(generic_params: &[ast::GenericParam]) -> String {
State::new().generic_params_to_string(generic_params)
}

pub fn path_to_string(p: &ast::Path) -> String {
State::new().path_to_string(p)
}
Expand All @@ -74,26 +62,14 @@ pub fn vis_to_string(v: &ast::Visibility) -> String {
State::new().vis_to_string(v)
}

pub fn block_to_string(blk: &ast::Block) -> String {
State::new().block_to_string(blk)
}

pub fn meta_list_item_to_string(li: &ast::NestedMetaItem) -> String {
State::new().meta_list_item_to_string(li)
}

pub fn attr_item_to_string(ai: &ast::AttrItem) -> String {
State::new().attr_item_to_string(ai)
}

pub fn attribute_to_string(attr: &ast::Attribute) -> String {
State::new().attribute_to_string(attr)
}

pub fn param_to_string(arg: &ast::Param) -> String {
State::new().param_to_string(arg)
}

pub fn to_string(f: impl FnOnce(&mut State<'_>)) -> String {
State::new().to_string(f)
}
4 changes: 0 additions & 4 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2292,10 +2292,6 @@ impl<'a> State<'a> {
}
}

pub fn print_usize(&mut self, i: usize) {
self.s.word(i.to_string())
}

crate fn print_name(&mut self, name: Symbol) {
self.s.word(name.to_string());
self.ann.post(self, AnnNode::Name(&name))
Expand Down
44 changes: 13 additions & 31 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,33 +190,6 @@ pub enum RealPredicate {
RealPredicateTrue = 15,
}

impl RealPredicate {
pub fn from_generic(realpred: rustc_codegen_ssa::common::RealPredicate) -> Self {
match realpred {
rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
RealPredicate::RealPredicateFalse
}
rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
RealPredicate::RealPredicateTrue
}
}
}
}

/// LLVMTypeKind
#[derive(Copy, Clone, PartialEq, Debug)]
#[repr(C)]
Expand Down Expand Up @@ -711,7 +684,7 @@ pub mod coverageinfo {
}

impl CounterMappingRegion {
pub fn code_region(
crate fn code_region(
counter: coverage_map::Counter,
file_id: u32,
start_line: u32,
Expand All @@ -731,7 +704,10 @@ pub mod coverageinfo {
}
}

pub fn expansion_region(
// This function might be used in the future; the LLVM API is still evolving, as is coverage
// support.
#[allow(dead_code)]
crate fn expansion_region(
file_id: u32,
expanded_file_id: u32,
start_line: u32,
Expand All @@ -751,7 +727,10 @@ pub mod coverageinfo {
}
}

pub fn skipped_region(
// This function might be used in the future; the LLVM API is still evolving, as is coverage
// support.
#[allow(dead_code)]
crate fn skipped_region(
file_id: u32,
start_line: u32,
start_col: u32,
Expand All @@ -770,7 +749,10 @@ pub mod coverageinfo {
}
}

pub fn gap_region(
// This function might be used in the future; the LLVM API is still evolving, as is coverage
// support.
#[allow(dead_code)]
crate fn gap_region(
counter: coverage_map::Counter,
file_id: u32,
start_line: u32,
Expand Down
Loading