From 5a3a599428f5af024857d19b5d360b148e885fa2 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 15 Apr 2015 16:11:56 -0700 Subject: [PATCH] Forbid is/us suffixes. Fixes #22496 It was an oversight that this was not done in the great int upheaval. [breaking-change] --- src/librustc_trans/trans/tvec.rs | 2 +- src/libsyntax/parse/mod.rs | 2 -- src/test/auxiliary/issue-11224.rs | 2 +- src/test/compile-fail/lint-type-limits.rs | 4 ++-- .../old-suffixes-are-really-forbidden.rs | 14 ++++++++++++++ src/test/run-make/symbols-are-reasonable/lib.rs | 2 +- src/test/run-pass/autoderef-method-on-trait.rs | 2 +- src/test/run-pass/issue-15763.rs | 8 ++++---- 8 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 src/test/compile-fail/old-suffixes-are-really-forbidden.rs diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index 791b58d88a9..b02fcb6cf0c 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -361,7 +361,7 @@ fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, InBoundsGEP(bcx, data_ptr, &[loop_counter]) }; let bcx = f(bcx, lleltptr, vt.unit_ty); - let plusone = Add(bcx, loop_counter, C_uint(bcx.ccx(), 1us), DebugLoc::None); + let plusone = Add(bcx, loop_counter, C_uint(bcx.ccx(), 1usize), DebugLoc::None); AddIncomingToPhi(loop_counter, plusone, bcx.llbb); let cond_val = ICmp(bcx, llvm::IntULT, plusone, count, DebugLoc::None); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 226e2037b2f..4b7b7b66582 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -714,8 +714,6 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> "u16" => ast::UnsignedIntLit(ast::TyU16), "u32" => ast::UnsignedIntLit(ast::TyU32), "u64" => ast::UnsignedIntLit(ast::TyU64), - "is" => ast::SignedIntLit(ast::TyIs, ast::Plus), - "us" => ast::UnsignedIntLit(ast::TyUs), _ => { // i and u look like widths, so lets // give an error message along those lines diff --git a/src/test/auxiliary/issue-11224.rs b/src/test/auxiliary/issue-11224.rs index 21935b6b9ab..15b72b37781 100644 --- a/src/test/auxiliary/issue-11224.rs +++ b/src/test/auxiliary/issue-11224.rs @@ -21,6 +21,6 @@ mod inner { } pub fn foo() { - let a = &1is as &inner::Trait; + let a = &1isize as &inner::Trait; a.f(); } diff --git a/src/test/compile-fail/lint-type-limits.rs b/src/test/compile-fail/lint-type-limits.rs index 798dc112b0a..42515e0f00c 100644 --- a/src/test/compile-fail/lint-type-limits.rs +++ b/src/test/compile-fail/lint-type-limits.rs @@ -52,12 +52,12 @@ fn qux() { } fn quy() { - let i = -23_us; //~ WARNING negation of unsigned int literal may be unintentional + let i = -23_usize; //~ WARNING negation of unsigned int literal may be unintentional //~^ WARNING unused variable } fn quz() { - let i = 23_us; + let i = 23_usize; let j = -i; //~ WARNING negation of unsigned int variable may be unintentional //~^ WARNING unused variable } diff --git a/src/test/compile-fail/old-suffixes-are-really-forbidden.rs b/src/test/compile-fail/old-suffixes-are-really-forbidden.rs new file mode 100644 index 00000000000..b18741d3932 --- /dev/null +++ b/src/test/compile-fail/old-suffixes-are-really-forbidden.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let a = 1_is; //~ ERROR illegal suffix + let b = 2_us; //~ ERROR illegal suffix +} diff --git a/src/test/run-make/symbols-are-reasonable/lib.rs b/src/test/run-make/symbols-are-reasonable/lib.rs index 8ba705bfb61..ff56ed62869 100644 --- a/src/test/run-make/symbols-are-reasonable/lib.rs +++ b/src/test/run-make/symbols-are-reasonable/lib.rs @@ -16,5 +16,5 @@ impl Foo for usize {} pub fn dummy() { // force the vtable to be created - let _x = &1us as &Foo; + let _x = &1usize as &Foo; } diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index 582fd020dd0..40acb6eb9fe 100644 --- a/src/test/run-pass/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoderef-method-on-trait.rs @@ -21,6 +21,6 @@ impl double for usize { } pub fn main() { - let x: Box<_> = box() (box 3us as Box); + let x: Box<_> = box() (box 3usize as Box); assert_eq!(x.double(), 6); } diff --git a/src/test/run-pass/issue-15763.rs b/src/test/run-pass/issue-15763.rs index b5251d63ff0..0baaaac2676 100644 --- a/src/test/run-pass/issue-15763.rs +++ b/src/test/run-pass/issue-15763.rs @@ -87,12 +87,12 @@ fn main() { assert_eq!(cc().unwrap(), 3); assert_eq!(dd().unwrap(), 3); - let i = box 32is as Box; + let i = box 32isize as Box; assert_eq!(i.aaa(), 3); - let i = box 32is as Box; + let i = box 32isize as Box; assert_eq!(i.bbb(), 3); - let i = box 32is as Box; + let i = box 32isize as Box; assert_eq!(i.ccc().unwrap(), 3); - let i = box 32is as Box; + let i = box 32isize as Box; assert_eq!(i.ddd().unwrap(), 3); }