Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Dec 14, 2023
1 parent 44cd4d1 commit ce45b48
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_pattern_analysis/src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ pub struct IntRange {

impl IntRange {
/// Best effort; will not know that e.g. `255u8..` is a singleton.
#[cfg_attr(not(feature = "rustc"), allow(dead_code))]
pub(crate) fn is_singleton(&self) -> bool {
pub fn is_singleton(&self) -> bool {
// Since `lo` and `hi` can't be the same `Infinity` and `plus_one` never changes from finite
// to infinite, this correctly only detects ranges that contain exacly one `Finite(x)`.
self.lo.plus_one() == self.hi
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_pattern_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,8 @@ pub struct MatchArm<'p, Cx: MatchCx> {

impl<'p, Cx: MatchCx> Copy for MatchArm<'p, Cx> {}

#[cfg(not(feature = "rustc"))]
pub trait Captures<'a> {}
#[cfg(not(feature = "rustc"))]
impl<'a, T: ?Sized> Captures<'a> for T {}
#[cfg(feature = "rustc")]
pub use rustc_data_structures::captures::Captures;

/// The entrypoint for this crate. Computes whether a match is exhaustive and which of its arms are
/// useful, and runs some lints.
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_pattern_analysis/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,11 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> {
/// This returns one column per field of the constructor. They usually all have the same length
/// (the number of patterns in `self` that matched `ctor`), except that we expand or-patterns
/// which may change the lengths.
fn specialize<'b>(
fn specialize(
&self,
pcx: &'b PatCtxt<'_, 'p, 'tcx>,
pcx: &PatCtxt<'a, 'p, 'tcx>,
ctor: &Constructor<'p, 'tcx>,
) -> Vec<PatternColumn<'b, 'p, 'tcx>>
where
'a: 'b,
{
) -> Vec<PatternColumn<'a, 'p, 'tcx>> {
let arity = ctor.arity(pcx);
if arity == 0 {
return Vec::new();
Expand Down

0 comments on commit ce45b48

Please sign in to comment.