diff options
| author | bors <bors@rust-lang.org> | 2021-07-09 12:51:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-09 12:51:02 +0000 |
| commit | e916b7cb7708e470be8d0134bdf39479051a5c44 (patch) | |
| tree | 9e8b46bfdf7ca349530c03ca20ea3ac8e6c187c4 /src | |
| parent | ee86f96ba176f598d64dc9f3bb7e074d5b8b86b6 (diff) | |
| parent | d019c71df9c88c7ee19065cb6699008e55d51610 (diff) | |
| download | rust-e916b7cb7708e470be8d0134bdf39479051a5c44.tar.gz rust-e916b7cb7708e470be8d0134bdf39479051a5c44.zip | |
Auto merge of #86888 - FabianWolff:issue-86600, r=davidtwco
Fix double warning about illegal floating-point literal pattern This PR fixes #86600. The problem is that the `ConstToPat` struct contains a field `include_lint_checks`, which determines whether lints should be emitted or not, but this field is currently not obeyed at one point, leading to a warning being emitted more than once. I have fixed this behavior here.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/deduplicate-diagnostics-2.deduplicate.stderr | 30 | ||||
| -rw-r--r-- | src/test/ui/deduplicate-diagnostics-2.duplicate.stderr | 39 | ||||
| -rw-r--r-- | src/test/ui/deduplicate-diagnostics-2.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-41255.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-41255.stderr | 132 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-6804.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-6804.stderr | 22 | ||||
| -rw-r--r-- | src/test/ui/lint/issue-86600-lint-twice.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/lint/issue-86600-lint-twice.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr | 11 |
11 files changed, 42 insertions, 266 deletions
diff --git a/src/test/ui/deduplicate-diagnostics-2.deduplicate.stderr b/src/test/ui/deduplicate-diagnostics-2.deduplicate.stderr deleted file mode 100644 index 7f6a432d5ab..00000000000 --- a/src/test/ui/deduplicate-diagnostics-2.deduplicate.stderr +++ /dev/null @@ -1,30 +0,0 @@ -warning: floating-point types cannot be used in patterns - --> $DIR/deduplicate-diagnostics-2.rs:7:9 - | -LL | 1.0 => {} - | ^^^ - | - = note: `#[warn(illegal_floating_point_literal_pattern)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -warning: floating-point types cannot be used in patterns - --> $DIR/deduplicate-diagnostics-2.rs:11:9 - | -LL | 2.0 => {} - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -warning: floating-point types cannot be used in patterns - --> $DIR/deduplicate-diagnostics-2.rs:7:9 - | -LL | 1.0 => {} - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -warning: 3 warnings emitted - diff --git a/src/test/ui/deduplicate-diagnostics-2.duplicate.stderr b/src/test/ui/deduplicate-diagnostics-2.duplicate.stderr deleted file mode 100644 index f2315bc91ec..00000000000 --- a/src/test/ui/deduplicate-diagnostics-2.duplicate.stderr +++ /dev/null @@ -1,39 +0,0 @@ -warning: floating-point types cannot be used in patterns - --> $DIR/deduplicate-diagnostics-2.rs:7:9 - | -LL | 1.0 => {} - | ^^^ - | - = note: `#[warn(illegal_floating_point_literal_pattern)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -warning: floating-point types cannot be used in patterns - --> $DIR/deduplicate-diagnostics-2.rs:11:9 - | -LL | 2.0 => {} - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -warning: floating-point types cannot be used in patterns - --> $DIR/deduplicate-diagnostics-2.rs:7:9 - | -LL | 1.0 => {} - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -warning: floating-point types cannot be used in patterns - --> $DIR/deduplicate-diagnostics-2.rs:11:9 - | -LL | 2.0 => {} - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -warning: 4 warnings emitted - diff --git a/src/test/ui/deduplicate-diagnostics-2.rs b/src/test/ui/deduplicate-diagnostics-2.rs deleted file mode 100644 index f46a7c0c1c4..00000000000 --- a/src/test/ui/deduplicate-diagnostics-2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// build-pass -// revisions: duplicate deduplicate -//[deduplicate] compile-flags: -Z deduplicate-diagnostics=yes - -fn main() { - match 0.0 { - 1.0 => {} //~ WARNING floating-point types cannot be used in patterns - //~| WARNING this was previously accepted - //~| WARNING floating-point types cannot be used in patterns - //~| WARNING this was previously accepted - 2.0 => {} //~ WARNING floating-point types cannot be used in patterns - //~| WARNING this was previously accepted - //[duplicate]~| WARNING floating-point types cannot be used in patterns - //[duplicate]~| WARNING this was previously accepted - _ => {} - } -} diff --git a/src/test/ui/issues/issue-41255.rs b/src/test/ui/issues/issue-41255.rs index 5b95a737913..9d7072f1665 100644 --- a/src/test/ui/issues/issue-41255.rs +++ b/src/test/ui/issues/issue-41255.rs @@ -10,47 +10,27 @@ fn main() { match x { 5.0 => {}, //~ ERROR floating-point types cannot be used in patterns //~| WARNING hard error - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING this was previously accepted by the compiler but is being 5.0f32 => {}, //~ ERROR floating-point types cannot be used in patterns - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error //~| WARNING hard error -5.0 => {}, //~ ERROR floating-point types cannot be used in patterns - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error //~| WARNING hard error 1.0 .. 33.0 => {}, //~ ERROR floating-point types cannot be used in patterns //~| WARNING hard error //~| ERROR floating-point types cannot be used in patterns //~| WARNING hard error - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error 39.0 ..= 70.0 => {}, //~ ERROR floating-point types cannot be used in patterns //~| ERROR floating-point types cannot be used in patterns //~| WARNING hard error - //~| ERROR floating-point types cannot be used in patterns - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error - //~| WARNING hard error //~| WARNING hard error ..71.0 => {} //~^ ERROR floating-point types cannot be used in patterns - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error //~| WARNING this was previously accepted by the compiler ..=72.0 => {} //~^ ERROR floating-point types cannot be used in patterns - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error //~| WARNING this was previously accepted by the compiler 71.0.. => {} //~^ ERROR floating-point types cannot be used in patterns - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error //~| WARNING this was previously accepted by the compiler _ => {}, }; @@ -58,8 +38,6 @@ fn main() { // Same for tuples match (x, 5) { (3.14, 1) => {}, //~ ERROR floating-point types cannot be used - //~| ERROR floating-point types cannot be used - //~| WARNING hard error //~| WARNING hard error _ => {}, } @@ -67,8 +45,6 @@ fn main() { struct Foo { x: f32 }; match (Foo { x }) { Foo { x: 2.0 } => {}, //~ ERROR floating-point types cannot be used - //~| ERROR floating-point types cannot be used - //~| WARNING hard error //~| WARNING hard error _ => {}, } diff --git a/src/test/ui/issues/issue-41255.stderr b/src/test/ui/issues/issue-41255.stderr index b6e57afcd12..bf81c8d371c 100644 --- a/src/test/ui/issues/issue-41255.stderr +++ b/src/test/ui/issues/issue-41255.stderr @@ -13,7 +13,7 @@ LL | #![forbid(illegal_floating_point_literal_pattern)] = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:15:9 + --> $DIR/issue-41255.rs:13:9 | LL | 5.0f32 => {}, | ^^^^^^ @@ -22,7 +22,7 @@ LL | 5.0f32 => {}, = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:19:10 + --> $DIR/issue-41255.rs:15:10 | LL | -5.0 => {}, | ^^^ @@ -31,7 +31,7 @@ LL | -5.0 => {}, = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:23:9 + --> $DIR/issue-41255.rs:17:9 | LL | 1.0 .. 33.0 => {}, | ^^^ @@ -40,7 +40,7 @@ LL | 1.0 .. 33.0 => {}, = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:23:16 + --> $DIR/issue-41255.rs:17:16 | LL | 1.0 .. 33.0 => {}, | ^^^^ @@ -49,7 +49,7 @@ LL | 1.0 .. 33.0 => {}, = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:31:9 + --> $DIR/issue-41255.rs:21:9 | LL | 39.0 ..= 70.0 => {}, | ^^^^ @@ -58,7 +58,7 @@ LL | 39.0 ..= 70.0 => {}, = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:31:18 + --> $DIR/issue-41255.rs:21:18 | LL | 39.0 ..= 70.0 => {}, | ^^^^ @@ -67,7 +67,7 @@ LL | 39.0 ..= 70.0 => {}, = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:40:11 + --> $DIR/issue-41255.rs:26:11 | LL | ..71.0 => {} | ^^^^ @@ -76,7 +76,7 @@ LL | ..71.0 => {} = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:45:12 + --> $DIR/issue-41255.rs:29:12 | LL | ..=72.0 => {} | ^^^^ @@ -85,7 +85,7 @@ LL | ..=72.0 => {} = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:50:9 + --> $DIR/issue-41255.rs:32:9 | LL | 71.0.. => {} | ^^^^ @@ -94,7 +94,7 @@ LL | 71.0.. => {} = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:60:10 + --> $DIR/issue-41255.rs:40:10 | LL | (3.14, 1) => {}, | ^^^^ @@ -103,7 +103,7 @@ LL | (3.14, 1) => {}, = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:69:18 + --> $DIR/issue-41255.rs:47:18 | LL | Foo { x: 2.0 } => {}, | ^^^ @@ -111,113 +111,5 @@ LL | Foo { x: 2.0 } => {}, = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:11:9 - | -LL | 5.0 => {}, - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:15:9 - | -LL | 5.0f32 => {}, - | ^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:19:10 - | -LL | -5.0 => {}, - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:23:9 - | -LL | 1.0 .. 33.0 => {}, - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:23:16 - | -LL | 1.0 .. 33.0 => {}, - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:31:9 - | -LL | 39.0 ..= 70.0 => {}, - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:31:18 - | -LL | 39.0 ..= 70.0 => {}, - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:40:11 - | -LL | ..71.0 => {} - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:45:12 - | -LL | ..=72.0 => {} - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:50:9 - | -LL | 71.0.. => {} - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:60:10 - | -LL | (3.14, 1) => {}, - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:69:18 - | -LL | Foo { x: 2.0 } => {}, - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: aborting due to 24 previous errors +error: aborting due to 12 previous errors diff --git a/src/test/ui/issues/issue-6804.rs b/src/test/ui/issues/issue-6804.rs index 6d950c424e3..0260caa82cb 100644 --- a/src/test/ui/issues/issue-6804.rs +++ b/src/test/ui/issues/issue-6804.rs @@ -9,16 +9,12 @@ fn main() { let x = NAN; match x { NAN => {}, //~ ERROR floating-point types cannot be used - //~^ WARN this was previously accepted by the compiler but is being phased out - //~| ERROR floating-point types cannot be used in patterns //~| WARN this was previously accepted by the compiler but is being phased out _ => {}, }; match [x, 1.0] { [NAN, _] => {}, //~ ERROR floating-point types cannot be used - //~| ERROR floating-point types cannot be used - //~| WARN this was previously accepted by the compiler but is being phased out //~| WARN this was previously accepted by the compiler but is being phased out _ => {}, }; diff --git a/src/test/ui/issues/issue-6804.stderr b/src/test/ui/issues/issue-6804.stderr index c7411e27c25..4e2961e5e23 100644 --- a/src/test/ui/issues/issue-6804.stderr +++ b/src/test/ui/issues/issue-6804.stderr @@ -13,7 +13,7 @@ LL | #![deny(illegal_floating_point_literal_pattern)] = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> error: floating-point types cannot be used in patterns - --> $DIR/issue-6804.rs:19:10 + --> $DIR/issue-6804.rs:17:10 | LL | [NAN, _] => {}, | ^^^ @@ -21,23 +21,5 @@ LL | [NAN, _] => {}, = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> -error: floating-point types cannot be used in patterns - --> $DIR/issue-6804.rs:11:9 - | -LL | NAN => {}, - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: floating-point types cannot be used in patterns - --> $DIR/issue-6804.rs:19:10 - | -LL | [NAN, _] => {}, - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/src/test/ui/lint/issue-86600-lint-twice.rs b/src/test/ui/lint/issue-86600-lint-twice.rs new file mode 100644 index 00000000000..0e8a837d987 --- /dev/null +++ b/src/test/ui/lint/issue-86600-lint-twice.rs @@ -0,0 +1,15 @@ +// Regression test for #86600, where an instance of the +// `illegal_floating_point_literal_pattern` lint was issued twice. + +// check-pass + +fn main() { + let x = 42.0; + + match x { + 5.0 => {} + //~^ WARNING: floating-point types cannot be used in patterns + //~| WARNING: this was previously accepted by the compiler + _ => {} + } +} diff --git a/src/test/ui/lint/issue-86600-lint-twice.stderr b/src/test/ui/lint/issue-86600-lint-twice.stderr new file mode 100644 index 00000000000..8da3fb5a839 --- /dev/null +++ b/src/test/ui/lint/issue-86600-lint-twice.stderr @@ -0,0 +1,12 @@ +warning: floating-point types cannot be used in patterns + --> $DIR/issue-86600-lint-twice.rs:10:9 + | +LL | 5.0 => {} + | ^^^ + | + = note: `#[warn(illegal_floating_point_literal_pattern)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> + +warning: 1 warning emitted + diff --git a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs index fa5630837b9..59a22c33778 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs +++ b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs @@ -17,8 +17,6 @@ fn main() { match x { f32::INFINITY => { } //~^ WARNING floating-point types cannot be used in patterns - //~| WARNING will become a hard error in a future release - //~| WARNING floating-point types cannot be used in patterns //~| WARNING this was previously accepted by the compiler but is being phased out _ => { } } diff --git a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr index 9a5d57d4118..df4809dabf1 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr +++ b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr @@ -14,14 +14,5 @@ LL | f32::INFINITY => { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> -warning: floating-point types cannot be used in patterns - --> $DIR/match-forbidden-without-eq.rs:18:9 - | -LL | f32::INFINITY => { } - | ^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620> - -error: aborting due to previous error; 2 warnings emitted +error: aborting due to previous error; 1 warning emitted |
