diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2015-03-27 18:41:18 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2015-03-27 18:41:18 +1300 |
| commit | a67faf1b25f40c3a4ad8545192136ceea8c4e63f (patch) | |
| tree | a8a4c4911ed287f175345042f8f14c3311aed086 | |
| parent | 199bdcfeff5cfafd1f8e8ff583d7209272469879 (diff) | |
| download | rust-a67faf1b25f40c3a4ad8545192136ceea8c4e63f.tar.gz rust-a67faf1b25f40c3a4ad8545192136ceea8c4e63f.zip | |
Change the trivial cast lints to allow by default
| -rw-r--r-- | src/libcollections/lib.rs | 1 | ||||
| -rw-r--r-- | src/libcore/fmt/num.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/i16.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/i32.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/i64.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/i8.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/int_macros.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/isize.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/u16.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/u32.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/u64.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/u8.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/uint_macros.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/usize.rs | 1 | ||||
| -rw-r--r-- | src/librand/distributions/range.rs | 2 | ||||
| -rw-r--r-- | src/librand/isaac.rs | 1 | ||||
| -rw-r--r-- | src/librustc/lib.rs | 1 | ||||
| -rw-r--r-- | src/librustc/lint/builtin.rs | 4 | ||||
| -rw-r--r-- | src/librustc_llvm/lib.rs | 1 | ||||
| -rw-r--r-- | src/librustc_trans/lib.rs | 1 | ||||
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 11 | ||||
| -rw-r--r-- | src/libserialize/json.rs | 2 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 1 |
25 files changed, 8 insertions, 32 deletions
diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 6a65c991c95..2e6a3527706 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -25,7 +25,6 @@ #![doc(test(no_crate_inject))] #![allow(trivial_casts)] -#![allow(trivial_numeric_casts)] #![feature(alloc)] #![feature(box_syntax)] #![feature(box_patterns)] diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 56d2eabc095..49da99b97cb 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -13,7 +13,6 @@ // FIXME: #6220 Implement floating point formatting #![allow(unsigned_negation)] -#![allow(trivial_numeric_casts)] use fmt; use iter::IteratorExt; diff --git a/src/libcore/num/i16.rs b/src/libcore/num/i16.rs index efafce3fdef..5ea60d0d96d 100644 --- a/src/libcore/num/i16.rs +++ b/src/libcore/num/i16.rs @@ -12,6 +12,5 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "i16")] -#![allow(trivial_numeric_casts)] int_module! { i16, 16 } diff --git a/src/libcore/num/i32.rs b/src/libcore/num/i32.rs index 72b0236a8d2..7d9faa998c1 100644 --- a/src/libcore/num/i32.rs +++ b/src/libcore/num/i32.rs @@ -12,6 +12,5 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "i32")] -#![allow(trivial_numeric_casts)] int_module! { i32, 32 } diff --git a/src/libcore/num/i64.rs b/src/libcore/num/i64.rs index a64a4febd5a..5a70911387b 100644 --- a/src/libcore/num/i64.rs +++ b/src/libcore/num/i64.rs @@ -12,6 +12,5 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "i64")] -#![allow(trivial_numeric_casts)] int_module! { i64, 64 } diff --git a/src/libcore/num/i8.rs b/src/libcore/num/i8.rs index 459814875ee..1d7d78ffa6c 100644 --- a/src/libcore/num/i8.rs +++ b/src/libcore/num/i8.rs @@ -12,6 +12,5 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "i8")] -#![allow(trivial_numeric_casts)] int_module! { i8, 8 } diff --git a/src/libcore/num/int_macros.rs b/src/libcore/num/int_macros.rs index 675f568a960..fe0d6d13c4c 100644 --- a/src/libcore/num/int_macros.rs +++ b/src/libcore/num/int_macros.rs @@ -9,7 +9,6 @@ // except according to those terms. #![doc(hidden)] -#![allow(trivial_numeric_casts)] macro_rules! int_module { ($T:ty, $bits:expr) => ( diff --git a/src/libcore/num/isize.rs b/src/libcore/num/isize.rs index 9af51a36748..0fd0d90b125 100644 --- a/src/libcore/num/isize.rs +++ b/src/libcore/num/isize.rs @@ -16,7 +16,6 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "isize")] -#![allow(trivial_numeric_casts)] #[cfg(target_pointer_width = "32")] int_module! { isize, 32 } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 0eec875afc3..9ca7b48fbe5 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -14,7 +14,6 @@ #![stable(feature = "rust1", since = "1.0.0")] #![allow(missing_docs)] -#![allow(trivial_numeric_casts)] use self::wrapping::{OverflowingOps, WrappingOps}; diff --git a/src/libcore/num/u16.rs b/src/libcore/num/u16.rs index 289c5dbd08e..21635799a77 100644 --- a/src/libcore/num/u16.rs +++ b/src/libcore/num/u16.rs @@ -12,6 +12,5 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "u16")] -#![allow(trivial_numeric_casts)] uint_module! { u16, i16, 16 } diff --git a/src/libcore/num/u32.rs b/src/libcore/num/u32.rs index 6d0b6b0e5ea..7d520770503 100644 --- a/src/libcore/num/u32.rs +++ b/src/libcore/num/u32.rs @@ -12,6 +12,5 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "u32")] -#![allow(trivial_numeric_casts)] uint_module! { u32, i32, 32 } diff --git a/src/libcore/num/u64.rs b/src/libcore/num/u64.rs index bf8747fdb6e..f10822077dc 100644 --- a/src/libcore/num/u64.rs +++ b/src/libcore/num/u64.rs @@ -12,6 +12,5 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "u64")] -#![allow(trivial_numeric_casts)] uint_module! { u64, i64, 64 } diff --git a/src/libcore/num/u8.rs b/src/libcore/num/u8.rs index 05199735d4a..3d6922b07b1 100644 --- a/src/libcore/num/u8.rs +++ b/src/libcore/num/u8.rs @@ -12,6 +12,5 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "u8")] -#![allow(trivial_numeric_casts)] uint_module! { u8, i8, 8 } diff --git a/src/libcore/num/uint_macros.rs b/src/libcore/num/uint_macros.rs index c22f31cc57e..d0c4885ad00 100644 --- a/src/libcore/num/uint_macros.rs +++ b/src/libcore/num/uint_macros.rs @@ -9,7 +9,6 @@ // except according to those terms. #![doc(hidden)] -#![allow(trivial_numeric_casts)] macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => ( diff --git a/src/libcore/num/usize.rs b/src/libcore/num/usize.rs index 82dd3312782..602ef4fe45e 100644 --- a/src/libcore/num/usize.rs +++ b/src/libcore/num/usize.rs @@ -16,6 +16,5 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(primitive = "usize")] -#![allow(trivial_numeric_casts)] uint_module! { usize, isize, ::isize::BITS } diff --git a/src/librand/distributions/range.rs b/src/librand/distributions/range.rs index a682fa85841..e6f27a28ffa 100644 --- a/src/librand/distributions/range.rs +++ b/src/librand/distributions/range.rs @@ -10,8 +10,6 @@ //! Generating numbers between two others. -#![allow(trivial_numeric_casts)] - // this is surprisingly complicated to be both generic & correct use core::prelude::{PartialOrd}; diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 14bebe0cd91..7ea62b7fd3f 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -447,7 +447,6 @@ impl Rng for Isaac64Rng { #[inline] fn next_u64(&mut self) -> u64 { - #![allow(trivial_numeric_casts)] if self.cnt == 0 { // make some more numbers self.isaac64(); diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index e8af07e4381..62ff7dd8131 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -48,7 +48,6 @@ #![cfg_attr(test, feature(test))] #![allow(trivial_casts)] -#![allow(trivial_numeric_casts)] extern crate arena; extern crate flate; diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 2cc47f258f0..9093cd00ca0 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -102,13 +102,13 @@ declare_lint! { declare_lint! { pub TRIVIAL_CASTS, - Warn, + Allow, "detects trivial casts which could be removed" } declare_lint! { pub TRIVIAL_NUMERIC_CASTS, - Warn, + Allow, "detects trivial casts of numeric types which could be removed" } /// Does nothing as a lint pass, but registers some `Lint`s diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 9d564fa56f5..d128e6f1a5f 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -15,7 +15,6 @@ #![allow(non_snake_case)] #![allow(dead_code)] #![allow(trivial_casts)] -#![allow(trivial_numeric_casts)] #![crate_name = "rustc_llvm"] #![unstable(feature = "rustc_private")] diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 99a64156d66..a9147205f7d 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -44,7 +44,6 @@ #![feature(path_relative_from)] #![allow(trivial_casts)] -#![allow(trivial_numeric_casts)] extern crate arena; extern crate flate; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 1e38a7d2d9f..3efe3a13562 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1105,14 +1105,18 @@ fn check_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, cast: &CastCheck<'tcx>) { fcx.tcx().sess.add_lint(lint::builtin::TRIVIAL_NUMERIC_CASTS, e.id, span, - format!("trivial numeric cast: `{}` as `{}`", + format!("trivial numeric cast: `{}` as `{}`. Cast can be \ + replaced by coercion, this might require type \ + ascription or a temporary variable", fcx.infcx().ty_to_string(t_e), fcx.infcx().ty_to_string(t_1))); } else { fcx.tcx().sess.add_lint(lint::builtin::TRIVIAL_CASTS, e.id, span, - format!("trivial cast: `{}` as `{}`", + format!("trivial cast: `{}` as `{}`. Cast can be \ + replaced by coercion, this might require type \ + ascription or a temporary variable", fcx.infcx().ty_to_string(t_e), fcx.infcx().ty_to_string(t_1))); } @@ -4595,8 +4599,6 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, ty: attr::IntType, disr: ty::Disr) -> bool { fn uint_in_range(ccx: &CrateCtxt, ty: ast::UintTy, disr: ty::Disr) -> bool { - #![allow(trivial_numeric_casts)] - match ty { ast::TyU8 => disr as u8 as Disr == disr, ast::TyU16 => disr as u16 as Disr == disr, @@ -4625,7 +4627,6 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, id: ast::NodeId, hint: attr::ReprAttr) -> Vec<Rc<ty::VariantInfo<'tcx>>> { - #![allow(trivial_numeric_casts)] use std::num::Int; let rty = ty::node_id_to_type(ccx.tcx, id); diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 0d6ed91d529..acd27161064 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -2430,7 +2430,6 @@ macro_rules! to_json_impl_i64 { ($($t:ty), +) => ( $(impl ToJson for $t { fn to_json(&self) -> Json { - #![allow(trivial_numeric_casts)] Json::I64(*self as i64) } })+ @@ -2443,7 +2442,6 @@ macro_rules! to_json_impl_u64 { ($($t:ty), +) => ( $(impl ToJson for $t { fn to_json(&self) -> Json { - #![allow(trivial_numeric_casts)] Json::U64(*self as u64) } })+ diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index cca6bb747d4..f3fb98e8c66 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -136,7 +136,6 @@ #![no_std] #![allow(trivial_casts)] -#![allow(trivial_numeric_casts)] #![deny(missing_docs)] #[cfg(test)] extern crate test; diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index a25a6451918..c11ffe66e6c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -262,7 +262,6 @@ pub mod rt { (unsigned, $t:ty, $tag:expr) => ( impl ToSource for $t { fn to_source(&self) -> String { - #![allow(trivial_numeric_casts)] let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit($tag)); pprust::lit_to_string(&dummy_spanned(lit)) } |
