Change the trivial cast lints to allow by default
This commit is contained in:
parent
199bdcfeff
commit
a67faf1b25
25 changed files with 8 additions and 32 deletions
|
@ -25,7 +25,6 @@
|
||||||
#![doc(test(no_crate_inject))]
|
#![doc(test(no_crate_inject))]
|
||||||
|
|
||||||
#![allow(trivial_casts)]
|
#![allow(trivial_casts)]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
#![feature(alloc)]
|
#![feature(alloc)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
// FIXME: #6220 Implement floating point formatting
|
// FIXME: #6220 Implement floating point formatting
|
||||||
|
|
||||||
#![allow(unsigned_negation)]
|
#![allow(unsigned_negation)]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
use fmt;
|
use fmt;
|
||||||
use iter::IteratorExt;
|
use iter::IteratorExt;
|
||||||
|
|
|
@ -12,6 +12,5 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "i16")]
|
#![doc(primitive = "i16")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
int_module! { i16, 16 }
|
int_module! { i16, 16 }
|
||||||
|
|
|
@ -12,6 +12,5 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "i32")]
|
#![doc(primitive = "i32")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
int_module! { i32, 32 }
|
int_module! { i32, 32 }
|
||||||
|
|
|
@ -12,6 +12,5 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "i64")]
|
#![doc(primitive = "i64")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
int_module! { i64, 64 }
|
int_module! { i64, 64 }
|
||||||
|
|
|
@ -12,6 +12,5 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "i8")]
|
#![doc(primitive = "i8")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
int_module! { i8, 8 }
|
int_module! { i8, 8 }
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![doc(hidden)]
|
#![doc(hidden)]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
macro_rules! int_module { ($T:ty, $bits:expr) => (
|
macro_rules! int_module { ($T:ty, $bits:expr) => (
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "isize")]
|
#![doc(primitive = "isize")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
int_module! { isize, 32 }
|
int_module! { isize, 32 }
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
use self::wrapping::{OverflowingOps, WrappingOps};
|
use self::wrapping::{OverflowingOps, WrappingOps};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,5 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "u16")]
|
#![doc(primitive = "u16")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
uint_module! { u16, i16, 16 }
|
uint_module! { u16, i16, 16 }
|
||||||
|
|
|
@ -12,6 +12,5 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "u32")]
|
#![doc(primitive = "u32")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
uint_module! { u32, i32, 32 }
|
uint_module! { u32, i32, 32 }
|
||||||
|
|
|
@ -12,6 +12,5 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "u64")]
|
#![doc(primitive = "u64")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
uint_module! { u64, i64, 64 }
|
uint_module! { u64, i64, 64 }
|
||||||
|
|
|
@ -12,6 +12,5 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "u8")]
|
#![doc(primitive = "u8")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
uint_module! { u8, i8, 8 }
|
uint_module! { u8, i8, 8 }
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![doc(hidden)]
|
#![doc(hidden)]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => (
|
macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => (
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,5 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![doc(primitive = "usize")]
|
#![doc(primitive = "usize")]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
uint_module! { usize, isize, ::isize::BITS }
|
uint_module! { usize, isize, ::isize::BITS }
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
//! Generating numbers between two others.
|
//! Generating numbers between two others.
|
||||||
|
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
// this is surprisingly complicated to be both generic & correct
|
// this is surprisingly complicated to be both generic & correct
|
||||||
|
|
||||||
use core::prelude::{PartialOrd};
|
use core::prelude::{PartialOrd};
|
||||||
|
|
|
@ -447,7 +447,6 @@ impl Rng for Isaac64Rng {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next_u64(&mut self) -> u64 {
|
fn next_u64(&mut self) -> u64 {
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
if self.cnt == 0 {
|
if self.cnt == 0 {
|
||||||
// make some more numbers
|
// make some more numbers
|
||||||
self.isaac64();
|
self.isaac64();
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#![cfg_attr(test, feature(test))]
|
#![cfg_attr(test, feature(test))]
|
||||||
|
|
||||||
#![allow(trivial_casts)]
|
#![allow(trivial_casts)]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
extern crate arena;
|
extern crate arena;
|
||||||
extern crate flate;
|
extern crate flate;
|
||||||
|
|
|
@ -102,13 +102,13 @@ declare_lint! {
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
pub TRIVIAL_CASTS,
|
pub TRIVIAL_CASTS,
|
||||||
Warn,
|
Allow,
|
||||||
"detects trivial casts which could be removed"
|
"detects trivial casts which could be removed"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
pub TRIVIAL_NUMERIC_CASTS,
|
pub TRIVIAL_NUMERIC_CASTS,
|
||||||
Warn,
|
Allow,
|
||||||
"detects trivial casts of numeric types which could be removed"
|
"detects trivial casts of numeric types which could be removed"
|
||||||
}
|
}
|
||||||
/// Does nothing as a lint pass, but registers some `Lint`s
|
/// Does nothing as a lint pass, but registers some `Lint`s
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(trivial_casts)]
|
#![allow(trivial_casts)]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
#![crate_name = "rustc_llvm"]
|
#![crate_name = "rustc_llvm"]
|
||||||
#![unstable(feature = "rustc_private")]
|
#![unstable(feature = "rustc_private")]
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#![feature(path_relative_from)]
|
#![feature(path_relative_from)]
|
||||||
|
|
||||||
#![allow(trivial_casts)]
|
#![allow(trivial_casts)]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
extern crate arena;
|
extern crate arena;
|
||||||
extern crate flate;
|
extern crate flate;
|
||||||
|
|
|
@ -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,
|
fcx.tcx().sess.add_lint(lint::builtin::TRIVIAL_NUMERIC_CASTS,
|
||||||
e.id,
|
e.id,
|
||||||
span,
|
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_e),
|
||||||
fcx.infcx().ty_to_string(t_1)));
|
fcx.infcx().ty_to_string(t_1)));
|
||||||
} else {
|
} else {
|
||||||
fcx.tcx().sess.add_lint(lint::builtin::TRIVIAL_CASTS,
|
fcx.tcx().sess.add_lint(lint::builtin::TRIVIAL_CASTS,
|
||||||
e.id,
|
e.id,
|
||||||
span,
|
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_e),
|
||||||
fcx.infcx().ty_to_string(t_1)));
|
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,
|
ty: attr::IntType,
|
||||||
disr: ty::Disr) -> bool {
|
disr: ty::Disr) -> bool {
|
||||||
fn uint_in_range(ccx: &CrateCtxt, ty: ast::UintTy, disr: ty::Disr) -> bool {
|
fn uint_in_range(ccx: &CrateCtxt, ty: ast::UintTy, disr: ty::Disr) -> bool {
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
|
|
||||||
match ty {
|
match ty {
|
||||||
ast::TyU8 => disr as u8 as Disr == disr,
|
ast::TyU8 => disr as u8 as Disr == disr,
|
||||||
ast::TyU16 => disr as u16 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,
|
id: ast::NodeId,
|
||||||
hint: attr::ReprAttr)
|
hint: attr::ReprAttr)
|
||||||
-> Vec<Rc<ty::VariantInfo<'tcx>>> {
|
-> Vec<Rc<ty::VariantInfo<'tcx>>> {
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
use std::num::Int;
|
use std::num::Int;
|
||||||
|
|
||||||
let rty = ty::node_id_to_type(ccx.tcx, id);
|
let rty = ty::node_id_to_type(ccx.tcx, id);
|
||||||
|
|
|
@ -2430,7 +2430,6 @@ macro_rules! to_json_impl_i64 {
|
||||||
($($t:ty), +) => (
|
($($t:ty), +) => (
|
||||||
$(impl ToJson for $t {
|
$(impl ToJson for $t {
|
||||||
fn to_json(&self) -> Json {
|
fn to_json(&self) -> Json {
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
Json::I64(*self as i64)
|
Json::I64(*self as i64)
|
||||||
}
|
}
|
||||||
})+
|
})+
|
||||||
|
@ -2443,7 +2442,6 @@ macro_rules! to_json_impl_u64 {
|
||||||
($($t:ty), +) => (
|
($($t:ty), +) => (
|
||||||
$(impl ToJson for $t {
|
$(impl ToJson for $t {
|
||||||
fn to_json(&self) -> Json {
|
fn to_json(&self) -> Json {
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
Json::U64(*self as u64)
|
Json::U64(*self as u64)
|
||||||
}
|
}
|
||||||
})+
|
})+
|
||||||
|
|
|
@ -136,7 +136,6 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
#![allow(trivial_casts)]
|
#![allow(trivial_casts)]
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
#[cfg(test)] extern crate test;
|
#[cfg(test)] extern crate test;
|
||||||
|
|
|
@ -262,7 +262,6 @@ pub mod rt {
|
||||||
(unsigned, $t:ty, $tag:expr) => (
|
(unsigned, $t:ty, $tag:expr) => (
|
||||||
impl ToSource for $t {
|
impl ToSource for $t {
|
||||||
fn to_source(&self) -> String {
|
fn to_source(&self) -> String {
|
||||||
#![allow(trivial_numeric_casts)]
|
|
||||||
let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit($tag));
|
let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit($tag));
|
||||||
pprust::lit_to_string(&dummy_spanned(lit))
|
pprust::lit_to_string(&dummy_spanned(lit))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue