From 77e6573929702731bc0bd2c41724e6a587c7f268 Mon Sep 17 00:00:00 2001 From: Lindsey Kuper Date: Thu, 14 Jun 2012 19:41:40 -0700 Subject: 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 --- src/libsyntax/parse/classify.rs | 2 +- src/libsyntax/parse/lexer.rs | 2 +- src/libsyntax/parse/parser.rs | 6 +++--- src/libsyntax/parse/token.rs | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/libsyntax/parse') 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 } -- cgit 1.4.1-3-g733a5