Skip to content

Commit a67faf1

Browse files
committed
Change the trivial cast lints to allow by default
1 parent 199bdcf commit a67faf1

File tree

25 files changed

+8
-32
lines changed

25 files changed

+8
-32
lines changed

src/libcollections/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#![doc(test(no_crate_inject))]
2626

2727
#![allow(trivial_casts)]
28-
#![allow(trivial_numeric_casts)]
2928
#![feature(alloc)]
3029
#![feature(box_syntax)]
3130
#![feature(box_patterns)]

src/libcore/fmt/num.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// FIXME: #6220 Implement floating point formatting
1414

1515
#![allow(unsigned_negation)]
16-
#![allow(trivial_numeric_casts)]
1716

1817
use fmt;
1918
use iter::IteratorExt;

src/libcore/num/i16.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414
#![doc(primitive = "i16")]
15-
#![allow(trivial_numeric_casts)]
1615

1716
int_module! { i16, 16 }

src/libcore/num/i32.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414
#![doc(primitive = "i32")]
15-
#![allow(trivial_numeric_casts)]
1615

1716
int_module! { i32, 32 }

src/libcore/num/i64.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414
#![doc(primitive = "i64")]
15-
#![allow(trivial_numeric_casts)]
1615

1716
int_module! { i64, 64 }

src/libcore/num/i8.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414
#![doc(primitive = "i8")]
15-
#![allow(trivial_numeric_casts)]
1615

1716
int_module! { i8, 8 }

src/libcore/num/int_macros.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
#![doc(hidden)]
12-
#![allow(trivial_numeric_casts)]
1312

1413
macro_rules! int_module { ($T:ty, $bits:expr) => (
1514

src/libcore/num/isize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
1717
#![stable(feature = "rust1", since = "1.0.0")]
1818
#![doc(primitive = "isize")]
19-
#![allow(trivial_numeric_casts)]
2019

2120
#[cfg(target_pointer_width = "32")]
2221
int_module! { isize, 32 }

src/libcore/num/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
1515
#![stable(feature = "rust1", since = "1.0.0")]
1616
#![allow(missing_docs)]
17-
#![allow(trivial_numeric_casts)]
1817

1918
use self::wrapping::{OverflowingOps, WrappingOps};
2019

src/libcore/num/u16.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414
#![doc(primitive = "u16")]
15-
#![allow(trivial_numeric_casts)]
1615

1716
uint_module! { u16, i16, 16 }

src/libcore/num/u32.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414
#![doc(primitive = "u32")]
15-
#![allow(trivial_numeric_casts)]
1615

1716
uint_module! { u32, i32, 32 }

src/libcore/num/u64.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414
#![doc(primitive = "u64")]
15-
#![allow(trivial_numeric_casts)]
1615

1716
uint_module! { u64, i64, 64 }

src/libcore/num/u8.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414
#![doc(primitive = "u8")]
15-
#![allow(trivial_numeric_casts)]
1615

1716
uint_module! { u8, i8, 8 }

src/libcore/num/uint_macros.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
#![doc(hidden)]
12-
#![allow(trivial_numeric_casts)]
1312

1413
macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => (
1514

src/libcore/num/usize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@
1616
1717
#![stable(feature = "rust1", since = "1.0.0")]
1818
#![doc(primitive = "usize")]
19-
#![allow(trivial_numeric_casts)]
2019

2120
uint_module! { usize, isize, ::isize::BITS }

src/librand/distributions/range.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
//! Generating numbers between two others.
1212
13-
#![allow(trivial_numeric_casts)]
14-
1513
// this is surprisingly complicated to be both generic & correct
1614

1715
use core::prelude::{PartialOrd};

src/librand/isaac.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@ impl Rng for Isaac64Rng {
447447

448448
#[inline]
449449
fn next_u64(&mut self) -> u64 {
450-
#![allow(trivial_numeric_casts)]
451450
if self.cnt == 0 {
452451
// make some more numbers
453452
self.isaac64();

src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#![cfg_attr(test, feature(test))]
4949

5050
#![allow(trivial_casts)]
51-
#![allow(trivial_numeric_casts)]
5251

5352
extern crate arena;
5453
extern crate flate;

src/librustc/lint/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ declare_lint! {
102102

103103
declare_lint! {
104104
pub TRIVIAL_CASTS,
105-
Warn,
105+
Allow,
106106
"detects trivial casts which could be removed"
107107
}
108108

109109
declare_lint! {
110110
pub TRIVIAL_NUMERIC_CASTS,
111-
Warn,
111+
Allow,
112112
"detects trivial casts of numeric types which could be removed"
113113
}
114114
/// Does nothing as a lint pass, but registers some `Lint`s

src/librustc_llvm/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![allow(non_snake_case)]
1616
#![allow(dead_code)]
1717
#![allow(trivial_casts)]
18-
#![allow(trivial_numeric_casts)]
1918

2019
#![crate_name = "rustc_llvm"]
2120
#![unstable(feature = "rustc_private")]

src/librustc_trans/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#![feature(path_relative_from)]
4545

4646
#![allow(trivial_casts)]
47-
#![allow(trivial_numeric_casts)]
4847

4948
extern crate arena;
5049
extern crate flate;

src/librustc_typeck/check/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,14 +1105,18 @@ fn check_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, cast: &CastCheck<'tcx>) {
11051105
fcx.tcx().sess.add_lint(lint::builtin::TRIVIAL_NUMERIC_CASTS,
11061106
e.id,
11071107
span,
1108-
format!("trivial numeric cast: `{}` as `{}`",
1108+
format!("trivial numeric cast: `{}` as `{}`. Cast can be \
1109+
replaced by coercion, this might require type \
1110+
ascription or a temporary variable",
11091111
fcx.infcx().ty_to_string(t_e),
11101112
fcx.infcx().ty_to_string(t_1)));
11111113
} else {
11121114
fcx.tcx().sess.add_lint(lint::builtin::TRIVIAL_CASTS,
11131115
e.id,
11141116
span,
1115-
format!("trivial cast: `{}` as `{}`",
1117+
format!("trivial cast: `{}` as `{}`. Cast can be \
1118+
replaced by coercion, this might require type \
1119+
ascription or a temporary variable",
11161120
fcx.infcx().ty_to_string(t_e),
11171121
fcx.infcx().ty_to_string(t_1)));
11181122
}
@@ -4595,8 +4599,6 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
45954599
ty: attr::IntType,
45964600
disr: ty::Disr) -> bool {
45974601
fn uint_in_range(ccx: &CrateCtxt, ty: ast::UintTy, disr: ty::Disr) -> bool {
4598-
#![allow(trivial_numeric_casts)]
4599-
46004602
match ty {
46014603
ast::TyU8 => disr as u8 as Disr == disr,
46024604
ast::TyU16 => disr as u16 as Disr == disr,
@@ -4625,7 +4627,6 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
46254627
id: ast::NodeId,
46264628
hint: attr::ReprAttr)
46274629
-> Vec<Rc<ty::VariantInfo<'tcx>>> {
4628-
#![allow(trivial_numeric_casts)]
46294630
use std::num::Int;
46304631

46314632
let rty = ty::node_id_to_type(ccx.tcx, id);

src/libserialize/json.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,7 +2430,6 @@ macro_rules! to_json_impl_i64 {
24302430
($($t:ty), +) => (
24312431
$(impl ToJson for $t {
24322432
fn to_json(&self) -> Json {
2433-
#![allow(trivial_numeric_casts)]
24342433
Json::I64(*self as i64)
24352434
}
24362435
})+
@@ -2443,7 +2442,6 @@ macro_rules! to_json_impl_u64 {
24432442
($($t:ty), +) => (
24442443
$(impl ToJson for $t {
24452444
fn to_json(&self) -> Json {
2446-
#![allow(trivial_numeric_casts)]
24472445
Json::U64(*self as u64)
24482446
}
24492447
})+

src/libstd/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
#![no_std]
137137

138138
#![allow(trivial_casts)]
139-
#![allow(trivial_numeric_casts)]
140139
#![deny(missing_docs)]
141140

142141
#[cfg(test)] extern crate test;

src/libsyntax/ext/quote.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ pub mod rt {
262262
(unsigned, $t:ty, $tag:expr) => (
263263
impl ToSource for $t {
264264
fn to_source(&self) -> String {
265-
#![allow(trivial_numeric_casts)]
266265
let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit($tag));
267266
pprust::lit_to_string(&dummy_spanned(lit))
268267
}

0 commit comments

Comments
 (0)