diff options
| author | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-06-14 19:41:40 -0700 |
|---|---|---|
| committer | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-06-14 20:24:36 -0700 |
| commit | 77e6573929702731bc0bd2c41724e6a587c7f268 (patch) | |
| tree | 65e5f479feb0dc97e4cf2b5c22b1ac27d74386c0 /src/libsyntax | |
| parent | d953462d031db6c6fd632456a5533be818a0db1c (diff) | |
| download | rust-77e6573929702731bc0bd2c41724e6a587c7f268.tar.gz rust-77e6573929702731bc0bd2c41724e6a587c7f268.zip | |
Further work on integer literal suffix inference (#1425)
In this commit:
* Change the lit_int_unsuffixed AST node to not carry a type, since
it doesn't need one
* Don't print "(unsuffixed)" when pretty-printing unsuffixed integer
literals
* Just print "I" instead of "(integral)" for integral type variables
* Set up trans to use the information that will be gathered during
typeck to construct the appropriate constants for unsuffixed int
literals
* Add logic for handling int_ty_sets in typeck::infer
* Clean up unnecessary code in typeck::infer
* Add missing mk_ functions to middle::ty
* Add ty_var_integral to a few of the type utility functions it was
missing from in middle::ty
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/classify.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 10 |
6 files changed, 14 insertions, 18 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 5381a9f345d..edc90fe8676 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -402,7 +402,7 @@ enum lit_ { lit_str(@str), lit_int(i64, int_ty), lit_uint(u64, uint_ty), - lit_int_unsuffixed(i64, int_ty), + lit_int_unsuffixed(i64), lit_float(@str, float_ty), lit_nil, lit_bool(bool), diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index aff0334a946..a3d55df320b 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -54,7 +54,7 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool { ast::expr_lit(node) { alt node { @{node: ast::lit_int(_, ast::ty_i), _} | - @{node: ast::lit_int_unsuffixed(_, ast::ty_i), _} + @{node: ast::lit_int_unsuffixed(_), _} { true } _ { false } } diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 115a9957c28..72b2462feb1 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -285,7 +285,7 @@ fn scan_number(c: char, rdr: reader) -> token::token { #debug["lexing %s as an unsuffixed integer literal", num_str]; - ret token::LIT_INT_UNSUFFIXED(parsed as i64, ast::ty_i); + ret token::LIT_INT_UNSUFFIXED(parsed as i64); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 20452cd8724..62ec5cc50f6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -501,7 +501,7 @@ class parser { let lo = self.span.lo; self.bump(); alt copy self.token { - token::LIT_INT_UNSUFFIXED(num, _) { + token::LIT_INT_UNSUFFIXED(num) { self.bump(); some(mac_var(num as uint)) } @@ -534,7 +534,7 @@ class parser { token::UNDERSCORE { self.bump(); some(vstore_fixed(none)) } - token::LIT_INT_UNSUFFIXED(i, _) if i >= 0i64 { + token::LIT_INT_UNSUFFIXED(i) if i >= 0i64 { self.bump(); some(vstore_fixed(some(i as uint))) } token::BINOP(token::AND) { @@ -553,7 +553,7 @@ class parser { alt tok { token::LIT_INT(i, it) { lit_int(i, it) } token::LIT_UINT(u, ut) { lit_uint(u, ut) } - token::LIT_INT_UNSUFFIXED(i, it) { lit_int_unsuffixed(i, it) } + token::LIT_INT_UNSUFFIXED(i) { lit_int_unsuffixed(i) } token::LIT_FLOAT(s, ft) { lit_float(self.get_str(s), ft) } token::LIT_STR(s) { lit_str(self.get_str(s)) } token::LPAREN { self.expect(token::RPAREN); lit_nil } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 6bf6347704d..4f4c2ee0064 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -57,7 +57,7 @@ enum token { /* Literals */ LIT_INT(i64, ast::int_ty), LIT_UINT(u64, ast::uint_ty), - LIT_INT_UNSUFFIXED(i64, ast::int_ty), + LIT_INT_UNSUFFIXED(i64), LIT_FLOAT(str_num, ast::float_ty), LIT_STR(str_num), @@ -129,8 +129,8 @@ fn to_str(in: interner<@str>, t: token) -> str { LIT_UINT(u, t) { uint::to_str(u as uint, 10u) + ast_util::uint_ty_to_str(t) } - LIT_INT_UNSUFFIXED(i, t) { - int::to_str(i as int, 10u) + ast_util::int_ty_to_str(t) + LIT_INT_UNSUFFIXED(i) { + int::to_str(i as int, 10u) } LIT_FLOAT(s, t) { *interner::get(in, s) + @@ -160,7 +160,7 @@ pure fn can_begin_expr(t: token) -> bool { TILDE { true } LIT_INT(_, _) { true } LIT_UINT(_, _) { true } - LIT_INT_UNSUFFIXED(_, _) { true } + LIT_INT_UNSUFFIXED(_) { true } LIT_FLOAT(_, _) { true } LIT_STR(_) { true } POUND { true } @@ -178,7 +178,7 @@ fn is_lit(t: token) -> bool { alt t { LIT_INT(_, _) { true } LIT_UINT(_, _) { true } - LIT_INT_UNSUFFIXED(_, _) { true } + LIT_INT_UNSUFFIXED(_) { true } LIT_FLOAT(_, _) { true } LIT_STR(_) { true } _ { false } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a63e3139b5b..43b498eae62 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1628,15 +1628,11 @@ fn print_literal(s: ps, &&lit: @ast::lit) { u64::to_str(u, 10u) + ast_util::uint_ty_to_str(t)); } - ast::lit_int_unsuffixed(i, t) { + ast::lit_int_unsuffixed(i) { if i < 0_i64 { - word(s.s, - "-" + u64::to_str(-i as u64, 10u) - + ast_util::int_ty_to_str(t)); + word(s.s, "-" + u64::to_str(-i as u64, 10u)); } else { - word(s.s, - u64::to_str(i as u64, 10u) - + ast_util::int_ty_to_str(t)); + word(s.s, u64::to_str(i as u64, 10u)); } } ast::lit_float(f, t) { |
