Rollup merge of #68399 - Centril:check-match-unify, r=oli-obk

check_match: misc unifications and ICE fixes

These are some unifications made as a by-product of working on `hir::ExprKind::Let`.

Fixes https://github.com/rust-lang/rust/issues/68396.
Fixes https://github.com/rust-lang/rust/issues/68394.
Fixes https://github.com/rust-lang/rust/issues/68393.

r? @oli-obk @matthewjasper
This commit is contained in:
Mazdak Farrokhzad 2020-01-21 19:42:25 +01:00 committed by GitHub
commit 58504823f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 198 additions and 95 deletions

View file

@ -25,6 +25,16 @@ fn main() {
//~^^^ WARN unused variable: `Foo`
}
let Foo = foo::Foo::Foo;
//~^ ERROR variable `Foo` should have a snake case name
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
//~^^^ WARN unused variable: `Foo`
fn in_param(Foo: foo::Foo) {}
//~^ ERROR variable `Foo` should have a snake case name
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
//~^^^ WARN unused variable: `Foo`
test(1);
let _ = Something { X: 0 };

View file

@ -6,6 +6,18 @@ LL | Foo => {}
|
= note: `#[warn(bindings_with_variant_name)]` on by default
warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
--> $DIR/lint-uppercase-variables.rs:28:9
|
LL | let Foo = foo::Foo::Foo;
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
--> $DIR/lint-uppercase-variables.rs:33:17
|
LL | fn in_param(Foo: foo::Foo) {}
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:22:9
|
@ -19,6 +31,18 @@ LL | #![warn(unused)]
| ^^^^^^
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:28:9
|
LL | let Foo = foo::Foo::Foo;
| ^^^ help: consider prefixing with an underscore: `_Foo`
warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:33:17
|
LL | fn in_param(Foo: foo::Foo) {}
| ^^^ help: consider prefixing with an underscore: `_Foo`
error: structure field `X` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:10:5
|
@ -49,6 +73,18 @@ error: variable `Foo` should have a snake case name
LL | Foo => {}
| ^^^ help: convert the identifier to snake case (notice the capitalization): `foo`
error: aborting due to 4 previous errors
error: variable `Foo` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:28:9
|
LL | let Foo = foo::Foo::Foo;
| ^^^ help: convert the identifier to snake case (notice the capitalization): `foo`
error: variable `Foo` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:33:17
|
LL | fn in_param(Foo: foo::Foo) {}
| ^^^ help: convert the identifier to snake case (notice the capitalization): `foo`
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0170`.

View file

@ -0,0 +1,26 @@
pub enum EFoo {
A,
}
pub trait Foo {
const X: EFoo;
}
struct Abc;
impl Foo for Abc {
const X: EFoo = EFoo::A;
}
struct Def;
impl Foo for Def {
const X: EFoo = EFoo::A;
}
pub fn test<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) {
//~^ ERROR associated consts cannot be referenced in patterns
let A::X = arg;
//~^ ERROR associated consts cannot be referenced in patterns
}
fn main() {}

View file

@ -0,0 +1,15 @@
error[E0158]: associated consts cannot be referenced in patterns
--> $DIR/issue-68393-let-pat-assoc-constant.rs:20:40
|
LL | pub fn test<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) {
| ^^^^
error[E0158]: associated consts cannot be referenced in patterns
--> $DIR/issue-68393-let-pat-assoc-constant.rs:22:9
|
LL | let A::X = arg;
| ^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0158`.

View file

@ -0,0 +1,5 @@
fn main() {
let x = 255u8;
let 0u8..=x = 0;
//~^ ERROR runtime values cannot be referenced in patterns
}

View file

@ -0,0 +1,9 @@
error[E0080]: runtime values cannot be referenced in patterns
--> $DIR/issue-68394-let-pat-runtime-value.rs:3:15
|
LL | let 0u8..=x = 0;
| ^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.

View file

@ -0,0 +1,7 @@
fn main() {
let 1234567890123456789012345678901234567890e-340: f64 = 0.0;
//~^ ERROR could not evaluate float literal (see issue #31407)
fn param(1234567890123456789012345678901234567890e-340: f64) {}
//~^ ERROR could not evaluate float literal (see issue #31407)
}

View file

@ -0,0 +1,15 @@
error[E0080]: could not evaluate float literal (see issue #31407)
--> $DIR/issue-68396-let-float-bug.rs:2:9
|
LL | let 1234567890123456789012345678901234567890e-340: f64 = 0.0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: could not evaluate float literal (see issue #31407)
--> $DIR/issue-68396-let-float-bug.rs:5:14
|
LL | fn param(1234567890123456789012345678901234567890e-340: f64) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0080`.

View file

@ -1,8 +1,10 @@
error: unreachable pattern
--> $DIR/struct-pattern-match-useless.rs:12:9
|
LL | Foo { x: _x, y: _y } => (),
| -------------------- matches any value
LL | Foo { .. } => ()
| ^^^^^^^^^^
| ^^^^^^^^^^ unreachable pattern
|
note: lint level defined here
--> $DIR/struct-pattern-match-useless.rs:1:9