Skip to content

Commit 0534655

Browse files
committedApr 6, 2023
Auto merge of #108504 - cjgillot:thir-pattern, r=compiler-errors,Nilstrieb
Check pattern refutability on THIR The current `check_match` query is based on HIR, but partially re-lowers HIR into THIR. This PR proposed to use the results of the `thir_body` query to check matches, instead of re-building THIR. Most of the diagnostic changes are spans getting shorter, or commas/semicolons not getting removed. This PR degrades the diagnostic for confusing constants in patterns (`let A = foo()` where `A` resolves to a `const A` somewhere): it does not point ot the definition of `const A` any more.
2 parents ce3cb03 + 1dde34b commit 0534655

File tree

106 files changed

+1041
-1482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1041
-1482
lines changed
 

‎compiler/rustc_hir/src/pat_util.rs

-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::def::{CtorOf, DefKind, Res};
22
use crate::def_id::DefId;
33
use crate::hir::{self, BindingAnnotation, ByRef, HirId, PatKind};
44
use rustc_data_structures::fx::FxHashSet;
5-
use rustc_span::hygiene::DesugaringKind;
65
use rustc_span::symbol::Ident;
76
use rustc_span::Span;
87

@@ -136,14 +135,4 @@ impl hir::Pat<'_> {
136135
});
137136
result
138137
}
139-
140-
/// If the pattern is `Some(<pat>)` from a desugared for loop, returns the inner pattern
141-
pub fn for_loop_some(&self) -> Option<&Self> {
142-
if self.span.desugaring_kind() == Some(DesugaringKind::ForLoop) {
143-
if let hir::PatKind::Struct(_, [pat_field], _) = self.kind {
144-
return Some(pat_field.pat);
145-
}
146-
}
147-
None
148-
}
149138
}

‎compiler/rustc_interface/src/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
765765
parallel!(
766766
{
767767
sess.time("match_checking", || {
768-
tcx.hir().par_body_owners(|def_id| tcx.ensure().check_match(def_id.to_def_id()))
768+
tcx.hir().par_body_owners(|def_id| tcx.ensure().check_match(def_id))
769769
});
770770
},
771771
{

0 commit comments

Comments
 (0)
Please sign in to comment.