diff options
| author | bors <bors@rust-lang.org> | 2024-01-31 15:01:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-31 15:01:22 +0000 |
| commit | 11f32b73e0dc9287e305b5b9980d24aecdc8c17f (patch) | |
| tree | f07778f3d4e79d2973013519118772697cd03e3b /compiler/rustc_pattern_analysis/src/lib.rs | |
| parent | cdaa12e3dff109f72a5a8a0a67ea225052122a79 (diff) | |
| parent | 4eaf4c261511295483757df8f01f28e0d19349ca (diff) | |
| download | rust-11f32b73e0dc9287e305b5b9980d24aecdc8c17f.tar.gz rust-11f32b73e0dc9287e305b5b9980d24aecdc8c17f.zip | |
Auto merge of #120524 - Nadrieril:rollup-67952ib, r=Nadrieril
Rollup of 9 pull requests Successful merges: - #120207 (check `RUST_BOOTSTRAP_CONFIG` in `profile_user_dist` test) - #120321 (pattern_analysis: cleanup the contexts) - #120355 (document `FromIterator for Vec` allocation behaviors) - #120430 (std: thread_local::register_dtor fix proposal for FreeBSD.) - #120469 (Provide more context on derived obligation error primary label) - #120472 (Make duplicate lang items fatal) - #120490 (Don't hash lints differently to non-lints.) - #120495 (Remove the `abi_amdgpu_kernel` feature) - #120501 (rustdoc: Correctly handle attribute merge if this is a glob reexport) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/lib.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/lib.rs | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index a53d7a0d809..3d0eb117d17 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -6,6 +6,7 @@ pub mod errors; #[cfg(feature = "rustc")] pub(crate) mod lints; pub mod pat; +pub mod pat_column; #[cfg(feature = "rustc")] pub mod rustc; pub mod usefulness; @@ -67,8 +68,9 @@ use rustc_span::ErrorGuaranteed; use crate::constructor::{Constructor, ConstructorSet, IntRange}; #[cfg(feature = "rustc")] -use crate::lints::{lint_nonexhaustive_missing_variants, PatternColumn}; +use crate::lints::lint_nonexhaustive_missing_variants; use crate::pat::DeconstructedPat; +use crate::pat_column::PatternColumn; #[cfg(feature = "rustc")] use crate::rustc::RustcMatchCheckCtxt; #[cfg(feature = "rustc")] @@ -135,20 +137,6 @@ pub trait TypeCx: Sized + fmt::Debug { } } -/// Context that provides information global to a match. -pub struct MatchCtxt<'a, Cx: TypeCx> { - /// The context for type information. - pub tycx: &'a Cx, -} - -impl<'a, Cx: TypeCx> Clone for MatchCtxt<'a, Cx> { - fn clone(&self) -> Self { - Self { tycx: self.tycx } - } -} - -impl<'a, Cx: TypeCx> Copy for MatchCtxt<'a, Cx> {} - /// The arm of a match expression. #[derive(Debug)] pub struct MatchArm<'p, Cx: TypeCx> { @@ -175,15 +163,13 @@ pub fn analyze_match<'p, 'tcx>( ) -> Result<rustc::UsefulnessReport<'p, 'tcx>, ErrorGuaranteed> { let scrut_ty = tycx.reveal_opaque_ty(scrut_ty); let scrut_validity = ValidityConstraint::from_bool(tycx.known_valid_scrutinee); - let cx = MatchCtxt { tycx }; - - let report = compute_match_usefulness(cx, arms, scrut_ty, scrut_validity)?; + let report = compute_match_usefulness(tycx, arms, scrut_ty, scrut_validity)?; // Run the non_exhaustive_omitted_patterns lint. Only run on refutable patterns to avoid hitting // `if let`s. Only run if the match is exhaustive otherwise the error is redundant. if tycx.refutable && report.non_exhaustiveness_witnesses.is_empty() { let pat_column = PatternColumn::new(arms); - lint_nonexhaustive_missing_variants(cx, arms, &pat_column, scrut_ty)?; + lint_nonexhaustive_missing_variants(tycx, arms, &pat_column, scrut_ty)?; } Ok(report) |
