pub mod constructor;
pub mod cx;
pub mod errors;
pub(crate) mod lints;
pub mod pat;
pub mod usefulness;
#[macro_use]
extern crate tracing;
#[macro_use]
extern crate rustc_middle;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
use lints::PatternColumn;
use rustc_hir::HirId;
use rustc_middle::ty::Ty;
use usefulness::{compute_match_usefulness, UsefulnessReport};
use crate::cx::MatchCheckCtxt;
use crate::lints::{lint_nonexhaustive_missing_variants, lint_overlapping_range_endpoints};
use crate::pat::DeconstructedPat;
#[derive(Clone, Copy, Debug)]
pub struct MatchArm<'p, 'tcx> {
pub pat: &'p DeconstructedPat<'p, 'tcx>,
pub hir_id: HirId,
pub has_guard: bool,
}
pub fn analyze_match<'p, 'tcx>(
cx: &MatchCheckCtxt<'p, 'tcx>,
arms: &[MatchArm<'p, 'tcx>],
scrut_ty: Ty<'tcx>,
) -> UsefulnessReport<'p, 'tcx> {
let pat_column = PatternColumn::new(arms);
let report = compute_match_usefulness(cx, arms, scrut_ty);
lint_overlapping_range_endpoints(cx, &pat_column);
if cx.refutable && report.non_exhaustiveness_witnesses.is_empty() {
lint_nonexhaustive_missing_variants(cx, arms, &pat_column, scrut_ty)
}
report
}