]> git.lizzy.rs Git - rust.git/commitdiff
Deny the `overflowing_literals` lint for all editions
authorOliver Middleton <olliemail27@gmail.com>
Thu, 17 Jan 2019 09:22:52 +0000 (09:22 +0000)
committerOliver Middleton <olliemail27@gmail.com>
Thu, 17 Jan 2019 09:22:52 +0000 (09:22 +0000)
13 files changed:
src/doc/rustc/src/lints/listing/deny-by-default.md
src/doc/rustc/src/lints/listing/warn-by-default.md
src/librustc_lint/types.rs
src/test/ui/editions/edition-deny-overflowing-literals-2018.rs [deleted file]
src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr [deleted file]
src/test/ui/lint/deny-overflowing-literals.rs [new file with mode: 0644]
src/test/ui/lint/deny-overflowing-literals.stderr [new file with mode: 0644]
src/test/ui/lint/lint-type-limits2.rs
src/test/ui/lint/lint-type-limits2.stderr
src/test/ui/lint/lint-type-limits3.rs
src/test/ui/lint/lint-type-limits3.stderr
src/test/ui/lint/type-overflow.rs
src/test/ui/lint/type-overflow.stderr

index ff9e0235a0435e8a95e0f160ad63c7ab2ba4711b..fa62d1a03f53b5d2f761bde3dae9bee3bf8e234e 100644 (file)
@@ -149,6 +149,26 @@ error: const items should never be #[no_mangle]
   |
 ```
 
+## overflowing-literals
+
+This lint detects literal out of range for its type. Some
+example code that triggers this lint:
+
+```rust,compile_fail
+let x: u8 = 1000;
+```
+
+This will produce:
+
+```text
+error: literal out of range for u8
+ --> src/main.rs:2:17
+  |
+2 |     let x: u8 = 1000;
+  |                 ^^^^
+  |
+```
+
 ## parenthesized-params-in-types-and-modules
 
 This lint detects incorrect parentheses. Some example code that triggers this
index 7fbbe686b5bd02b90a9bdd8b3d678cb46f05ee0a..ba927b1ef3b5761dcc08ba64c1d8d76f65e9cf42 100644 (file)
@@ -285,26 +285,6 @@ warning: functions generic over types must be mangled
   |
 ```
 
-## overflowing-literals
-
-This lint detects literal out of range for its type. Some
-example code that triggers this lint:
-
-```rust
-let x: u8 = 1000;
-```
-
-This will produce:
-
-```text
-warning: literal out of range for u8
- --> src/main.rs:2:17
-  |
-2 |     let x: u8 = 1000;
-  |                 ^^^^
-  |
-```
-
 ## path-statements
 
 This lint detects path statements with no effect. Some example code that
index 642681a73a8a0a57c2f878efdffe9ce7b4bf78f7..6d391814414fded5ca0a98f1f985f51d93801ca3 100644 (file)
@@ -15,7 +15,6 @@
 use syntax::{ast, attr};
 use syntax::errors::Applicability;
 use rustc_target::spec::abi::Abi;
-use syntax::edition::Edition;
 use syntax_pos::Span;
 use syntax::source_map;
 
@@ -29,9 +28,8 @@
 
 declare_lint! {
     OVERFLOWING_LITERALS,
-    Warn,
-    "literal out of range for its type",
-    Edition::Edition2018 => Deny
+    Deny,
+    "literal out of range for its type"
 }
 
 declare_lint! {
diff --git a/src/test/ui/editions/edition-deny-overflowing-literals-2018.rs b/src/test/ui/editions/edition-deny-overflowing-literals-2018.rs
deleted file mode 100644 (file)
index 0527d75..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-// edition:2018
-
-fn main() {
-    let x: u8 = 256;
-    //~^ error: literal out of range for u8
-}
diff --git a/src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr b/src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr
deleted file mode 100644 (file)
index 6d1d856..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-error: literal out of range for u8
-  --> $DIR/edition-deny-overflowing-literals-2018.rs:4:17
-   |
-LL |     let x: u8 = 256;
-   |                 ^^^
-   |
-   = note: #[deny(overflowing_literals)] on by default
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/lint/deny-overflowing-literals.rs b/src/test/ui/lint/deny-overflowing-literals.rs
new file mode 100644 (file)
index 0000000..ebd6654
--- /dev/null
@@ -0,0 +1,4 @@
+fn main() {
+    let x: u8 = 256;
+    //~^ error: literal out of range for u8
+}
diff --git a/src/test/ui/lint/deny-overflowing-literals.stderr b/src/test/ui/lint/deny-overflowing-literals.stderr
new file mode 100644 (file)
index 0000000..7313dd0
--- /dev/null
@@ -0,0 +1,10 @@
+error: literal out of range for u8
+  --> $DIR/deny-overflowing-literals.rs:2:17
+   |
+LL |     let x: u8 = 256;
+   |                 ^^^
+   |
+   = note: #[deny(overflowing_literals)] on by default
+
+error: aborting due to previous error
+
index 9c69ba12cf79e8cd06e0aa0fdae3ea273b85e31f..c4486e06768873a7f3c89fcab58a2ebd0b062ffb 100644 (file)
@@ -1,4 +1,5 @@
 #![allow(dead_code)]
+#![warn(overflowing_literals)]
 
 // compile-flags: -D unused-comparisons
 fn main() { }
index 3118bcec05e850db7ec6dc6a25ce76d8b71ca7d8..f88fff62e21fc1e65b6cbd9060f89467d8d62cbd 100644 (file)
@@ -1,5 +1,5 @@
 error: comparison is useless due to type limits
-  --> $DIR/lint-type-limits2.rs:12:5
+  --> $DIR/lint-type-limits2.rs:13:5
    |
 LL |     128 > bar() //~ ERROR comparison is useless due to type limits
    |     ^^^^^^^^^^^
@@ -7,12 +7,16 @@ LL |     128 > bar() //~ ERROR comparison is useless due to type limits
    = note: requested on the command line with `-D unused-comparisons`
 
 warning: literal out of range for i8
-  --> $DIR/lint-type-limits2.rs:12:5
+  --> $DIR/lint-type-limits2.rs:13:5
    |
 LL |     128 > bar() //~ ERROR comparison is useless due to type limits
    |     ^^^
    |
-   = note: #[warn(overflowing_literals)] on by default
+note: lint level defined here
+  --> $DIR/lint-type-limits2.rs:2:9
+   |
+LL | #![warn(overflowing_literals)]
+   |         ^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
index 3e95ad212eb16b7ca563c8e45543bb046d804796..a715c69f7849ef244ed38505ee987b0b2441023a 100644 (file)
@@ -1,4 +1,5 @@
 #![allow(dead_code)]
+#![warn(overflowing_literals)]
 
 // compile-flags: -D unused-comparisons
 fn main() { }
index 5e30b1646a755d773926d5c8a607284667776bca..4f47a7ce31665bc00289f8d0aeb3128e85fb6f2d 100644 (file)
@@ -1,5 +1,5 @@
 error: comparison is useless due to type limits
-  --> $DIR/lint-type-limits3.rs:8:11
+  --> $DIR/lint-type-limits3.rs:9:11
    |
 LL |     while 200 != i { //~ ERROR comparison is useless due to type limits
    |           ^^^^^^^^
@@ -7,12 +7,16 @@ LL |     while 200 != i { //~ ERROR comparison is useless due to type limits
    = note: requested on the command line with `-D unused-comparisons`
 
 warning: literal out of range for i8
-  --> $DIR/lint-type-limits3.rs:8:11
+  --> $DIR/lint-type-limits3.rs:9:11
    |
 LL |     while 200 != i { //~ ERROR comparison is useless due to type limits
    |           ^^^
    |
-   = note: #[warn(overflowing_literals)] on by default
+note: lint level defined here
+  --> $DIR/lint-type-limits3.rs:2:9
+   |
+LL | #![warn(overflowing_literals)]
+   |         ^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
index 2ccc52a0413e0e0713b09e75e98883c6eaad1bd1..64e595120737990734d65f444832b3f9ede825ca 100644 (file)
@@ -1,4 +1,5 @@
 // compile-pass
+#![warn(overflowing_literals)]
 
 fn main() {
     let error = 255i8; //~WARNING literal out of range for i8
index 3c4a37c4adf56941c9ff807ce3356415eba646a6..349d0be0164974386c1d6642717d329529b6c82d 100644 (file)
@@ -1,13 +1,17 @@
 warning: literal out of range for i8
-  --> $DIR/type-overflow.rs:4:17
+  --> $DIR/type-overflow.rs:5:17
    |
 LL |     let error = 255i8; //~WARNING literal out of range for i8
    |                 ^^^^^
    |
-   = note: #[warn(overflowing_literals)] on by default
+note: lint level defined here
+  --> $DIR/type-overflow.rs:2:9
+   |
+LL | #![warn(overflowing_literals)]
+   |         ^^^^^^^^^^^^^^^^^^^^
 
 warning: literal out of range for i8
-  --> $DIR/type-overflow.rs:9:16
+  --> $DIR/type-overflow.rs:10:16
    |
 LL |     let fail = 0b1000_0001i8; //~WARNING literal out of range for i8
    |                ^^^^^^^^^^^^^ help: consider using `u8` instead: `0b1000_0001u8`
@@ -15,7 +19,7 @@ LL |     let fail = 0b1000_0001i8; //~WARNING literal out of range for i8
    = note: the literal `0b1000_0001i8` (decimal `129`) does not fit into an `i8` and will become `-127i8`
 
 warning: literal out of range for i64
-  --> $DIR/type-overflow.rs:11:16
+  --> $DIR/type-overflow.rs:12:16
    |
 LL |     let fail = 0x8000_0000_0000_0000i64; //~WARNING literal out of range for i64
    |                ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `u64` instead: `0x8000_0000_0000_0000u64`
@@ -23,7 +27,7 @@ LL |     let fail = 0x8000_0000_0000_0000i64; //~WARNING literal out of range fo
    = note: the literal `0x8000_0000_0000_0000i64` (decimal `9223372036854775808`) does not fit into an `i64` and will become `-9223372036854775808i64`
 
 warning: literal out of range for u32
-  --> $DIR/type-overflow.rs:13:16
+  --> $DIR/type-overflow.rs:14:16
    |
 LL |     let fail = 0x1_FFFF_FFFFu32; //~WARNING literal out of range for u32
    |                ^^^^^^^^^^^^^^^^ help: consider using `u64` instead: `0x1_FFFF_FFFFu64`
@@ -31,7 +35,7 @@ LL |     let fail = 0x1_FFFF_FFFFu32; //~WARNING literal out of range for u32
    = note: the literal `0x1_FFFF_FFFFu32` (decimal `8589934591`) does not fit into an `u32` and will become `4294967295u32`
 
 warning: literal out of range for i128
-  --> $DIR/type-overflow.rs:15:22
+  --> $DIR/type-overflow.rs:16:22
    |
 LL |     let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000;
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -40,7 +44,7 @@ LL |     let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000;
    = help: consider using `u128` instead
 
 warning: literal out of range for i32
-  --> $DIR/type-overflow.rs:18:16
+  --> $DIR/type-overflow.rs:19:16
    |
 LL |     let fail = 0x8FFF_FFFF_FFFF_FFFE; //~WARNING literal out of range for i32
    |                ^^^^^^^^^^^^^^^^^^^^^
@@ -49,7 +53,7 @@ LL |     let fail = 0x8FFF_FFFF_FFFF_FFFE; //~WARNING literal out of range for i
    = help: consider using `i128` instead
 
 warning: literal out of range for i8
-  --> $DIR/type-overflow.rs:20:17
+  --> $DIR/type-overflow.rs:21:17
    |
 LL |     let fail = -0b1111_1111i8; //~WARNING literal out of range for i8
    |                 ^^^^^^^^^^^^^ help: consider using `i16` instead: `0b1111_1111i16`