Skip to content

Commit f7e894c

Browse files
author
mejrs
committed
Try to fix ICE
1 parent 6749ee4 commit f7e894c

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ use rustc_hir::def::*;
1717
use rustc_hir::def_id::DefId;
1818
use rustc_hir::intravisit::{self, Visitor};
1919
use rustc_hir::{HirId, Pat};
20+
use rustc_middle::ty::print::with_no_trimmed_paths;
2021
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
22+
2123
use rustc_session::lint::builtin::{
2224
BINDINGS_WITH_VARIANT_NAME, IRREFUTABLE_LET_PATTERNS, UNREACHABLE_PATTERNS,
2325
};
@@ -547,7 +549,9 @@ fn check_for_bindings_named_same_as_variants(
547549
})
548550
{
549551
let variant_count = edef.variants().len();
550-
let ty_path = cx.tcx.def_path_str(edef.did());
552+
let ty_path = with_no_trimmed_paths!({
553+
cx.tcx.def_path_str(edef.did())
554+
});
551555
cx.tcx.emit_spanned_lint(
552556
BINDINGS_WITH_VARIANT_NAME,
553557
p.hir_id,

src/test/ui/lint/lint-uppercase-variables.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ fn main() {
2020

2121
match foo::Foo::Foo {
2222
Foo => {}
23-
//~^ ERROR variable `Foo` should have a snake case name
24-
//~^^ WARN `Foo` is named the same as one of the variants of the type `Foo`
25-
//~^^^ WARN unused variable: `Foo`
23+
//~^ ERROR variable `Foo` should have a snake case name
24+
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
25+
//~^^^ WARN unused variable: `Foo`
2626
}
2727

2828
let Foo = foo::Foo::Foo;
2929
//~^ ERROR variable `Foo` should have a snake case name
30-
//~^^ WARN `Foo` is named the same as one of the variants of the type `Foo`
30+
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
3131
//~^^^ WARN unused variable: `Foo`
3232

3333
fn in_param(Foo: foo::Foo) {}
3434
//~^ ERROR variable `Foo` should have a snake case name
35-
//~^^ WARN `Foo` is named the same as one of the variants of the type `Foo`
35+
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
3636
//~^^^ WARN unused variable: `Foo`
3737

3838
test(1);

src/test/ui/lint/lint-uppercase-variables.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `Foo`
1+
warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
22
--> $DIR/lint-uppercase-variables.rs:22:9
33
|
44
LL | Foo => {}
5-
| ^^^ help: to match on the variant, qualify the path: `Foo::Foo`
5+
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
66
|
77
= note: `#[warn(bindings_with_variant_name)]` on by default
88

9-
warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `Foo`
9+
warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
1010
--> $DIR/lint-uppercase-variables.rs:28:9
1111
|
1212
LL | let Foo = foo::Foo::Foo;
13-
| ^^^ help: to match on the variant, qualify the path: `Foo::Foo`
13+
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
1414

15-
warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `Foo`
15+
warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
1616
--> $DIR/lint-uppercase-variables.rs:33:17
1717
|
1818
LL | fn in_param(Foo: foo::Foo) {}
19-
| ^^^ help: to match on the variant, qualify the path: `Foo::Foo`
19+
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
2020

2121
warning: unused variable: `Foo`
2222
--> $DIR/lint-uppercase-variables.rs:22:9

0 commit comments

Comments
 (0)