Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4c01025
std: thread_local::register_dtor fix proposal for FreeBSD.
devnexen Jan 27, 2024
ad1e629
Make duplicate lang items fatal
Noratrieb Jan 29, 2024
a360ecd
Delete now-useless test
Noratrieb Jan 29, 2024
1f89e90
Add test for duplicate lang items
Noratrieb Jan 29, 2024
f6b21e9
Remove the `abi_amdgpu_kernel` feature
clubby789 Jan 30, 2024
0b2579a
Make `PatternColumn` generic in `Cx`
Nadrieril Jan 24, 2024
cb0e8c5
Limit the use of `PlaceCtxt`
Nadrieril Jan 24, 2024
83e88c6
Repurpose `MatchCtxt` for usefulness only
Nadrieril Jan 24, 2024
6ef8362
Make `PatternColumn` part of the public API
Nadrieril Jan 24, 2024
5903142
Separate `PlaceCtxt` from `UsefulnessCtxt`
Nadrieril Jan 24, 2024
dfbbdda
check `RUST_BOOTSTRAP_CONFIG` in `profile_user_dist` test
onur-ozkan Jan 21, 2024
75f670d
rustdoc: Correctly handle attribute merge if this is a glob reexport
GuillaumeGomez Jan 30, 2024
024364a
Add regression test for #120487
GuillaumeGomez Jan 30, 2024
4225a1e
Don't hash lints differently to non-lints.
nnethercote Jan 30, 2024
6efddac
Provide more context on derived obligation error primary label
estebank Jan 29, 2024
c780fe6
document `FromIterator for Vec` allocation behaviors
the8472 Jan 25, 2024
39dc315
Apply suggestions from code review
the8472 Jan 26, 2024
bcb709b
Rollup merge of #120207 - onur-ozkan:120202-fix, r=clubby789
Nadrieril Jan 31, 2024
0eaa32f
Rollup merge of #120321 - Nadrieril:cleanup-cx, r=compiler-errors
Nadrieril Jan 31, 2024
03daaa6
Rollup merge of #120355 - the8472:doc-vec-fromiter, r=cuviper
Nadrieril Jan 31, 2024
a7d5382
Rollup merge of #120430 - devnexen:fix_tls_dtor_fbsd, r=cuviper
Nadrieril Jan 31, 2024
0313eb2
Rollup merge of #120469 - estebank:issue-40120, r=TaKO8Ki
Nadrieril Jan 31, 2024
032596e
Rollup merge of #120472 - Nilstrieb:die, r=compiler-errors
Nadrieril Jan 31, 2024
be4f8e2
Rollup merge of #120490 - nnethercote:Diagnostic-hashing, r=estebank
Nadrieril Jan 31, 2024
573e7f1
Rollup merge of #120495 - clubby789:remove-amdgpu-kernel, r=oli-obk
Nadrieril Jan 31, 2024
4eaf4c2
Rollup merge of #120501 - GuillaumeGomez:glob-reexport-attr-merge-bug…
Nadrieril Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make PatternColumn generic in Cx
  • Loading branch information
Nadrieril committed Jan 30, 2024
commit 0b2579a1b617e83da98008bac9b93c36c43a8f4b
43 changes: 20 additions & 23 deletions compiler/rustc_pattern_analysis/src/lints.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
use rustc_span::ErrorGuaranteed;

use crate::constructor::{Constructor, SplitConstructorSet};
use crate::errors::{NonExhaustiveOmittedPattern, NonExhaustiveOmittedPatternLintOnArm, Uncovered};
use crate::pat::PatOrWild;
use crate::rustc::{
Constructor, DeconstructedPat, MatchArm, MatchCtxt, PlaceCtxt, RevealedTy, RustcMatchCheckCtxt,
SplitConstructorSet, WitnessPat,
};
use crate::pat::{DeconstructedPat, PatOrWild};
use crate::rustc::{MatchCtxt, RevealedTy, RustcMatchCheckCtxt, WitnessPat};
use crate::usefulness::PlaceCtxt;
use crate::{MatchArm, TypeCx};

/// A column of patterns in the matrix, where a column is the intuitive notion of "subpatterns that
/// inspect the same subvalue/place".
Expand All @@ -19,12 +19,12 @@ use crate::rustc::{
///
/// This is not used in the usefulness algorithm; only in lints.
#[derive(Debug)]
pub(crate) struct PatternColumn<'p, 'tcx> {
patterns: Vec<&'p DeconstructedPat<'p, 'tcx>>,
pub(crate) struct PatternColumn<'p, Cx: TypeCx> {
patterns: Vec<&'p DeconstructedPat<'p, Cx>>,
}

impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
pub(crate) fn new(arms: &[MatchArm<'p, 'tcx>]) -> Self {
impl<'p, Cx: TypeCx> PatternColumn<'p, Cx> {
pub(crate) fn new(arms: &[MatchArm<'p, Cx>]) -> Self {
let patterns = Vec::with_capacity(arms.len());
let mut column = PatternColumn { patterns };
for arm in arms {
Expand All @@ -34,7 +34,7 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
}
/// Pushes a pattern onto the column, expanding any or-patterns into its subpatterns.
/// Internal method, prefer [`PatternColumn::new`].
fn expand_and_push(&mut self, pat: PatOrWild<'p, RustcMatchCheckCtxt<'p, 'tcx>>) {
fn expand_and_push(&mut self, pat: PatOrWild<'p, Cx>) {
// We flatten or-patterns and skip algorithm-generated wildcards.
if pat.is_or_pat() {
self.patterns.extend(
Expand All @@ -45,15 +45,12 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
}
}

fn head_ty(&self) -> Option<RevealedTy<'tcx>> {
self.patterns.first().map(|pat| *pat.ty())
fn head_ty(&self) -> Option<&Cx::Ty> {
self.patterns.first().map(|pat| pat.ty())
}

/// Do constructor splitting on the constructors of the column.
fn analyze_ctors(
&self,
pcx: &PlaceCtxt<'_, 'p, 'tcx>,
) -> Result<SplitConstructorSet<'p, 'tcx>, ErrorGuaranteed> {
fn analyze_ctors(&self, pcx: &PlaceCtxt<'_, Cx>) -> Result<SplitConstructorSet<Cx>, Cx::Error> {
let column_ctors = self.patterns.iter().map(|p| p.ctor());
let ctors_for_ty = &pcx.ctors_for_ty()?;
Ok(ctors_for_ty.split(column_ctors))
Expand All @@ -66,9 +63,9 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
/// which may change the lengths.
fn specialize(
&self,
pcx: &PlaceCtxt<'_, 'p, 'tcx>,
ctor: &Constructor<'p, 'tcx>,
) -> Vec<PatternColumn<'p, 'tcx>> {
pcx: &PlaceCtxt<'_, Cx>,
ctor: &Constructor<Cx>,
) -> Vec<PatternColumn<'p, Cx>> {
let arity = ctor.arity(pcx);
if arity == 0 {
return Vec::new();
Expand Down Expand Up @@ -96,9 +93,9 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
#[instrument(level = "debug", skip(cx), ret)]
fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
cx: MatchCtxt<'a, 'p, 'tcx>,
column: &PatternColumn<'p, 'tcx>,
column: &PatternColumn<'p, RustcMatchCheckCtxt<'p, 'tcx>>,
) -> Result<Vec<WitnessPat<'p, 'tcx>>, ErrorGuaranteed> {
let Some(ty) = column.head_ty() else {
let Some(&ty) = column.head_ty() else {
return Ok(Vec::new());
};
let pcx = &PlaceCtxt::new_dummy(cx, &ty);
Expand Down Expand Up @@ -143,8 +140,8 @@ fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>(

pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
cx: MatchCtxt<'a, 'p, 'tcx>,
arms: &[MatchArm<'p, 'tcx>],
pat_column: &PatternColumn<'p, 'tcx>,
arms: &[MatchArm<'p, RustcMatchCheckCtxt<'p, 'tcx>>],
pat_column: &PatternColumn<'p, RustcMatchCheckCtxt<'p, 'tcx>>,
scrut_ty: RevealedTy<'tcx>,
) -> Result<(), ErrorGuaranteed> {
let rcx: &RustcMatchCheckCtxt<'_, '_> = cx.tycx;
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_pattern_analysis/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ pub type DeconstructedPat<'p, 'tcx> =
crate::pat::DeconstructedPat<'p, RustcMatchCheckCtxt<'p, 'tcx>>;
pub type MatchArm<'p, 'tcx> = crate::MatchArm<'p, RustcMatchCheckCtxt<'p, 'tcx>>;
pub type MatchCtxt<'a, 'p, 'tcx> = crate::MatchCtxt<'a, RustcMatchCheckCtxt<'p, 'tcx>>;
pub(crate) type PlaceCtxt<'a, 'p, 'tcx> =
crate::usefulness::PlaceCtxt<'a, RustcMatchCheckCtxt<'p, 'tcx>>;
pub(crate) type SplitConstructorSet<'p, 'tcx> =
crate::constructor::SplitConstructorSet<RustcMatchCheckCtxt<'p, 'tcx>>;
pub type Usefulness<'p, 'tcx> = crate::usefulness::Usefulness<'p, RustcMatchCheckCtxt<'p, 'tcx>>;
pub type UsefulnessReport<'p, 'tcx> =
crate::usefulness::UsefulnessReport<'p, RustcMatchCheckCtxt<'p, 'tcx>>;
Expand Down