mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 09:44:08 +00:00
Make should_treat_range_exhaustively a method
This commit is contained in:
parent
d1642f1eb5
commit
0192124202
@ -1282,11 +1282,10 @@ impl<'tcx> IntRange<'tcx> {
|
||||
(*self.range.start(), *self.range.end())
|
||||
}
|
||||
|
||||
fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
fn treat_exhaustively(&self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
// Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching`
|
||||
// feature is enabled.
|
||||
IntRange::is_integral(ty)
|
||||
&& (!ty.is_ptr_sized_integral() || tcx.features().precise_pointer_size_matching)
|
||||
!self.ty.is_ptr_sized_integral() || tcx.features().precise_pointer_size_matching
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -1414,7 +1413,7 @@ impl<'tcx> IntRange<'tcx> {
|
||||
let ty = self.ty;
|
||||
let (lo, hi) = self.boundaries();
|
||||
let (other_lo, other_hi) = other.boundaries();
|
||||
if Self::should_treat_range_exhaustively(tcx, ty) {
|
||||
if self.treat_exhaustively(tcx) {
|
||||
if lo <= other_hi && other_lo <= hi {
|
||||
let span = other.span;
|
||||
Some(IntRange { range: max(lo, other_lo)..=min(hi, other_hi), ty, span })
|
||||
@ -1881,7 +1880,7 @@ fn split_grouped_constructors<'p, 'tcx>(
|
||||
|
||||
for ctor in ctors.into_iter() {
|
||||
match ctor {
|
||||
IntRange(ctor_range) if IntRange::should_treat_range_exhaustively(tcx, ty) => {
|
||||
IntRange(ctor_range) if ctor_range.treat_exhaustively(tcx) => {
|
||||
// Fast-track if the range is trivial. In particular, don't do the overlapping
|
||||
// ranges check.
|
||||
if ctor_range.is_singleton() {
|
||||
|
Loading…
Reference in New Issue
Block a user