1
Fork 0

Prefer a two value enum over bool

This commit is contained in:
Oli Scherer 2025-02-12 10:37:49 +00:00
parent 30f168ef81
commit 4f2b108816
9 changed files with 19 additions and 23 deletions

View file

@ -1,6 +1,7 @@
use std::fmt;
use rustc_data_structures::intern::Interned;
use rustc_hir::RangeEnd;
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use crate::ty;
@ -30,10 +31,7 @@ impl<'tcx> fmt::Debug for PatternKind<'tcx> {
if let Some(start) = start {
write!(f, "{start}")?;
}
write!(f, "..")?;
if include_end {
write!(f, "=")?;
}
write!(f, "{include_end}")?;
if let Some(end) = end {
write!(f, "{end}")?;
}
@ -46,5 +44,5 @@ impl<'tcx> fmt::Debug for PatternKind<'tcx> {
#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(HashStable, TyEncodable, TyDecodable, TypeVisitable, TypeFoldable)]
pub enum PatternKind<'tcx> {
Range { start: Option<ty::Const<'tcx>>, end: Option<ty::Const<'tcx>>, include_end: bool },
Range { start: Option<ty::Const<'tcx>>, end: Option<ty::Const<'tcx>>, include_end: RangeEnd },
}

View file

@ -284,6 +284,7 @@ TrivialTypeTraversalImpls! {
rustc_hir::def_id::LocalDefId,
rustc_hir::HirId,
rustc_hir::MatchSource,
rustc_hir::RangeEnd,
rustc_span::Ident,
rustc_span::Span,
rustc_span::Symbol,