Try to fix ICE
This commit is contained in:
parent
6749ee4d7b
commit
f7e894c000
3 changed files with 16 additions and 12 deletions
|
@ -17,7 +17,9 @@ use rustc_hir::def::*;
|
|||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{HirId, Pat};
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
|
||||
|
||||
use rustc_session::lint::builtin::{
|
||||
BINDINGS_WITH_VARIANT_NAME, IRREFUTABLE_LET_PATTERNS, UNREACHABLE_PATTERNS,
|
||||
};
|
||||
|
@ -547,7 +549,9 @@ fn check_for_bindings_named_same_as_variants(
|
|||
})
|
||||
{
|
||||
let variant_count = edef.variants().len();
|
||||
let ty_path = cx.tcx.def_path_str(edef.did());
|
||||
let ty_path = with_no_trimmed_paths!({
|
||||
cx.tcx.def_path_str(edef.did())
|
||||
});
|
||||
cx.tcx.emit_spanned_lint(
|
||||
BINDINGS_WITH_VARIANT_NAME,
|
||||
p.hir_id,
|
||||
|
|
|
@ -20,19 +20,19 @@ fn main() {
|
|||
|
||||
match 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`
|
||||
//~^^^ WARN unused variable: `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`
|
||||
}
|
||||
|
||||
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`
|
||||
//~^^ 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`
|
||||
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
|
||||
//~^^^ WARN unused variable: `Foo`
|
||||
|
||||
test(1);
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `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:22:9
|
||||
|
|
||||
LL | Foo => {}
|
||||
| ^^^ help: to match on the variant, qualify the path: `Foo::Foo`
|
||||
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::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`
|
||||
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`
|
||||
| ^^^ 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`
|
||||
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`
|
||||
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
|
||||
|
||||
warning: unused variable: `Foo`
|
||||
--> $DIR/lint-uppercase-variables.rs:22:9
|
||||
|
|
Loading…
Add table
Reference in a new issue