Skip to content

Commit

Permalink
Try to fix ICE
Browse files Browse the repository at this point in the history
  • Loading branch information
mejrs committed Dec 17, 2022
1 parent 6749ee4 commit f7e894c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 5 additions & 1 deletion compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/lint/lint-uppercase-variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/lint/lint-uppercase-variables.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit f7e894c

Please sign in to comment.