about summary refs log tree commit diff
path: root/src/libsyntax/parse/mod.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-02-11 12:52:42 +0000
committerbors <bors@rust-lang.org>2016-02-11 12:52:42 +0000
commit7732c0aa9ea12262cbe46fa77c2fa636e8aecf6a (patch)
tree8d0364921d0d70e6fdc67176297a1f1ee3e5070e /src/libsyntax/parse/mod.rs
parentf5f8e0bfbeee2abc425f26a3ad36430f23010e69 (diff)
parentbafea3bf78e75c99958ef15fd3d06652cb63133c (diff)
downloadrust-7732c0aa9ea12262cbe46fa77c2fa636e8aecf6a.tar.gz
rust-7732c0aa9ea12262cbe46fa77c2fa636e8aecf6a.zip
Auto merge of #31487 - oli-obk:breaking_batch/ast/unop, r=Manishearth
r? @Manishearth

I just noticed they can't be rolled up (often modifying the same line(s) in imports). So once I reach the critical amount for them to be merged I'll create a PR that merges all of them.
Diffstat (limited to 'src/libsyntax/parse/mod.rs')
-rw-r--r--src/libsyntax/parse/mod.rs88
1 files changed, 40 insertions, 48 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 32372ccc13b..f7060296f1a 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -449,11 +449,11 @@ fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
 }
 
 fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
-                      sd: &Handler, sp: Span) -> ast::Lit_ {
+                      sd: &Handler, sp: Span) -> ast::LitKind {
     debug!("filtered_float_lit: {}, {:?}", data, suffix);
     match suffix.as_ref().map(|s| &**s) {
-        Some("f32") => ast::LitFloat(data, ast::TyF32),
-        Some("f64") => ast::LitFloat(data, ast::TyF64),
+        Some("f32") => ast::LitKind::Float(data, ast::FloatTy::F32),
+        Some("f64") => ast::LitKind::Float(data, ast::FloatTy::F64),
         Some(suf) => {
             if suf.len() >= 2 && looks_like_width_suffix(&['f'], suf) {
                 // if it looks like a width, lets try to be helpful.
@@ -466,13 +466,13 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
                   .emit();
             }
 
-            ast::LitFloatUnsuffixed(data)
+            ast::LitKind::FloatUnsuffixed(data)
         }
-        None => ast::LitFloatUnsuffixed(data)
+        None => ast::LitKind::FloatUnsuffixed(data)
     }
 }
 pub fn float_lit(s: &str, suffix: Option<InternedString>,
-                 sd: &Handler, sp: Span) -> ast::Lit_ {
+                 sd: &Handler, sp: Span) -> ast::LitKind {
     debug!("float_lit: {:?}, {:?}", s, suffix);
     // FIXME #2252: bounds checking float literals is deferred until trans
     let s = s.chars().filter(|&c| c != '_').collect::<String>();
@@ -576,7 +576,7 @@ pub fn integer_lit(s: &str,
                    suffix: Option<InternedString>,
                    sd: &Handler,
                    sp: Span)
-                   -> ast::Lit_ {
+                   -> ast::LitKind {
     // s can only be ascii, byte indexing is fine
 
     let s2 = s.chars().filter(|&c| c != '_').collect::<String>();
@@ -586,7 +586,7 @@ pub fn integer_lit(s: &str,
 
     let mut base = 10;
     let orig = s;
-    let mut ty = ast::UnsuffixedIntLit(ast::Plus);
+    let mut ty = ast::LitIntType::Unsuffixed;
 
     if char_at(s, 0) == '0' && s.len() > 1 {
         match char_at(s, 1) {
@@ -618,16 +618,16 @@ pub fn integer_lit(s: &str,
     if let Some(ref suf) = suffix {
         if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
         ty = match &**suf {
-            "isize" => ast::SignedIntLit(ast::TyIs, ast::Plus),
-            "i8"  => ast::SignedIntLit(ast::TyI8, ast::Plus),
-            "i16" => ast::SignedIntLit(ast::TyI16, ast::Plus),
-            "i32" => ast::SignedIntLit(ast::TyI32, ast::Plus),
-            "i64" => ast::SignedIntLit(ast::TyI64, ast::Plus),
-            "usize" => ast::UnsignedIntLit(ast::TyUs),
-            "u8"  => ast::UnsignedIntLit(ast::TyU8),
-            "u16" => ast::UnsignedIntLit(ast::TyU16),
-            "u32" => ast::UnsignedIntLit(ast::TyU32),
-            "u64" => ast::UnsignedIntLit(ast::TyU64),
+            "isize" => ast::LitIntType::Signed(ast::IntTy::Is),
+            "i8"  => ast::LitIntType::Signed(ast::IntTy::I8),
+            "i16" => ast::LitIntType::Signed(ast::IntTy::I16),
+            "i32" => ast::LitIntType::Signed(ast::IntTy::I32),
+            "i64" => ast::LitIntType::Signed(ast::IntTy::I64),
+            "usize" => ast::LitIntType::Unsigned(ast::UintTy::Us),
+            "u8"  => ast::LitIntType::Unsigned(ast::UintTy::U8),
+            "u16" => ast::LitIntType::Unsigned(ast::UintTy::U16),
+            "u32" => ast::LitIntType::Unsigned(ast::UintTy::U32),
+            "u64" => ast::LitIntType::Unsigned(ast::UintTy::U64),
             _ => {
                 // i<digits> and u<digits> look like widths, so lets
                 // give an error message along those lines
@@ -651,9 +651,9 @@ pub fn integer_lit(s: &str,
     debug!("integer_lit: the type is {:?}, base {:?}, the new string is {:?}, the original \
            string was {:?}, the original suffix was {:?}", ty, base, s, orig, suffix);
 
-    let res = match u64::from_str_radix(s, base).ok() {
-        Some(r) => r,
-        None => {
+    match u64::from_str_radix(s, base) {
+        Ok(r) => ast::LitKind::Int(r, ty),
+        Err(_) => {
             // small bases are lexed as if they were base 10, e.g, the string
             // might be `0b10201`. This will cause the conversion above to fail,
             // but these cases have errors in the lexer: we don't want to emit
@@ -665,16 +665,8 @@ pub fn integer_lit(s: &str,
             if !already_errored {
                 sd.span_err(sp, "int literal is too large");
             }
-            0
+            ast::LitKind::Int(0, ty)
         }
-    };
-
-    // adjust the sign
-    let sign = ast::Sign::new(res);
-    match ty {
-        ast::SignedIntLit(t, _) => ast::LitInt(res, ast::SignedIntLit(t, sign)),
-        ast::UnsuffixedIntLit(_) => ast::LitInt(res, ast::UnsuffixedIntLit(sign)),
-        us@ast::UnsignedIntLit(_) => ast::LitInt(res, us)
     }
 }
 
@@ -684,7 +676,7 @@ mod tests {
     use std::rc::Rc;
     use codemap::{Span, BytePos, Pos, Spanned, NO_EXPANSION};
     use ast::{self, TokenTree};
-    use abi;
+    use abi::Abi;
     use attr::{first_attr_value_str_by_name, AttrMetaMethods};
     use parse;
     use parse::parser::Parser;
@@ -703,7 +695,7 @@ mod tests {
         assert!(string_to_expr("a".to_string()) ==
                    P(ast::Expr{
                     id: ast::DUMMY_NODE_ID,
-                    node: ast::ExprPath(None, ast::Path {
+                    node: ast::ExprKind::Path(None, ast::Path {
                         span: sp(0, 1),
                         global: false,
                         segments: vec!(
@@ -722,7 +714,7 @@ mod tests {
         assert!(string_to_expr("::a::b".to_string()) ==
                    P(ast::Expr {
                     id: ast::DUMMY_NODE_ID,
-                    node: ast::ExprPath(None, ast::Path {
+                    node: ast::ExprKind::Path(None, ast::Path {
                             span: sp(0, 6),
                             global: true,
                             segments: vec!(
@@ -852,9 +844,9 @@ mod tests {
         assert!(string_to_expr("return d".to_string()) ==
                    P(ast::Expr{
                     id: ast::DUMMY_NODE_ID,
-                    node:ast::ExprRet(Some(P(ast::Expr{
+                    node:ast::ExprKind::Ret(Some(P(ast::Expr{
                         id: ast::DUMMY_NODE_ID,
-                        node:ast::ExprPath(None, ast::Path{
+                        node:ast::ExprKind::Path(None, ast::Path{
                             span: sp(7, 8),
                             global: false,
                             segments: vec!(
@@ -875,9 +867,9 @@ mod tests {
     #[test] fn parse_stmt_1 () {
         assert!(string_to_stmt("b;".to_string()) ==
                    Some(P(Spanned{
-                       node: ast::StmtExpr(P(ast::Expr {
+                       node: ast::StmtKind::Expr(P(ast::Expr {
                            id: ast::DUMMY_NODE_ID,
-                           node: ast::ExprPath(None, ast::Path {
+                           node: ast::ExprKind::Path(None, ast::Path {
                                span:sp(0,1),
                                global:false,
                                segments: vec!(
@@ -904,7 +896,7 @@ mod tests {
         assert!(panictry!(parser.parse_pat())
                 == P(ast::Pat{
                 id: ast::DUMMY_NODE_ID,
-                node: ast::PatIdent(ast::BindingMode::ByValue(ast::MutImmutable),
+                node: ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable),
                                     Spanned{ span:sp(0, 1),
                                              node: str_to_ident("b")
                     },
@@ -921,10 +913,10 @@ mod tests {
                       P(ast::Item{ident:str_to_ident("a"),
                             attrs:Vec::new(),
                             id: ast::DUMMY_NODE_ID,
-                            node: ast::ItemFn(P(ast::FnDecl {
+                            node: ast::ItemKind::Fn(P(ast::FnDecl {
                                 inputs: vec!(ast::Arg{
                                     ty: P(ast::Ty{id: ast::DUMMY_NODE_ID,
-                                                  node: ast::TyPath(None, ast::Path{
+                                                  node: ast::TyKind::Path(None, ast::Path{
                                         span:sp(10,13),
                                         global:false,
                                         segments: vec!(
@@ -940,7 +932,7 @@ mod tests {
                                     pat: P(ast::Pat {
                                         id: ast::DUMMY_NODE_ID,
                                         node: ast::PatIdent(
-                                            ast::BindingMode::ByValue(ast::MutImmutable),
+                                            ast::BindingMode::ByValue(ast::Mutability::Immutable),
                                                 Spanned{
                                                     span: sp(6,7),
                                                     node: str_to_ident("b")},
@@ -950,12 +942,12 @@ mod tests {
                                     }),
                                         id: ast::DUMMY_NODE_ID
                                     }),
-                                output: ast::DefaultReturn(sp(15, 15)),
+                                output: ast::FunctionRetTy::Default(sp(15, 15)),
                                 variadic: false
                             }),
                                     ast::Unsafety::Normal,
                                     ast::Constness::NotConst,
-                                    abi::Rust,
+                                    Abi::Rust,
                                     ast::Generics{ // no idea on either of these:
                                         lifetimes: Vec::new(),
                                         ty_params: P::empty(),
@@ -966,9 +958,9 @@ mod tests {
                                     },
                                     P(ast::Block {
                                         stmts: vec!(P(Spanned{
-                                            node: ast::StmtSemi(P(ast::Expr{
+                                            node: ast::StmtKind::Semi(P(ast::Expr{
                                                 id: ast::DUMMY_NODE_ID,
-                                                node: ast::ExprPath(None,
+                                                node: ast::ExprKind::Path(None,
                                                       ast::Path{
                                                         span:sp(17,18),
                                                         global:false,
@@ -988,10 +980,10 @@ mod tests {
                                             span: sp(17,19)})),
                                         expr: None,
                                         id: ast::DUMMY_NODE_ID,
-                                        rules: ast::DefaultBlock, // no idea
+                                        rules: ast::BlockCheckMode::Default, // no idea
                                         span: sp(15,21),
                                     })),
-                            vis: ast::Inherited,
+                            vis: ast::Visibility::Inherited,
                             span: sp(0,21)})));
     }
 
@@ -1110,7 +1102,7 @@ mod tests {
             "foo!( fn main() { body } )".to_string(), vec![], &sess);
 
         let tts = match expr.node {
-            ast::ExprMac(ref mac) => mac.node.tts.clone(),
+            ast::ExprKind::Mac(ref mac) => mac.node.tts.clone(),
             _ => panic!("not a macro"),
         };