mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
pattern_analysis
doesn't need an arena anymore
This commit is contained in:
parent
3356ebd255
commit
b04e0df1ce
2 changed files with 8 additions and 14 deletions
|
@ -169,9 +169,9 @@ impl ExprValidator {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pattern_arena = Arena::new();
|
let cx = MatchCheckCtx::new(self.owner.module(db.upcast()), self.owner, db);
|
||||||
let cx = MatchCheckCtx::new(self.owner.module(db.upcast()), self.owner, db, &pattern_arena);
|
|
||||||
|
|
||||||
|
let pattern_arena = Arena::new();
|
||||||
let mut m_arms = Vec::with_capacity(arms.len());
|
let mut m_arms = Vec::with_capacity(arms.len());
|
||||||
let mut has_lowering_errors = false;
|
let mut has_lowering_errors = false;
|
||||||
for arm in arms {
|
for arm in arms {
|
||||||
|
@ -196,8 +196,9 @@ impl ExprValidator {
|
||||||
// If we had a NotUsefulMatchArm diagnostic, we could
|
// If we had a NotUsefulMatchArm diagnostic, we could
|
||||||
// check the usefulness of each pattern as we added it
|
// check the usefulness of each pattern as we added it
|
||||||
// to the matrix here.
|
// to the matrix here.
|
||||||
|
let pat = self.lower_pattern(&cx, arm.pat, db, &body, &mut has_lowering_errors);
|
||||||
let m_arm = pat_analysis::MatchArm {
|
let m_arm = pat_analysis::MatchArm {
|
||||||
pat: self.lower_pattern(&cx, arm.pat, db, &body, &mut has_lowering_errors),
|
pat: pattern_arena.alloc(pat),
|
||||||
has_guard: arm.guard.is_some(),
|
has_guard: arm.guard.is_some(),
|
||||||
arm_data: (),
|
arm_data: (),
|
||||||
};
|
};
|
||||||
|
@ -245,10 +246,10 @@ impl ExprValidator {
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
body: &Body,
|
body: &Body,
|
||||||
have_errors: &mut bool,
|
have_errors: &mut bool,
|
||||||
) -> &'p DeconstructedPat<'p> {
|
) -> DeconstructedPat<'p> {
|
||||||
let mut patcx = match_check::PatCtxt::new(db, &self.infer, body);
|
let mut patcx = match_check::PatCtxt::new(db, &self.infer, body);
|
||||||
let pattern = patcx.lower_pattern(pat);
|
let pattern = patcx.lower_pattern(pat);
|
||||||
let pattern = cx.pattern_arena.alloc(cx.lower_pat(&pattern));
|
let pattern = cx.lower_pat(&pattern);
|
||||||
if !patcx.errors.is_empty() {
|
if !patcx.errors.is_empty() {
|
||||||
*have_errors = true;
|
*have_errors = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ use rustc_pattern_analysis::{
|
||||||
};
|
};
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use stdx::never;
|
use stdx::never;
|
||||||
use typed_arena::Arena;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
|
@ -40,7 +39,6 @@ pub(crate) struct MatchCheckCtx<'p> {
|
||||||
module: ModuleId,
|
module: ModuleId,
|
||||||
body: DefWithBodyId,
|
body: DefWithBodyId,
|
||||||
pub(crate) db: &'p dyn HirDatabase,
|
pub(crate) db: &'p dyn HirDatabase,
|
||||||
pub(crate) pattern_arena: &'p Arena<DeconstructedPat<'p>>,
|
|
||||||
exhaustive_patterns: bool,
|
exhaustive_patterns: bool,
|
||||||
min_exhaustive_patterns: bool,
|
min_exhaustive_patterns: bool,
|
||||||
}
|
}
|
||||||
|
@ -52,17 +50,12 @@ pub(crate) struct PatData<'p> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'p> MatchCheckCtx<'p> {
|
impl<'p> MatchCheckCtx<'p> {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(module: ModuleId, body: DefWithBodyId, db: &'p dyn HirDatabase) -> Self {
|
||||||
module: ModuleId,
|
|
||||||
body: DefWithBodyId,
|
|
||||||
db: &'p dyn HirDatabase,
|
|
||||||
pattern_arena: &'p Arena<DeconstructedPat<'p>>,
|
|
||||||
) -> Self {
|
|
||||||
let def_map = db.crate_def_map(module.krate());
|
let def_map = db.crate_def_map(module.krate());
|
||||||
let exhaustive_patterns = def_map.is_unstable_feature_enabled("exhaustive_patterns");
|
let exhaustive_patterns = def_map.is_unstable_feature_enabled("exhaustive_patterns");
|
||||||
let min_exhaustive_patterns =
|
let min_exhaustive_patterns =
|
||||||
def_map.is_unstable_feature_enabled("min_exhaustive_patterns");
|
def_map.is_unstable_feature_enabled("min_exhaustive_patterns");
|
||||||
Self { module, body, db, pattern_arena, exhaustive_patterns, min_exhaustive_patterns }
|
Self { module, body, db, exhaustive_patterns, min_exhaustive_patterns }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_uninhabited(&self, ty: &Ty) -> bool {
|
fn is_uninhabited(&self, ty: &Ty) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue