From 49d4a756f1138d8246abb1c027490d1ea37be920 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 9 Oct 2020 11:20:56 +0200 Subject: [PATCH] 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;