diff options
| author | Kiet Tran <ktt3ja@gmail.com> | 2013-12-08 02:55:28 -0500 |
|---|---|---|
| committer | Kiet Tran <ktt3ja@gmail.com> | 2013-12-08 02:55:28 -0500 |
| commit | 1755408d1a58684b6c9bce11aeceb18a1ec2d66e (patch) | |
| tree | 9d781272021fe4ead382ffc8f87c048f194e25b5 /src/libsyntax | |
| parent | c06dd0e0afb4b78ab4e482a7488adcf1c865bd19 (diff) | |
| download | rust-1755408d1a58684b6c9bce11aeceb18a1ec2d66e.tar.gz rust-1755408d1a58684b6c9bce11aeceb18a1ec2d66e.zip | |
Remove dead codes
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 22 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 100 | ||||
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 2 |
7 files changed, 3 insertions, 159 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index f4cb19bfa24..ac89689f004 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -448,13 +448,6 @@ impl CodeMap { }; } - fn span_to_str_no_adj(&self, sp: Span) -> ~str { - let lo = self.lookup_char_pos(sp.lo); - let hi = self.lookup_char_pos(sp.hi); - return format!("{}:{}:{}: {}:{}", lo.file.name, - lo.line, lo.col.to_uint(), hi.line, hi.col.to_uint()) - } - fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos { let idx = self.lookup_filemap_idx(bpos); diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index a773fe8497c..af86091084a 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -201,15 +201,7 @@ pub fn syntax_expander_table() -> SyntaxEnv { } as @SyntaxExpanderTTTrait, None)) } - // utility function to simplify creating IdentTT syntax extensions - // that ignore their contexts - fn builtin_item_tt_no_ctxt(f: SyntaxExpanderTTItemFunNoCtxt) -> @Transformer { - @SE(IdentTT(@SyntaxExpanderTTItem { - expander: SyntaxExpanderTTItemExpanderWithoutContext(f), - span: None, - } as @SyntaxExpanderTTItemTrait, - None)) - } + let mut syntax_expanders = HashMap::new(); // NB identifier starts with space, and can't conflict with legal idents syntax_expanders.insert(intern(&" block"), diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index fe7699f36bb..0c6eb6a94a8 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -9,7 +9,7 @@ // except according to those terms. use ast; -use codemap::{BytePos, Pos, Span}; +use codemap::Span; use ext::base::ExtCtxt; use ext::base; use ext::build::AstBuilder; @@ -357,12 +357,6 @@ fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr { ~[e_str]) } -fn mk_bytepos(cx: @ExtCtxt, sp: Span, bpos: BytePos) -> @ast::Expr { - let path = id_ext("BytePos"); - let arg = cx.expr_uint(sp, bpos.to_uint()); - cx.expr_call_ident(sp, path, ~[arg]) -} - fn mk_binop(cx: @ExtCtxt, sp: Span, bop: token::binop) -> @ast::Expr { let name = match bop { PLUS => "PLUS", diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 4f5b0f69a24..3547fa8251b 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -541,20 +541,6 @@ fn fold_struct_def<T:ast_fold>(struct_def: @ast::struct_def, fld: &T) } } -fn noop_fold_view_item(vi: &view_item_, fld: @ast_fold) -> view_item_ { - match *vi { - view_item_extern_mod(ident, name, ref meta_items, node_id) => { - view_item_extern_mod(ident, - name, - fld.fold_meta_items(*meta_items), - fld.new_id(node_id)) - } - view_item_use(ref view_paths) => { - view_item_use(fld.fold_view_paths(*view_paths)) - } - } -} - fn fold_trait_ref<T:ast_fold>(p: &trait_ref, fld: &T) -> trait_ref { ast::trait_ref { path: fld.fold_path(&p.path), @@ -589,14 +575,6 @@ fn fold_mt<T:ast_fold>(mt: &mt, folder: &T) -> mt { } } -fn fold_field<T:ast_fold>(f: TypeField, folder: &T) -> TypeField { - ast::TypeField { - ident: folder.fold_ident(f.ident), - mt: fold_mt(&f.mt, folder), - span: folder.new_span(f.span), - } -} - fn fold_opt_bounds<T:ast_fold>(b: &Option<OptVec<TyParamBound>>, folder: &T) -> Option<OptVec<TyParamBound>> { b.as_ref().map(|bounds| { diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 9c35bb838a3..22a999ab744 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -273,8 +273,6 @@ pub fn nextch(rdr: @mut StringReader) -> char { } else { return unsafe { transmute(-1u32) }; } // FIXME: #8971: unsound } -fn dec_digit_val(c: char) -> int { return (c as int) - ('0' as int); } - fn hex_digit_val(c: char) -> int { if in_range(c, '0', '9') { return (c as int) - ('0' as int); } if in_range(c, 'a', 'f') { return (c as int) - ('a' as int) + 10; } @@ -282,13 +280,6 @@ fn hex_digit_val(c: char) -> int { fail!(); } -fn oct_digit_val(c: char) -> int { - if in_range(c, '0', '7') { return (c as int) - ('0' as int); } - fail!(); -} - -fn bin_digit_value(c: char) -> int { if c == '0' { return 0; } return 1; } - pub fn is_whitespace(c: char) -> bool { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } @@ -304,10 +295,6 @@ fn is_hex_digit(c: char) -> bool { in_range(c, 'A', 'F'); } -fn is_oct_digit(c: char) -> bool { return in_range(c, '0', '7'); } - -fn is_bin_digit(c: char) -> bool { return c == '0' || c == '1'; } - // EFFECT: eats whitespace and comments. // returns a Some(sugared-doc-attr) if one exists, None otherwise. fn consume_whitespace_and_comments(rdr: @mut StringReader) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8c4bf5d87ab..62bfd7c80f9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -135,13 +135,6 @@ pub enum item_or_view_item { iovi_view_item(view_item) } -#[deriving(Eq)] -enum view_item_parse_mode { - VIEW_ITEMS_AND_ITEMS_ALLOWED, - FOREIGN_ITEMS_ALLOWED, - IMPORTS_AND_ITEMS_ALLOWED -} - /* The expr situation is not as complex as I thought it would be. The important thing is to make sure that lookahead doesn't balk at INTERPOLATED tokens */ @@ -3455,18 +3448,6 @@ impl Parser { }) } - fn parse_optional_purity(&self) -> ast::purity { - if self.eat_keyword(keywords::Unsafe) { - ast::unsafe_fn - } else { - ast::impure_fn - } - } - - fn parse_optional_onceness(&self) -> ast::Onceness { - if self.eat_keyword(keywords::Once) { ast::Once } else { ast::Many } - } - // matches optbounds = ( ( : ( boundseq )? )? ) // where boundseq = ( bound + boundseq ) | bound // and bound = 'static | ty @@ -3531,15 +3512,6 @@ impl Parser { } } - // parse a generic use site - fn parse_generic_values(&self) -> (OptVec<ast::Lifetime>, ~[P<Ty>]) { - if !self.eat(&token::LT) { - (opt_vec::Empty, ~[]) - } else { - self.parse_generic_values_after_lt() - } - } - fn parse_generic_values_after_lt(&self) -> (OptVec<ast::Lifetime>, ~[P<Ty>]) { let lifetimes = self.parse_lifetimes(); let result = self.parse_seq_to_gt( @@ -4080,13 +4052,6 @@ impl Parser { None) } - fn token_is_pound_or_doc_comment(&self, tok: token::Token) -> bool { - match tok { - token::POUND | token::DOC_COMMENT(_) => true, - _ => false - } - } - // parse a structure field declaration pub fn parse_single_struct_field(&self, vis: visibility, @@ -4556,26 +4521,6 @@ impl Parser { (id, item_enum(enum_definition, generics), None) } - fn parse_fn_ty_sigil(&self) -> Option<Sigil> { - match *self.token { - token::AT => { - self.bump(); - Some(ManagedSigil) - } - token::TILDE => { - self.bump(); - Some(OwnedSigil) - } - token::BINOP(token::AND) => { - self.bump(); - Some(BorrowedSigil) - } - _ => { - None - } - } - } - fn fn_expr_lookahead(&self, tok: &token::Token) -> bool { match *tok { token::LPAREN | token::AT | token::TILDE | token::BINOP(_) => true, @@ -4983,51 +4928,6 @@ impl Parser { return vp; } - fn is_view_item(&self) -> bool { - if !self.is_keyword(keywords::Pub) && !self.is_keyword(keywords::Priv) { - token::is_keyword(keywords::Use, self.token) - || (token::is_keyword(keywords::Extern, self.token) && - self.look_ahead(1, - |t| token::is_keyword(keywords::Mod, t))) - } else { - self.look_ahead(1, |t| token::is_keyword(keywords::Use, t)) - || (self.look_ahead(1, - |t| token::is_keyword(keywords::Extern, - t)) && - self.look_ahead(2, - |t| token::is_keyword(keywords::Mod, t))) - } - } - - // parse a view item. - fn parse_view_item( - &self, - attrs: ~[Attribute], - vis: visibility - ) -> view_item { - let lo = self.span.lo; - let node = if self.eat_keyword(keywords::Use) { - self.parse_use() - } else if self.eat_keyword(keywords::Extern) { - self.expect_keyword(keywords::Mod); - let ident = self.parse_ident(); - let path = if *self.token == token::EQ { - self.bump(); - Some(self.parse_str()) - } - else { None }; - let metadata = self.parse_optional_meta(); - view_item_extern_mod(ident, path, metadata, ast::DUMMY_NODE_ID) - } else { - self.bug("expected view item"); - }; - self.expect(&token::SEMI); - ast::view_item { node: node, - attrs: attrs, - vis: vis, - span: mk_sp(lo, self.last_span.hi) } - } - // Parses a sequence of items. Stops when it finds program // text that can't be parsed as an item // - mod_items uses extern_mod_allowed = true diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 0e07ee23b67..51656160d31 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -64,7 +64,7 @@ impl<T> SmallVector<T> { } } - fn get<'a>(&'a self, idx: uint) -> &'a T { + pub fn get<'a>(&'a self, idx: uint) -> &'a T { match *self { One(ref v) if idx == 0 => v, Many(ref vs) => &vs[idx], |
