From e95779554e9d6fc111102df7af80b40f8e22cfae Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 8 Jan 2015 20:13:14 +1100 Subject: Store deprecated status of i/u-suffixed literals. --- src/libsyntax/ast.rs | 44 +++++++++++++++++++++++++------ src/libsyntax/ast_util.rs | 16 ++++++----- src/libsyntax/attr.rs | 10 +++---- src/libsyntax/ext/build.rs | 5 ++-- src/libsyntax/ext/deriving/generic/mod.rs | 2 +- src/libsyntax/ext/quote.rs | 28 ++++++++++---------- src/libsyntax/parse/mod.rs | 8 +++--- 7 files changed, 73 insertions(+), 40 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 0a9e0aedd3d..630f7768885 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1075,15 +1075,29 @@ pub struct Typedef { pub typ: P, } -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum IntTy { - TyIs, + TyIs(bool /* is this deprecated `int`? */), TyI8, TyI16, TyI32, TyI64, } +impl PartialEq for IntTy { + fn eq(&self, other: &IntTy) -> bool { + match (*self, *other) { + // true/false need to compare the same, so this can't be derived + (TyIs(_), TyIs(_)) | + (TyI8, TyI8) | + (TyI16, TyI16) | + (TyI32, TyI32) | + (TyI64, TyI64) => true, + _ => false + } + } +} + impl fmt::Show for IntTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::String::fmt(self, f) @@ -1099,27 +1113,41 @@ impl fmt::String for IntTy { impl IntTy { pub fn suffix_len(&self) -> uint { match *self { - TyIs => 1, - TyI8 => 2, + TyIs(true) /* i */ => 1, + TyIs(false) /* is */ | TyI8 => 2, TyI16 | TyI32 | TyI64 => 3, } } } -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum UintTy { - TyUs, + TyUs(bool /* is this deprecated uint? */), TyU8, TyU16, TyU32, TyU64, } +impl PartialEq for UintTy { + fn eq(&self, other: &UintTy) -> bool { + match (*self, *other) { + // true/false need to compare the same, so this can't be derived + (TyUs(_), TyUs(_)) | + (TyU8, TyU8) | + (TyU16, TyU16) | + (TyU32, TyU32) | + (TyU64, TyU64) => true, + _ => false + } + } +} + impl UintTy { pub fn suffix_len(&self) -> uint { match *self { - TyUs => 1, - TyU8 => 2, + TyUs(true) /* u */ => 1, + TyUs(false) /* us */ | TyU8 => 2, TyU16 | TyU32 | TyU64 => 3, } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index b4e917e28cb..bc7fbd46fd8 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -127,8 +127,10 @@ pub fn is_path(e: P) -> bool { /// We want to avoid "45int" and "-3int" in favor of "45" and "-3" pub fn int_ty_to_string(t: IntTy, val: Option) -> String { let s = match t { - TyIs if val.is_some() => "is", - TyIs => "isize", + TyIs(true) if val.is_some() => "i", + TyIs(true) => "int", + TyIs(false) if val.is_some() => "is", + TyIs(false) => "isize", TyI8 => "i8", TyI16 => "i16", TyI32 => "i32", @@ -148,7 +150,7 @@ pub fn int_ty_max(t: IntTy) -> u64 { match t { TyI8 => 0x80u64, TyI16 => 0x8000u64, - TyIs | TyI32 => 0x80000000u64, // actually ni about TyIs + TyIs(_) | TyI32 => 0x80000000u64, // actually ni about TyIs TyI64 => 0x8000000000000000u64 } } @@ -157,8 +159,10 @@ pub fn int_ty_max(t: IntTy) -> u64 { /// We want to avoid "42uint" in favor of "42u" pub fn uint_ty_to_string(t: UintTy, val: Option) -> String { let s = match t { - TyUs if val.is_some() => "us", - TyUs => "usize", + TyUs(true) if val.is_some() => "u", + TyUs(true) => "uint", + TyUs(false) if val.is_some() => "us", + TyUs(false) => "usize", TyU8 => "u8", TyU16 => "u16", TyU32 => "u32", @@ -175,7 +179,7 @@ pub fn uint_ty_max(t: UintTy) -> u64 { match t { TyU8 => 0xffu64, TyU16 => 0xffffu64, - TyUs | TyU32 => 0xffffffffu64, // actually ni about TyUs + TyUs(_) | TyU32 => 0xffffffffu64, // actually ni about TyUs TyU64 => 0xffffffffffffffffu64 } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 2cea55dfc55..6f57c06d33e 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -464,10 +464,10 @@ fn int_type_of_word(s: &str) -> Option { "u32" => Some(UnsignedInt(ast::TyU32)), "i64" => Some(SignedInt(ast::TyI64)), "u64" => Some(UnsignedInt(ast::TyU64)), - "int" => Some(SignedInt(ast::TyIs)), - "uint" => Some(UnsignedInt(ast::TyUs)), - "isize" => Some(SignedInt(ast::TyIs)), - "usize" => Some(UnsignedInt(ast::TyUs)), + "int" => Some(SignedInt(ast::TyIs(true))), + "uint" => Some(UnsignedInt(ast::TyUs(true))), + "isize" => Some(SignedInt(ast::TyIs(false))), + "usize" => Some(UnsignedInt(ast::TyUs(false))), _ => None } } @@ -511,7 +511,7 @@ impl IntType { SignedInt(ast::TyI16) | UnsignedInt(ast::TyU16) | SignedInt(ast::TyI32) | UnsignedInt(ast::TyU32) | SignedInt(ast::TyI64) | UnsignedInt(ast::TyU64) => true, - SignedInt(ast::TyIs) | UnsignedInt(ast::TyUs) => false + SignedInt(ast::TyIs(_)) | UnsignedInt(ast::TyUs(_)) => false } } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 27523ea4535..c34142aec39 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -642,10 +642,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr(sp, ast::ExprLit(P(respan(sp, lit)))) } fn expr_uint(&self, span: Span, i: uint) -> P { - self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs))) + self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs(false)))) } fn expr_int(&self, sp: Span, i: int) -> P { - self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs, ast::Sign::new(i)))) + self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs(false), + ast::Sign::new(i)))) } fn expr_u8(&self, sp: Span, u: u8) -> P { self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU8))) diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 47b29a4db3e..e6b6f7bbd49 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -1031,7 +1031,7 @@ impl<'a> MethodDef<'a> { let arms: Vec = variants.iter().enumerate() .map(|(index, variant)| { let pat = variant_to_pat(cx, sp, type_ident, &**variant); - let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyUs)); + let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyUs(false))); cx.arm(sp, vec![pat], cx.expr_lit(sp, lit)) }).collect(); diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 2dbf29c145c..c42b188302c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -244,10 +244,10 @@ pub mod rt { } macro_rules! impl_to_source_int { - (signed, $t:ty, $tag:ident) => ( + (signed, $t:ty, $tag:expr) => ( impl ToSource for $t { fn to_source(&self) -> String { - let lit = ast::LitInt(*self as u64, ast::SignedIntLit(ast::$tag, + let lit = ast::LitInt(*self as u64, ast::SignedIntLit($tag, ast::Sign::new(*self))); pprust::lit_to_string(&dummy_spanned(lit)) } @@ -258,10 +258,10 @@ pub mod rt { } } ); - (unsigned, $t:ty, $tag:ident) => ( + (unsigned, $t:ty, $tag:expr) => ( impl ToSource for $t { fn to_source(&self) -> String { - let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit(ast::$tag)); + let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit($tag)); pprust::lit_to_string(&dummy_spanned(lit)) } } @@ -273,17 +273,17 @@ pub mod rt { ); } - impl_to_source_int! { signed, int, TyIs } - impl_to_source_int! { signed, i8, TyI8 } - impl_to_source_int! { signed, i16, TyI16 } - impl_to_source_int! { signed, i32, TyI32 } - impl_to_source_int! { signed, i64, TyI64 } + impl_to_source_int! { signed, int, ast::TyIs(false) } + impl_to_source_int! { signed, i8, ast::TyI8 } + impl_to_source_int! { signed, i16, ast::TyI16 } + impl_to_source_int! { signed, i32, ast::TyI32 } + impl_to_source_int! { signed, i64, ast::TyI64 } - impl_to_source_int! { unsigned, uint, TyUs } - impl_to_source_int! { unsigned, u8, TyU8 } - impl_to_source_int! { unsigned, u16, TyU16 } - impl_to_source_int! { unsigned, u32, TyU32 } - impl_to_source_int! { unsigned, u64, TyU64 } + impl_to_source_int! { unsigned, uint, ast::TyUs(false) } + impl_to_source_int! { unsigned, u8, ast::TyU8 } + impl_to_source_int! { unsigned, u16, ast::TyU16 } + impl_to_source_int! { unsigned, u32, ast::TyU32 } + impl_to_source_int! { unsigned, u64, ast::TyU64 } // Alas ... we write these out instead. All redundant. diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index c42a6beea2d..f1f547ba0c7 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -702,14 +702,14 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> if let Some(suf) = suffix { if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")} ty = match suf { - "i" => ast::SignedIntLit(ast::TyIs, ast::Plus), - "is" => ast::SignedIntLit(ast::TyIs, ast::Plus), + "i" => ast::SignedIntLit(ast::TyIs(true), ast::Plus), + "is" => ast::SignedIntLit(ast::TyIs(false), 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), - "u" => ast::UnsignedIntLit(ast::TyUs), - "us" => ast::UnsignedIntLit(ast::TyUs), + "u" => ast::UnsignedIntLit(ast::TyUs(true)), + "us" => ast::UnsignedIntLit(ast::TyUs(false)), "u8" => ast::UnsignedIntLit(ast::TyU8), "u16" => ast::UnsignedIntLit(ast::TyU16), "u32" => ast::UnsignedIntLit(ast::TyU32), -- cgit 1.4.1-3-g733a5 From d12514bc589c1955108d517acd6d5952929b1650 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 8 Jan 2015 21:16:35 +1100 Subject: Add a warning feature gate for int/uint in types and i/u suffixes. --- src/librustc/middle/ty.rs | 4 +- src/librustc_trans/trans/type_of.rs | 2 +- src/libsyntax/feature_gate.rs | 55 ++++++++++++++++++++++++++ src/test/compile-fail/feature-gate-int-uint.rs | 35 ++++++++++++++++ 4 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 src/test/compile-fail/feature-gate-int-uint.rs (limited to 'src/libsyntax') diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 2534232960f..ef86e67de16 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2341,12 +2341,12 @@ impl<'tcx> CommonTypes<'tcx> { bool: intern_ty(arena, interner, ty_bool), char: intern_ty(arena, interner, ty_char), err: intern_ty(arena, interner, ty_err), - int: intern_ty(arena, interner, ty_int(ast::TyIs(_))), + int: intern_ty(arena, interner, ty_int(ast::TyIs(false))), i8: intern_ty(arena, interner, ty_int(ast::TyI8)), i16: intern_ty(arena, interner, ty_int(ast::TyI16)), i32: intern_ty(arena, interner, ty_int(ast::TyI32)), i64: intern_ty(arena, interner, ty_int(ast::TyI64)), - uint: intern_ty(arena, interner, ty_uint(ast::TyUs(_))), + uint: intern_ty(arena, interner, ty_uint(ast::TyUs(false))), u8: intern_ty(arena, interner, ty_uint(ast::TyU8)), u16: intern_ty(arena, interner, ty_uint(ast::TyU16)), u32: intern_ty(arena, interner, ty_uint(ast::TyU32)), diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index 416dfb420ff..99330797422 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -263,7 +263,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type { } match unsized_part_of_type(cx.tcx(), t).sty { - ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyUs(_)), + ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyUs(false)), ty::ty_trait(_) => Type::vtable_ptr(cx), _ => panic!("Unexpected type returned from unsized_part_of_type : {}", t.repr(cx.tcx())) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2cfcd38d48f..6deffa804b2 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -93,6 +93,9 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ // OIBIT specific features ("optin_builtin_traits", Active), + // int and uint are now deprecated + ("int_uint", Active), + // These are used to test this portion of the compiler, they don't actually // mean anything ("test_accepted_feature", Accepted), @@ -157,6 +160,14 @@ impl<'a> Context<'a> { } } + fn warn_feature(&self, feature: &str, span: Span, explain: &str) { + if !self.has_feature(feature) { + self.span_handler.span_warn(span, explain); + self.span_handler.span_help(span, &format!("add #![feature({})] to the \ + crate attributes to silence this warning", + feature)[]); + } + } fn has_feature(&self, feature: &str) -> bool { self.features.iter().any(|&n| n == feature) } @@ -334,6 +345,31 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { } fn visit_ty(&mut self, t: &ast::Ty) { + match t.node { + ast::TyPath(ref p, _) => { + match &*p.segments { + + [ast::PathSegment { identifier, .. }] => { + let name = token::get_ident(identifier); + let msg = if name == "int" { + Some("the `int` type is deprecated; \ + use `isize` or a fixed-sized integer") + } else if name == "uint" { + Some("the `unt` type is deprecated; \ + use `usize` or a fixed-sized integer") + } else { + None + }; + + if let Some(msg) = msg { + self.context.warn_feature("int_uint", t.span, msg) + } + } + _ => {} + } + } + _ => {} + } visit::walk_ty(self, t); } @@ -345,6 +381,25 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { "box expression syntax is experimental in alpha release; \ you can call `Box::new` instead."); } + ast::ExprLit(ref lit) => { + match lit.node { + ast::LitInt(_, ty) => { + let msg = if let ast::SignedIntLit(ast::TyIs(true), _) = ty { + Some("the `i` suffix on integers is deprecated; use `is` \ + or one of the fixed-sized suffixes") + } else if let ast::UnsignedIntLit(ast::TyUs(true)) = ty { + Some("the `u` suffix on integers is deprecated; use `us` \ + or one of the fixed-sized suffixes") + } else { + None + }; + if let Some(msg) = msg { + self.context.warn_feature("int_uint", e.span, msg); + } + } + _ => {} + } + } _ => {} } visit::walk_expr(self, e); diff --git a/src/test/compile-fail/feature-gate-int-uint.rs b/src/test/compile-fail/feature-gate-int-uint.rs new file mode 100644 index 00000000000..78b931b383f --- /dev/null +++ b/src/test/compile-fail/feature-gate-int-uint.rs @@ -0,0 +1,35 @@ +// 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. + +#![allow(dead_code)] + +mod u { + type X = uint; //~ WARN the `uint` type is deprecated + struct Foo { + x: uint //~ WARN the `uint` type is deprecated + } + fn bar(x: uint) { //~ WARN the `uint` type is deprecated + 1u; //~ WARN the `u` suffix on integers is deprecated + } +} +mod i { + type X = int; //~ WARN the `int` type is deprecated + struct Foo { + x: int //~ WARN the `int` type is deprecated + } + fn bar(x: int) { //~ WARN the `int` type is deprecated + 1i; //~ WARN the `u` suffix on integers is deprecated + } +} + +fn main() { + // make compilation fail, after feature gating + let () = 1u8; //~ ERROR +} -- cgit 1.4.1-3-g733a5 From 4f5a57e80ef6c029278f1e8ef59e13dcea9b255b Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 8 Jan 2015 21:45:49 +1100 Subject: Remove warning from the libraries. This adds the int_uint feature to *every* library, whether or not it needs it. --- src/compiletest/compiletest.rs | 1 + src/liballoc/lib.rs | 1 + src/libarena/lib.rs | 1 + src/libcollections/lib.rs | 1 + src/libcore/lib.rs | 3 ++- src/libcore/macros.rs | 4 ++-- src/libcoretest/lib.rs | 1 + src/libflate/lib.rs | 1 + src/libfmt_macros/lib.rs | 1 + src/libgetopts/lib.rs | 1 + src/libgraphviz/lib.rs | 1 + src/liblibc/lib.rs | 1 + src/liblog/lib.rs | 1 + src/librand/lib.rs | 2 +- src/librbml/lib.rs | 1 + src/libregex/lib.rs | 1 + src/librustc/lib.rs | 1 + src/librustc_back/lib.rs | 1 + src/librustc_borrowck/lib.rs | 1 + src/librustc_driver/lib.rs | 1 + src/librustc_llvm/lib.rs | 1 + src/librustc_resolve/lib.rs | 1 + src/librustc_trans/lib.rs | 1 + src/librustc_typeck/lib.rs | 1 + src/librustdoc/lib.rs | 1 + src/libserialize/lib.rs | 1 + src/libstd/lib.rs | 1 + src/libstd/macros.rs | 8 ++++---- src/libsyntax/lib.rs | 1 + src/libterm/lib.rs | 1 + src/libtest/lib.rs | 1 + src/libunicode/lib.rs | 1 + 32 files changed, 37 insertions(+), 8 deletions(-) (limited to 'src/libsyntax') diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 9a5665e6839..802fb05796d 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -12,6 +12,7 @@ #![allow(unknown_features)] #![feature(slicing_syntax, unboxed_closures)] #![feature(box_syntax)] +#![feature(int_uint)] #![deny(warnings)] diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 0bb8ba669ec..3fbb063b340 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -68,6 +68,7 @@ #![allow(unknown_features)] #![feature(lang_items, unsafe_destructor)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] #[macro_use] extern crate core; diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index f208ff9dc05..e6ceab4c4d4 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -32,6 +32,7 @@ #![feature(unsafe_destructor)] #![feature(unboxed_closures)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] #![allow(missing_docs)] extern crate alloc; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 7692c1558a7..a651d8a9d76 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -27,6 +27,7 @@ #![feature(box_syntax)] #![feature(unboxed_closures)] #![feature(old_impl_check)] +#![allow(unknown_features)] #![feature(int_uint)] #![no_std] #[macro_use] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index af5aba53bf4..39aaca93f1b 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -59,9 +59,10 @@ #![no_std] #![allow(unknown_features, raw_pointer_derive)] #![cfg_attr(stage0, allow(unused_attributes))] -#![feature(intrinsics, lang_items)] +#![allow(unknown_features)] #![feature(intrinsics, lang_items)] #![feature(simd, unsafe_destructor, slicing_syntax)] #![feature(unboxed_closures)] +#![allow(unknown_features)] #![feature(int_uint)] #![deny(missing_docs)] #[macro_use] diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index bfe88fff22f..f6415518864 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -15,7 +15,7 @@ macro_rules! panic { panic!("explicit panic") ); ($msg:expr) => ({ - static _MSG_FILE_LINE: (&'static str, &'static str, uint) = ($msg, file!(), line!()); + static _MSG_FILE_LINE: (&'static str, &'static str, usize) = ($msg, file!(), line!()); ::core::panicking::panic(&_MSG_FILE_LINE) }); ($fmt:expr, $($arg:tt)*) => ({ @@ -23,7 +23,7 @@ macro_rules! panic { // used inside a dead function. Just `#[allow(dead_code)]` is // insufficient, since the user may have // `#[forbid(dead_code)]` and which cannot be overridden. - static _FILE_LINE: (&'static str, uint) = (file!(), line!()); + static _FILE_LINE: (&'static str, usize) = (file!(), line!()); ::core::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE) }); } diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs index c12981b7d24..0d371dbe153 100644 --- a/src/libcoretest/lib.rs +++ b/src/libcoretest/lib.rs @@ -11,6 +11,7 @@ #![feature(unsafe_destructor, slicing_syntax)] #![feature(unboxed_closures)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate core; extern crate test; diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index 1896bdd182a..fda52cebf75 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -17,6 +17,7 @@ #![crate_name = "flate"] #![experimental] #![staged_api] +#![allow(unknown_features)] #![feature(int_uint)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 02eea5d024c..4ec5969a6d7 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -25,6 +25,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![feature(slicing_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] pub use self::Piece::*; pub use self::Position::*; diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 1d6c99542b5..10d514fee8c 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -87,6 +87,7 @@ html_root_url = "http://doc.rust-lang.org/nightly/", html_playground_url = "http://play.rust-lang.org/")] #![feature(slicing_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] #![deny(missing_docs)] #[cfg(test)] #[macro_use] extern crate log; diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 9d2318e253e..268dfdc00f9 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -273,6 +273,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] #![feature(slicing_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] use self::LabelText::*; diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index c39fd074387..dfa7f5cc754 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -12,6 +12,7 @@ #![crate_type = "rlib"] #![cfg_attr(not(feature = "cargo-build"), experimental)] #![cfg_attr(not(feature = "cargo-build"), staged_api)] +#![allow(unknown_features)] #![feature(int_uint)] #![no_std] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 0d5f6b65827..ef7c6f5f311 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -168,6 +168,7 @@ #![allow(unknown_features)] #![feature(slicing_syntax)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] #![deny(missing_docs)] extern crate regex; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 497e339b316..d7caa4158dd 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -22,7 +22,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/", html_playground_url = "http://play.rust-lang.org/")] - +#![allow(unknown_features)] #![feature(int_uint)] #![no_std] #![experimental] #![staged_api] diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index da803aa5011..4a28316fbea 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -26,6 +26,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![allow(unknown_features)] #![feature(slicing_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate serialize; #[macro_use] extern crate log; diff --git a/src/libregex/lib.rs b/src/libregex/lib.rs index d19ce3b460a..4fd4531a92b 100644 --- a/src/libregex/lib.rs +++ b/src/libregex/lib.rs @@ -26,6 +26,7 @@ #![allow(unknown_features)] #![feature(slicing_syntax)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] #![deny(missing_docs)] #[cfg(test)] diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index e0143917a7c..283e32e8802 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -27,6 +27,7 @@ #![feature(quote)] #![feature(slicing_syntax, unsafe_destructor)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] #![feature(rustc_diagnostic_macros)] #![feature(old_impl_check)] diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs index fcd20158c0a..d07a11b8a6a 100644 --- a/src/librustc_back/lib.rs +++ b/src/librustc_back/lib.rs @@ -31,6 +31,7 @@ html_root_url = "http://doc.rust-lang.org/nightly/")] #![allow(unknown_features)] #![feature(slicing_syntax, box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate syntax; extern crate serialize; diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index 452eaaaa52d..0b96171548a 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -21,6 +21,7 @@ #![feature(quote)] #![feature(slicing_syntax, unsafe_destructor)] #![feature(rustc_diagnostic_macros)] +#![allow(unknown_features)] #![feature(int_uint)] #![allow(non_camel_case_types)] #[macro_use] extern crate log; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 27e1eaacdfd..7617027dfd1 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -28,6 +28,7 @@ #![feature(slicing_syntax, unsafe_destructor)] #![feature(box_syntax)] #![feature(rustc_diagnostic_macros)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate arena; extern crate flate; diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 4a281c413d6..2895defdd6f 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -25,6 +25,7 @@ #![allow(unknown_features)] #![feature(link_args)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate libc; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 88f0abf3ca7..edd67590e0c 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -19,6 +19,7 @@ #![feature(slicing_syntax)] #![feature(rustc_diagnostic_macros)] +#![allow(unknown_features)] #![feature(int_uint)] #[macro_use] extern crate log; #[macro_use] extern crate syntax; diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 5da51697d2f..b317cdc4dca 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -28,6 +28,7 @@ #![feature(slicing_syntax, unsafe_destructor)] #![feature(box_syntax)] #![feature(rustc_diagnostic_macros)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate arena; extern crate flate; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 76ac4b2e8af..e39d7186fa1 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -77,6 +77,7 @@ This API is completely unstable and subject to change. #![feature(slicing_syntax, unsafe_destructor)] #![feature(box_syntax)] #![feature(rustc_diagnostic_macros)] +#![allow(unknown_features)] #![feature(int_uint)] #![allow(non_camel_case_types)] #[macro_use] extern crate log; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 56f5c23f6f1..e0b0274b7c4 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -19,6 +19,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![feature(slicing_syntax)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate arena; extern crate getopts; diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index b3c4cec2ef1..942a8cfa2c5 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -28,6 +28,7 @@ Core encoding and decoding interfaces. #![feature(box_syntax)] #![feature(old_impl_check)] #![feature(slicing_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] // test harness access #[cfg(test)] extern crate test; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 71221a654e8..dc157c7d676 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -110,6 +110,7 @@ #![feature(slicing_syntax, unboxed_closures)] #![feature(box_syntax)] #![feature(old_impl_check)] +#![allow(unknown_features)] #![feature(int_uint)] // Don't link to std. We are std. #![no_std] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 0594b711ad6..6e7599b7b8f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -44,7 +44,7 @@ macro_rules! panic { ($msg:expr) => ({ $crate::rt::begin_unwind($msg, { // static requires less code at runtime, more constant data - static _FILE_LINE: (&'static str, uint) = (file!(), line!()); + static _FILE_LINE: (&'static str, usize) = (file!(), line!()); &_FILE_LINE }) }); @@ -54,7 +54,7 @@ macro_rules! panic { // used inside a dead function. Just `#[allow(dead_code)]` is // insufficient, since the user may have // `#[forbid(dead_code)]` and which cannot be overridden. - static _FILE_LINE: (&'static str, uint) = (file!(), line!()); + static _FILE_LINE: (&'static str, usize) = (file!(), line!()); &_FILE_LINE }) }); @@ -466,7 +466,7 @@ pub mod builtin { /// A macro which expands to the line number on which it was invoked. /// - /// The expanded expression has type `uint`, and the returned line is not + /// The expanded expression has type `usize`, and the returned line is not /// the invocation of the `line!()` macro itself, but rather the first macro /// invocation leading up to the invocation of the `line!()` macro. /// @@ -481,7 +481,7 @@ pub mod builtin { /// A macro which expands to the column number on which it was invoked. /// - /// The expanded expression has type `uint`, and the returned column is not + /// The expanded expression has type `usize`, and the returned column is not /// the invocation of the `column!()` macro itself, but rather the first macro /// invocation leading up to the invocation of the `column!()` macro. /// diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 1efd6a87f86..4bbc8a40a9e 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -27,6 +27,7 @@ #![feature(slicing_syntax)] #![feature(box_syntax)] #![feature(quote, unsafe_destructor)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate arena; extern crate fmt_macros; diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index b4f224cb4a7..6db07b9c87c 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -51,6 +51,7 @@ #![allow(unknown_features)] #![feature(slicing_syntax)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] #![deny(missing_docs)] #[macro_use] extern crate log; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index d04308814f8..ec01b535bfd 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -34,6 +34,7 @@ #![allow(unknown_features)] #![feature(asm, slicing_syntax)] #![feature(box_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate getopts; extern crate regex; diff --git a/src/libunicode/lib.rs b/src/libunicode/lib.rs index 27255cc33ee..6c95d6ef2a6 100644 --- a/src/libunicode/lib.rs +++ b/src/libunicode/lib.rs @@ -30,6 +30,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![no_std] #![feature(slicing_syntax)] +#![allow(unknown_features)] #![feature(int_uint)] extern crate core; -- cgit 1.4.1-3-g733a5 From dc1ba08d1603aeedf37a4a7182e990207891379d Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 8 Jan 2015 23:36:24 +1100 Subject: Test fixes. --- src/libsyntax/ext/deriving/rand.rs | 6 +++--- src/libsyntax/feature_gate.rs | 2 +- src/test/compile-fail/feature-gate-int-uint.rs | 16 ++++++++-------- src/test/compile-fail/issue-13482-2.rs | 2 +- src/test/compile-fail/issue-5544-a.rs | 2 +- src/test/compile-fail/lex-bad-numeric-literals.rs | 4 ++-- src/test/compile-fail/lint-type-limits.rs | 4 ++-- src/test/compile-fail/oversized-literal.rs | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 5517019f804..1359cada673 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -98,13 +98,13 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) rand_name, vec!(rng.clone())); - // need to specify the uint-ness of the random number - let uint_ty = cx.ty_ident(trait_span, cx.ident_of("uint")); + // need to specify the usize-ness of the random number + let usize_ty = cx.ty_ident(trait_span, cx.ident_of("usize")); let value_ident = cx.ident_of("__value"); let let_statement = cx.stmt_let_typed(trait_span, false, value_ident, - uint_ty, + usize_ty, rv_call); // rand() % variants.len() diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 6deffa804b2..ec1910f9017 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -355,7 +355,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { Some("the `int` type is deprecated; \ use `isize` or a fixed-sized integer") } else if name == "uint" { - Some("the `unt` type is deprecated; \ + Some("the `uint` type is deprecated; \ use `usize` or a fixed-sized integer") } else { None diff --git a/src/test/compile-fail/feature-gate-int-uint.rs b/src/test/compile-fail/feature-gate-int-uint.rs index 94190cc1511..016a0394289 100644 --- a/src/test/compile-fail/feature-gate-int-uint.rs +++ b/src/test/compile-fail/feature-gate-int-uint.rs @@ -11,21 +11,21 @@ #![allow(dead_code)] mod u { - type X = usize; //~ WARN the `usize` type is deprecated + type X = uint; //~ WARN the `uint` type is deprecated struct Foo { - x: usize //~ WARN the `usize` type is deprecated + x: uint //~ WARN the `uint` type is deprecated } - fn bar(x: usize) { //~ WARN the `usize` type is deprecated - 1us; //~ WARN the `u` suffix on integers is deprecated + fn bar(x: uint) { //~ WARN the `uint` type is deprecated + 1u; //~ WARN the `u` suffix on integers is deprecated } } mod i { - type X = isize; //~ WARN the `isize` type is deprecated + type X = int; //~ WARN the `int` type is deprecated struct Foo { - x: isize //~ WARN the `isize` type is deprecated + x: int //~ WARN the `int` type is deprecated } - fn bar(x: isize) { //~ WARN the `isize` type is deprecated - 1is; //~ WARN the `u` suffix on integers is deprecated + fn bar(x: int) { //~ WARN the `int` type is deprecated + 1i; //~ WARN the `i` suffix on integers is deprecated } } diff --git a/src/test/compile-fail/issue-13482-2.rs b/src/test/compile-fail/issue-13482-2.rs index 5c9b0473cea..ef7d3d4d158 100644 --- a/src/test/compile-fail/issue-13482-2.rs +++ b/src/test/compile-fail/issue-13482-2.rs @@ -14,7 +14,7 @@ fn main() { let x = [1,2]; let y = match x { [] => None, - //~^ ERROR types: expected `[_#0is; 2]`, found `[_#7t; 0]` + //~^ ERROR types: expected `[_#0i; 2]`, found `[_#7t; 0]` // (expected array of 2 elements, found array of 0 elements) [a,_] => Some(a) }; diff --git a/src/test/compile-fail/issue-5544-a.rs b/src/test/compile-fail/issue-5544-a.rs index 6db126f403a..42a18ba5fb7 100644 --- a/src/test/compile-fail/issue-5544-a.rs +++ b/src/test/compile-fail/issue-5544-a.rs @@ -10,5 +10,5 @@ fn main() { let _i = 18446744073709551616; // 2^64 - //~^ ERROR isize literal is too large + //~^ ERROR int literal is too large } diff --git a/src/test/compile-fail/lex-bad-numeric-literals.rs b/src/test/compile-fail/lex-bad-numeric-literals.rs index 273a7627d73..9a490be6a01 100644 --- a/src/test/compile-fail/lex-bad-numeric-literals.rs +++ b/src/test/compile-fail/lex-bad-numeric-literals.rs @@ -21,8 +21,8 @@ fn main() { 0o; //~ ERROR: no valid digits 1e+; //~ ERROR: expected at least one digit in exponent 0x539.0; //~ ERROR: hexadecimal float literal is not supported - 99999999999999999999999999999999; //~ ERROR: isize literal is too large - 99999999999999999999999999999999u32; //~ ERROR: isize literal is too large + 99999999999999999999999999999999; //~ ERROR: int literal is too large + 99999999999999999999999999999999u32; //~ ERROR: int literal is too large 0x; //~ ERROR: no valid digits 0xu32; //~ ERROR: no valid digits 0ou32; //~ ERROR: no valid digits diff --git a/src/test/compile-fail/lint-type-limits.rs b/src/test/compile-fail/lint-type-limits.rs index 3224dec1c99..a2bc464ac49 100644 --- a/src/test/compile-fail/lint-type-limits.rs +++ b/src/test/compile-fail/lint-type-limits.rs @@ -50,12 +50,12 @@ fn qux() { } fn quy() { - let i = -23us; //~ WARNING negation of unsigned isize literal may be unintentional + let i = -23us; //~ WARNING negation of unsigned int literal may be unintentional //~^ WARNING unused variable } fn quz() { let i = 23us; - let j = -i; //~ WARNING negation of unsigned isize variable may be unintentional + let j = -i; //~ WARNING negation of unsigned int variable may be unintentional //~^ WARNING unused variable } diff --git a/src/test/compile-fail/oversized-literal.rs b/src/test/compile-fail/oversized-literal.rs index 2a70653bd6c..5416bcacf3d 100644 --- a/src/test/compile-fail/oversized-literal.rs +++ b/src/test/compile-fail/oversized-literal.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - println!("{}", 18446744073709551616u64); //~ error: isize literal is too large + println!("{}", 18446744073709551616u64); //~ error: int literal is too large } -- cgit 1.4.1-3-g733a5