Skip to content

Commit 3ba27e7

Browse files
Use same_type_modulo_infer in more places
1 parent 5bc9807 commit 3ba27e7

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
18791879
.iter()
18801880
.filter(|field| field.vis.is_accessible_from(field.did, self.tcx))
18811881
.map(|field| (field.ident.name, field.ty(self.tcx, expected_substs)))
1882-
.find(|(_, ty)| ty::TyS::same_type(ty, exp_found.found))
1882+
.find(|(_, ty)| same_type_modulo_infer(ty, exp_found.found))
18831883
{
18841884
if let ObligationCauseCode::Pattern { span: Some(span), .. } = cause.code {
18851885
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
@@ -1944,7 +1944,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
19441944
| (_, ty::Infer(_))
19451945
| (ty::Param(_), _)
19461946
| (ty::Infer(_), _) => {}
1947-
_ if ty::TyS::same_type(exp_ty, found_ty) => {}
1947+
_ if same_type_modulo_infer(exp_ty, found_ty) => {}
19481948
_ => show_suggestion = false,
19491949
};
19501950
}

src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ LL | [_, 99.., _] => {},
88
|
99
= note: expected struct `std::ops::Range<{integer}>`
1010
found type `{integer}`
11+
help: you might have meant to use field `start` whose type is `{integer}`
12+
|
13+
LL | match [5..4, 99..105, 43..44].start {
14+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1115

1216
error: aborting due to previous error
1317

src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ LL | [_, 99..] => {},
1414
|
1515
= note: expected struct `std::ops::Range<{integer}>`
1616
found type `{integer}`
17+
help: you might have meant to use field `start` whose type is `{integer}`
18+
|
19+
LL | match [5..4, 99..105, 43..44].start {
20+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1721

1822
error: aborting due to 2 previous errors
1923

src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.stderr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ LL | [..9, 99..100, _] => {},
88
|
99
= note: expected struct `std::ops::Range<{integer}>`
1010
found type `{integer}`
11+
help: you might have meant to use field `start` whose type is `{integer}`
12+
|
13+
LL | match [5..4, 99..105, 43..44].start {
14+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1115

1216
error[E0308]: mismatched types
1317
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:15
@@ -21,6 +25,10 @@ LL | [..9, 99..100, _] => {},
2125
|
2226
= note: expected struct `std::ops::Range<{integer}>`
2327
found type `{integer}`
28+
help: you might have meant to use field `start` whose type is `{integer}`
29+
|
30+
LL | match [5..4, 99..105, 43..44].start {
31+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2432

2533
error[E0308]: mismatched types
2634
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:19
@@ -34,6 +42,10 @@ LL | [..9, 99..100, _] => {},
3442
|
3543
= note: expected struct `std::ops::Range<{integer}>`
3644
found type `{integer}`
45+
help: you might have meant to use field `start` whose type is `{integer}`
46+
|
47+
LL | match [5..4, 99..105, 43..44].start {
48+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3749

3850
error: aborting due to 3 previous errors
3951

src/test/ui/issues/issue-5358-1.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ LL | Either::Right(_) => {}
88
|
99
= note: expected struct `S`
1010
found enum `Either<_, _>`
11+
help: you might have meant to use field `0` whose type is `Either<usize, usize>`
12+
|
13+
LL | match S(Either::Left(5)).0 {
14+
| ~~~~~~~~~~~~~~~~~~~~
1115

1216
error: aborting due to previous error
1317

0 commit comments

Comments
 (0)