diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index cdefc9effa1e9..7766db5f468b1 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -26,6 +26,7 @@ use rustc_middle::ty::{self, AdtDef, Const, Ty, UpvarSubsts, UserType}; use rustc_middle::ty::{ CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, }; +use rustc_middle::ty::{ConstInt, ScalarInt}; use rustc_span::{Span, Symbol, DUMMY_SP}; use rustc_target::abi::VariantIdx; use rustc_target::asm::InlineAsmRegOrRegClass; @@ -668,8 +669,9 @@ pub enum PatKind<'tcx> { #[derive(Copy, Clone, Debug, PartialEq, HashStable)] pub struct PatRange<'tcx> { - pub lo: &'tcx ty::Const<'tcx>, - pub hi: &'tcx ty::Const<'tcx>, + pub lo: ScalarInt, + pub hi: ScalarInt, + pub ty: Ty<'tcx>, pub end: RangeEnd, } @@ -788,10 +790,12 @@ impl<'tcx> fmt::Display for Pat<'tcx> { write!(f, "{}", subpattern) } PatKind::Constant { value } => write!(f, "{}", value), - PatKind::Range(PatRange { lo, hi, end }) => { - write!(f, "{}", lo)?; + PatKind::Range(PatRange { lo, hi, end, ty }) => { + let lo = ConstInt::new(lo, ty.is_signed(), ty.is_ptr_sized_integral()); + let hi = ConstInt::new(hi, ty.is_signed(), ty.is_ptr_sized_integral()); + write!(f, "{:?}", lo)?; write!(f, "{}", end)?; - write!(f, "{}", hi) + write!(f, "{:?}", hi) } PatKind::Slice { ref prefix, ref slice, ref suffix } | PatKind::Array { ref prefix, ref slice, ref suffix } => { diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index 13cfc3695cc9f..cde6d2c30182d 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -196,8 +196,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Err(match_pair) } - PatKind::Range(PatRange { lo, hi, end }) => { - let (range, bias) = match *lo.ty.kind() { + PatKind::Range(PatRange { lo, hi, end, ty }) => { + let (range, bias) = match *ty.kind() { ty::Char => { (Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32))), 0) } @@ -215,18 +215,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { _ => (None, 0), }; if let Some((min, max, sz)) = range { - if let (Some(lo), Some(hi)) = (lo.val.try_to_bits(sz), hi.val.try_to_bits(sz)) { - // We want to compare ranges numerically, but the order of the bitwise - // representation of signed integers does not match their numeric order. - // Thus, to correct the ordering, we need to shift the range of signed - // integers to correct the comparison. This is achieved by XORing with a - // bias (see pattern/_match.rs for another pertinent example of this - // pattern). - let (lo, hi) = (lo ^ bias, hi ^ bias); - if lo <= min && (hi > max || hi == max && end == RangeEnd::Included) { - // Irrefutable pattern match. - return Ok(()); - } + let lo = lo.assert_bits(sz); + let hi = hi.assert_bits(sz); + // We want to compare ranges numerically, but the order of the bitwise + // representation of signed integers does not match their numeric order. + // Thus, to correct the ordering, we need to shift the range of signed + // integers to correct the comparison. This is achieved by XORing with a + // bias (see pattern/_match.rs for another pertinent example of this + // pattern). + let (lo, hi) = (lo ^ bias, hi ^ bias); + if lo <= min && (hi > max || hi == max && end == RangeEnd::Included) { + // Irrefutable pattern match. + return Ok(()); } } Err(match_pair) diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index c87f42738c67f..2578562766af3 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -12,6 +12,7 @@ use crate::thir::pattern::compare_const_vals; use rustc_data_structures::fx::FxIndexMap; use rustc_hir::{LangItem, RangeEnd}; use rustc_index::bit_set::BitSet; +use rustc_middle::mir::interpret::ConstValue; use rustc_middle::mir::*; use rustc_middle::thir::*; use rustc_middle::ty::subst::{GenericArg, Subst}; @@ -58,8 +59,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }, PatKind::Range(range) => { - assert_eq!(range.lo.ty, match_pair.pattern.ty); - assert_eq!(range.hi.ty, match_pair.pattern.ty); + assert_eq!(range.ty, match_pair.pattern.ty); Test { span: match_pair.pattern.span, kind: TestKind::Range(range) } } @@ -271,11 +271,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - TestKind::Range(PatRange { ref lo, ref hi, ref end }) => { + TestKind::Range(PatRange { lo, hi, ref end, ty }) => { let lower_bound_success = self.cfg.start_new_block(); let target_blocks = make_target_blocks(self); // Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons. + let lo = ty::Const::from_value(self.tcx, ConstValue::Scalar(lo.into()), ty); + let hi = ty::Const::from_value(self.tcx, ConstValue::Scalar(hi.into()), ty); let lo = self.literal_operand(test.span, lo); let hi = self.literal_operand(test.span, hi); let val = Operand::Copy(place); @@ -640,9 +642,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let tcx = self.tcx; - let test_ty = test.lo.ty; - let lo = compare_const_vals(tcx, test.lo, pat.hi, self.param_env, test_ty)?; - let hi = compare_const_vals(tcx, test.hi, pat.lo, self.param_env, test_ty)?; + let test_ty = match_pair.pattern.ty; + let test_lo = + ty::Const::from_value(tcx, ConstValue::Scalar(test.lo.into()), test_ty); + let test_hi = + ty::Const::from_value(tcx, ConstValue::Scalar(test.hi.into()), test_ty); + let pat_lo = + ty::Const::from_value(tcx, ConstValue::Scalar(test.lo.into()), test_ty); + let pat_hi = + ty::Const::from_value(tcx, ConstValue::Scalar(test.hi.into()), test_ty); + let lo = compare_const_vals(tcx, test_lo, pat_hi, self.param_env, test_ty)?; + let hi = compare_const_vals(tcx, test_hi, pat_lo, self.param_env, test_ty)?; match (test.end, pat.end, lo, hi) { // pat < test @@ -769,8 +779,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let tcx = self.tcx; - let a = compare_const_vals(tcx, range.lo, value, self.param_env, range.lo.ty)?; - let b = compare_const_vals(tcx, value, range.hi, self.param_env, range.lo.ty)?; + let lo = ty::Const::from_value(tcx, ConstValue::Scalar(range.lo.into()), value.ty); + let hi = ty::Const::from_value(tcx, ConstValue::Scalar(range.hi.into()), value.ty); + let a = compare_const_vals(tcx, lo, value, self.param_env, value.ty)?; + let b = compare_const_vals(tcx, value, hi, self.param_env, value.ty)?; match (b, range.end) { (Less, _) | (Equal, RangeEnd::Included) if a != Greater => Some(true), diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index 925c555dbbea1..a9492f02fe7f4 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -52,10 +52,11 @@ use rustc_data_structures::captures::Captures; use rustc_index::vec::Idx; use rustc_hir::{HirId, RangeEnd}; +use rustc_middle::mir::interpret::ConstValue; use rustc_middle::mir::Field; use rustc_middle::thir::{FieldPat, Pat, PatKind, PatRange}; use rustc_middle::ty::layout::IntegerExt; -use rustc_middle::ty::{self, Const, Ty, TyCtxt}; +use rustc_middle::ty::{self, Const, ScalarInt, Ty, TyCtxt}; use rustc_session::lint; use rustc_span::{Span, DUMMY_SP}; use rustc_target::abi::{Integer, Size, VariantIdx}; @@ -202,14 +203,18 @@ impl IntRange { let bias = IntRange::signed_bias(tcx, ty); let (lo, hi) = (lo ^ bias, hi ^ bias); - let env = ty::ParamEnv::empty().and(ty); - let lo_const = ty::Const::from_bits(tcx, lo, env); - let hi_const = ty::Const::from_bits(tcx, hi, env); - let kind = if lo == hi { - PatKind::Constant { value: lo_const } + let ty = ty::ParamEnv::empty().and(ty); + PatKind::Constant { value: ty::Const::from_bits(tcx, lo, ty) } } else { - PatKind::Range(PatRange { lo: lo_const, hi: hi_const, end: RangeEnd::Included }) + let param_env_and_ty = ty::ParamEnv::empty().and(ty); + let size = tcx.layout_of(param_env_and_ty).unwrap().size; + PatKind::Range(PatRange { + lo: ScalarInt::from_uint(lo, size), + hi: ScalarInt::from_uint(hi, size), + end: RangeEnd::Included, + ty, + }) }; Pat { ty, span: DUMMY_SP, kind: Box::new(kind) } @@ -586,7 +591,7 @@ pub(super) enum Constructor<'tcx> { /// Ranges of integer literal values (`2`, `2..=5` or `2..5`). IntRange(IntRange), /// Ranges of floating-point literal values (`2.0..=5.2`). - FloatRange(&'tcx ty::Const<'tcx>, &'tcx ty::Const<'tcx>, RangeEnd), + FloatRange(ScalarInt, ScalarInt, RangeEnd), /// String literals. Strings are not quite the same as `&[u8]` so we treat them separately. Str(&'tcx ty::Const<'tcx>), /// Array and slice patterns. @@ -647,7 +652,11 @@ impl<'tcx> Constructor<'tcx> { IntRange(int_range) } else { match pat.ty.kind() { - ty::Float(_) => FloatRange(value, value, RangeEnd::Included), + ty::Float(_) => { + let value = + value.val.eval(cx.tcx, cx.param_env).try_to_scalar_int().unwrap(); + FloatRange(value, value, RangeEnd::Included) + } // In `expand_pattern`, we convert string literals to `&CONST` patterns with // `CONST` a pattern of type `str`. In truth this contains a constant of type // `&str`. @@ -659,13 +668,13 @@ impl<'tcx> Constructor<'tcx> { } } } - &PatKind::Range(PatRange { lo, hi, end }) => { - let ty = lo.ty; + &PatKind::Range(PatRange { lo, hi, end, ty }) => { + let size = cx.tcx.layout_of(cx.param_env.and(ty)).unwrap().size; if let Some(int_range) = IntRange::from_range( cx.tcx, - lo.eval_bits(cx.tcx, cx.param_env, lo.ty), - hi.eval_bits(cx.tcx, cx.param_env, hi.ty), - ty, + lo.assert_bits(size), + hi.assert_bits(size), + pat.ty, &end, ) { IntRange(int_range) @@ -759,6 +768,26 @@ impl<'tcx> Constructor<'tcx> { FloatRange(self_from, self_to, self_end), FloatRange(other_from, other_to, other_end), ) => { + let self_to = ty::Const::from_value( + pcx.cx.tcx, + ConstValue::Scalar((*self_to).into()), + pcx.ty, + ); + let other_to = ty::Const::from_value( + pcx.cx.tcx, + ConstValue::Scalar((*other_to).into()), + pcx.ty, + ); + let self_from = ty::Const::from_value( + pcx.cx.tcx, + ConstValue::Scalar((*self_from).into()), + pcx.ty, + ); + let other_from = ty::Const::from_value( + pcx.cx.tcx, + ConstValue::Scalar((*other_from).into()), + pcx.ty, + ); match ( compare_const_vals(pcx.cx.tcx, self_to, other_to, pcx.cx.param_env, pcx.ty), compare_const_vals(pcx.cx.tcx, self_from, other_from, pcx.cx.param_env, pcx.ty), @@ -1253,7 +1282,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> { } }, &Str(value) => PatKind::Constant { value }, - &FloatRange(lo, hi, end) => PatKind::Range(PatRange { lo, hi, end }), + &FloatRange(lo, hi, end) => PatKind::Range(PatRange { lo, hi, end, ty: pcx.ty }), IntRange(range) => return range.to_pat(pcx.cx.tcx, pcx.ty), NonExhaustive => PatKind::Wild, Wildcard => return Pat::wildcard_from_ty(pcx.ty), diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 3ea76fb99d531..081ff09f59e91 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -130,10 +130,23 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { assert_eq!(lo.ty, ty); assert_eq!(hi.ty, ty); let cmp = compare_const_vals(self.tcx, lo, hi, self.param_env, ty); + let lo_const = lo; + let lo = lo + .val + .eval(self.tcx, self.param_env) + .try_to_scalar_int() + .expect("range patterns must be integral"); + let hi = hi + .val + .eval(self.tcx, self.param_env) + .try_to_scalar_int() + .expect("range patterns must be integral"); match (end, cmp) { // `x..y` where `x < y`. // Non-empty because the range includes at least `x`. - (RangeEnd::Excluded, Some(Ordering::Less)) => PatKind::Range(PatRange { lo, hi, end }), + (RangeEnd::Excluded, Some(Ordering::Less)) => { + PatKind::Range(PatRange { lo, hi, end, ty }) + } // `x..y` where `x >= y`. The range is empty => error. (RangeEnd::Excluded, _) => { struct_span_err!( @@ -146,9 +159,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { PatKind::Wild } // `x..=y` where `x == y`. - (RangeEnd::Included, Some(Ordering::Equal)) => PatKind::Constant { value: lo }, + (RangeEnd::Included, Some(Ordering::Equal)) => PatKind::Constant { value: lo_const }, // `x..=y` where `x < y`. - (RangeEnd::Included, Some(Ordering::Less)) => PatKind::Range(PatRange { lo, hi, end }), + (RangeEnd::Included, Some(Ordering::Less)) => { + PatKind::Range(PatRange { lo, hi, end, ty }) + } // `x..=y` where `x > y` hence the range is empty => error. (RangeEnd::Included, _) => { let mut err = struct_span_err!( diff --git a/compiler/rustc_mir_build/src/thir/visit.rs b/compiler/rustc_mir_build/src/thir/visit.rs index f611bb6eb43e9..6f699b8c8d910 100644 --- a/compiler/rustc_mir_build/src/thir/visit.rs +++ b/compiler/rustc_mir_build/src/thir/visit.rs @@ -213,10 +213,7 @@ pub fn walk_pat<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, pat: &Pat<' } } Constant { value } => visitor.visit_const(value), - Range(range) => { - visitor.visit_const(range.lo); - visitor.visit_const(range.hi); - } + Range(PatRange { lo: _, hi: _, ty: _, end: _ }) => {} Slice { prefix, slice, suffix } | Array { prefix, slice, suffix } => { for subpattern in prefix { visitor.visit_pat(&subpattern); diff --git a/src/test/mir-opt/match_test.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/match_test.main.SimplifyCfg-initial.after.mir index 5bb910947ca25..e050b5ea0b4ee 100644 --- a/src/test/mir-opt/match_test.main.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/match_test.main.SimplifyCfg-initial.after.mir @@ -28,43 +28,43 @@ fn main() -> () { StorageLive(_3); // scope 2 at $DIR/match_test.rs:12:5: 17:6 FakeRead(ForMatchedPlace(None), _1); // scope 2 at $DIR/match_test.rs:12:11: 12:12 _6 = Le(const 0_i32, _1); // scope 2 at $DIR/match_test.rs:13:9: 13:14 - switchInt(move _6) -> [false: bb4, otherwise: bb1]; // scope 2 at $DIR/match_test.rs:13:9: 13:14 + switchInt(move _6) -> [false: bb3, otherwise: bb1]; // scope 2 at $DIR/match_test.rs:13:9: 13:14 } bb1: { _7 = Lt(_1, const 10_i32); // scope 2 at $DIR/match_test.rs:13:9: 13:14 - switchInt(move _7) -> [false: bb4, otherwise: bb2]; // scope 2 at $DIR/match_test.rs:13:9: 13:14 + switchInt(move _7) -> [false: bb3, otherwise: bb2]; // scope 2 at $DIR/match_test.rs:13:9: 13:14 } bb2: { - falseEdge -> [real: bb9, imaginary: bb6]; // scope 2 at $DIR/match_test.rs:13:9: 13:14 + falseEdge -> [real: bb9, imaginary: bb5]; // scope 2 at $DIR/match_test.rs:13:9: 13:14 } bb3: { - _3 = const 3_i32; // scope 2 at $DIR/match_test.rs:16:14: 16:15 - goto -> bb14; // scope 2 at $DIR/match_test.rs:12:5: 17:6 + _4 = Le(const 10_i32, _1); // scope 2 at $DIR/match_test.rs:14:9: 14:16 + switchInt(move _4) -> [false: bb6, otherwise: bb4]; // scope 2 at $DIR/match_test.rs:14:9: 14:16 } bb4: { - _4 = Le(const 10_i32, _1); // scope 2 at $DIR/match_test.rs:14:9: 14:16 - switchInt(move _4) -> [false: bb7, otherwise: bb5]; // scope 2 at $DIR/match_test.rs:14:9: 14:16 + _5 = Le(_1, const 20_i32); // scope 2 at $DIR/match_test.rs:14:9: 14:16 + switchInt(move _5) -> [false: bb6, otherwise: bb5]; // scope 2 at $DIR/match_test.rs:14:9: 14:16 } bb5: { - _5 = Le(_1, const 20_i32); // scope 2 at $DIR/match_test.rs:14:9: 14:16 - switchInt(move _5) -> [false: bb7, otherwise: bb6]; // scope 2 at $DIR/match_test.rs:14:9: 14:16 + falseEdge -> [real: bb12, imaginary: bb7]; // scope 2 at $DIR/match_test.rs:14:9: 14:16 } bb6: { - falseEdge -> [real: bb12, imaginary: bb8]; // scope 2 at $DIR/match_test.rs:14:9: 14:16 + switchInt(_1) -> [-1_i32: bb7, otherwise: bb8]; // scope 2 at $DIR/match_test.rs:15:9: 15:11 } bb7: { - switchInt(_1) -> [-1_i32: bb8, otherwise: bb3]; // scope 2 at $DIR/match_test.rs:15:9: 15:11 + falseEdge -> [real: bb13, imaginary: bb8]; // scope 2 at $DIR/match_test.rs:15:9: 15:11 } bb8: { - falseEdge -> [real: bb13, imaginary: bb3]; // scope 2 at $DIR/match_test.rs:15:9: 15:11 + _3 = const 3_i32; // scope 2 at $DIR/match_test.rs:16:14: 16:15 + goto -> bb14; // scope 2 at $DIR/match_test.rs:12:5: 17:6 } bb9: { @@ -83,7 +83,7 @@ fn main() -> () { bb11: { StorageDead(_9); // scope 2 at $DIR/match_test.rs:13:23: 13:24 - falseEdge -> [real: bb3, imaginary: bb6]; // scope 2 at $DIR/match_test.rs:13:18: 13:19 + falseEdge -> [real: bb3, imaginary: bb5]; // scope 2 at $DIR/match_test.rs:13:18: 13:19 } bb12: { diff --git a/src/test/ui/consts/const-match-check.eval1.stderr b/src/test/ui/consts/const-match-check.eval1.stderr index eb6b0774e152c..2194b3f1b0363 100644 --- a/src/test/ui/consts/const-match-check.eval1.stderr +++ b/src/test/ui/consts/const-match-check.eval1.stderr @@ -1,8 +1,8 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding: `i32::MIN..=-1` and `1..=i32::MAX` not covered --> $DIR/const-match-check.rs:25:15 | LL | A = { let 0 = 0; 0 }, - | ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered + | ^ patterns `i32::MIN..=-1` and `1..=i32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html diff --git a/src/test/ui/consts/const-match-check.eval2.stderr b/src/test/ui/consts/const-match-check.eval2.stderr index 756426d84a479..e4844feec28d3 100644 --- a/src/test/ui/consts/const-match-check.eval2.stderr +++ b/src/test/ui/consts/const-match-check.eval2.stderr @@ -1,8 +1,8 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding: `i32::MIN..=-1` and `1..=i32::MAX` not covered --> $DIR/const-match-check.rs:31:24 | LL | let x: [i32; { let 0 = 0; 0 }] = []; - | ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered + | ^ patterns `i32::MIN..=-1` and `1..=i32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html diff --git a/src/test/ui/consts/const-match-check.matchck.stderr b/src/test/ui/consts/const-match-check.matchck.stderr index 84600bb1b8aad..9e5cc99bcf9d6 100644 --- a/src/test/ui/consts/const-match-check.matchck.stderr +++ b/src/test/ui/consts/const-match-check.matchck.stderr @@ -1,8 +1,8 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding: `i32::MIN..=-1` and `1..=i32::MAX` not covered --> $DIR/const-match-check.rs:4:22 | LL | const X: i32 = { let 0 = 0; 0 }; - | ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered + | ^ patterns `i32::MIN..=-1` and `1..=i32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html @@ -12,11 +12,11 @@ help: you might want to use `if let` to ignore the variant that isn't matched LL | const X: i32 = { if let 0 = 0 { /* */ } 0 }; | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding: `i32::MIN..=-1` and `1..=i32::MAX` not covered --> $DIR/const-match-check.rs:8:23 | LL | static Y: i32 = { let 0 = 0; 0 }; - | ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered + | ^ patterns `i32::MIN..=-1` and `1..=i32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html @@ -26,11 +26,11 @@ help: you might want to use `if let` to ignore the variant that isn't matched LL | static Y: i32 = { if let 0 = 0 { /* */ } 0 }; | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding: `i32::MIN..=-1` and `1..=i32::MAX` not covered --> $DIR/const-match-check.rs:13:26 | LL | const X: i32 = { let 0 = 0; 0 }; - | ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered + | ^ patterns `i32::MIN..=-1` and `1..=i32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html @@ -40,11 +40,11 @@ help: you might want to use `if let` to ignore the variant that isn't matched LL | const X: i32 = { if let 0 = 0 { /* */ } 0 }; | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding: `i32::MIN..=-1` and `1..=i32::MAX` not covered --> $DIR/const-match-check.rs:19:26 | LL | const X: i32 = { let 0 = 0; 0 }; - | ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered + | ^ patterns `i32::MIN..=-1` and `1..=i32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html diff --git a/src/test/ui/consts/const-pattern-irrefutable.rs b/src/test/ui/consts/const-pattern-irrefutable.rs index 2105c12a1680a..593ebfbec07c2 100644 --- a/src/test/ui/consts/const-pattern-irrefutable.rs +++ b/src/test/ui/consts/const-pattern-irrefutable.rs @@ -9,8 +9,8 @@ use foo::d; const a: u8 = 2; fn main() { - let a = 4; //~ ERROR refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX - let c = 4; //~ ERROR refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX - let d = 4; //~ ERROR refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX + let a = 4; //~ ERROR refutable pattern in local binding: `0..=1` and `3..=u8::MAX + let c = 4; //~ ERROR refutable pattern in local binding: `0..=1` and `3..=u8::MAX + let d = 4; //~ ERROR refutable pattern in local binding: `0..=1` and `3..=u8::MAX fn f() {} // Check that the `NOTE`s still work with an item here (cf. issue #35115). } diff --git a/src/test/ui/consts/const-pattern-irrefutable.stderr b/src/test/ui/consts/const-pattern-irrefutable.stderr index 3e3bc1979a2e0..ff5e478e991c8 100644 --- a/src/test/ui/consts/const-pattern-irrefutable.stderr +++ b/src/test/ui/consts/const-pattern-irrefutable.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered +error[E0005]: refutable pattern in local binding: `0..=1` and `3..=u8::MAX` not covered --> $DIR/const-pattern-irrefutable.rs:12:9 | LL | const a: u8 = 2; @@ -12,7 +12,7 @@ LL | let a = 4; | = note: the matched value is of type `u8` -error[E0005]: refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered +error[E0005]: refutable pattern in local binding: `0..=1` and `3..=u8::MAX` not covered --> $DIR/const-pattern-irrefutable.rs:13:9 | LL | pub const b: u8 = 2; @@ -26,7 +26,7 @@ LL | let c = 4; | = note: the matched value is of type `u8` -error[E0005]: refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered +error[E0005]: refutable pattern in local binding: `0..=1` and `3..=u8::MAX` not covered --> $DIR/const-pattern-irrefutable.rs:14:9 | LL | pub const d: u8 = 2; diff --git a/src/test/ui/for/for-loop-refutable-pattern-error-message.stderr b/src/test/ui/for/for-loop-refutable-pattern-error-message.stderr index 20b689aa5e0af..bd662549b1e1c 100644 --- a/src/test/ui/for/for-loop-refutable-pattern-error-message.stderr +++ b/src/test/ui/for/for-loop-refutable-pattern-error-message.stderr @@ -1,8 +1,8 @@ -error[E0005]: refutable pattern in `for` loop binding: `&i32::MIN..=0_i32` and `&2_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in `for` loop binding: `&i32::MIN..=0` and `&2..=i32::MAX` not covered --> $DIR/for-loop-refutable-pattern-error-message.rs:2:9 | LL | for &1 in [1].iter() {} - | ^^ patterns `&i32::MIN..=0_i32` and `&2_i32..=i32::MAX` not covered + | ^^ patterns `&i32::MIN..=0` and `&2..=i32::MAX` not covered | = note: the matched value is of type `&i32` diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr index 14dbca60b78f2..6ec0f7702efc4 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr @@ -25,11 +25,11 @@ LL | m!('a', ..core::char::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `char` -error[E0004]: non-exhaustive patterns: `'\u{10fffe}'..='\u{10ffff}'` not covered +error[E0004]: non-exhaustive patterns: `1114110..=1114111` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:27:8 | LL | m!('a', ..ALMOST_MAX); - | ^^^ pattern `'\u{10fffe}'..='\u{10ffff}'` not covered + | ^^^ pattern `1114110..=1114111` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `char` @@ -79,11 +79,11 @@ LL | m!(0, ..u8::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` -error[E0004]: non-exhaustive patterns: `254_u8..=u8::MAX` not covered +error[E0004]: non-exhaustive patterns: `254..=u8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:42:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `254_u8..=u8::MAX` not covered + | ^ pattern `254..=u8::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` @@ -133,11 +133,11 @@ LL | m!(0, ..u16::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u16` -error[E0004]: non-exhaustive patterns: `65534_u16..=u16::MAX` not covered +error[E0004]: non-exhaustive patterns: `65534..=u16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:55:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `65534_u16..=u16::MAX` not covered + | ^ pattern `65534..=u16::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u16` @@ -187,11 +187,11 @@ LL | m!(0, ..u32::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u32` -error[E0004]: non-exhaustive patterns: `4294967294_u32..=u32::MAX` not covered +error[E0004]: non-exhaustive patterns: `4294967294..=u32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:68:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `4294967294_u32..=u32::MAX` not covered + | ^ pattern `4294967294..=u32::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u32` @@ -241,11 +241,11 @@ LL | m!(0, ..u64::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u64` -error[E0004]: non-exhaustive patterns: `18446744073709551614_u64..=u64::MAX` not covered +error[E0004]: non-exhaustive patterns: `18446744073709551614..=u64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:81:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `18446744073709551614_u64..=u64::MAX` not covered + | ^ pattern `18446744073709551614..=u64::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u64` @@ -295,11 +295,11 @@ LL | m!(0, ..u128::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` -error[E0004]: non-exhaustive patterns: `340282366920938463463374607431768211454_u128..=u128::MAX` not covered +error[E0004]: non-exhaustive patterns: `340282366920938463463374607431768211454..=u128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:94:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `340282366920938463463374607431768211454_u128..=u128::MAX` not covered + | ^ pattern `340282366920938463463374607431768211454..=u128::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` @@ -349,11 +349,11 @@ LL | m!(0, ..i8::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` -error[E0004]: non-exhaustive patterns: `126_i8..=i8::MAX` not covered +error[E0004]: non-exhaustive patterns: `126..=i8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:110:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `126_i8..=i8::MAX` not covered + | ^ pattern `126..=i8::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` @@ -403,11 +403,11 @@ LL | m!(0, ..i16::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i16` -error[E0004]: non-exhaustive patterns: `32766_i16..=i16::MAX` not covered +error[E0004]: non-exhaustive patterns: `32766..=i16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:123:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `32766_i16..=i16::MAX` not covered + | ^ pattern `32766..=i16::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i16` @@ -457,11 +457,11 @@ LL | m!(0, ..i32::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` -error[E0004]: non-exhaustive patterns: `2147483646_i32..=i32::MAX` not covered +error[E0004]: non-exhaustive patterns: `2147483646..=i32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:136:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `2147483646_i32..=i32::MAX` not covered + | ^ pattern `2147483646..=i32::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` @@ -511,11 +511,11 @@ LL | m!(0, ..i64::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i64` -error[E0004]: non-exhaustive patterns: `9223372036854775806_i64..=i64::MAX` not covered +error[E0004]: non-exhaustive patterns: `9223372036854775806..=i64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:149:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `9223372036854775806_i64..=i64::MAX` not covered + | ^ pattern `9223372036854775806..=i64::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i64` @@ -565,11 +565,11 @@ LL | m!(0, ..i128::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i128` -error[E0004]: non-exhaustive patterns: `170141183460469231731687303715884105726_i128..=i128::MAX` not covered +error[E0004]: non-exhaustive patterns: `170141183460469231731687303715884105726..=i128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:162:12 | LL | m!(0, ..ALMOST_MAX); - | ^ pattern `170141183460469231731687303715884105726_i128..=i128::MAX` not covered + | ^ pattern `170141183460469231731687303715884105726..=i128::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i128` diff --git a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs index 5999e04e0e2dd..037423e39c5f3 100644 --- a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs +++ b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs @@ -3,15 +3,15 @@ // We wrap patterns in a tuple because top-level or-patterns were special-cased. fn main() { match (0u8, 0u8) { - //~^ ERROR non-exhaustive patterns: `(2_u8..=u8::MAX, _)` + //~^ ERROR non-exhaustive patterns: `(2..=u8::MAX, _)` (0 | 1, 2 | 3) => {} } match ((0u8,),) { - //~^ ERROR non-exhaustive patterns: `((4_u8..=u8::MAX))` + //~^ ERROR non-exhaustive patterns: `((4..=u8::MAX))` ((0 | 1,) | (2 | 3,),) => {} } match (Some(0u8),) { - //~^ ERROR non-exhaustive patterns: `(Some(2_u8..=u8::MAX))` + //~^ ERROR non-exhaustive patterns: `(Some(2..=u8::MAX))` (None | Some(0 | 1),) => {} } } diff --git a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr index 44f334eee9386..b2d81fdb52281 100644 --- a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr +++ b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr @@ -1,26 +1,26 @@ -error[E0004]: non-exhaustive patterns: `(2_u8..=u8::MAX, _)` not covered +error[E0004]: non-exhaustive patterns: `(2..=u8::MAX, _)` not covered --> $DIR/exhaustiveness-non-exhaustive.rs:5:11 | LL | match (0u8, 0u8) { - | ^^^^^^^^^^ pattern `(2_u8..=u8::MAX, _)` not covered + | ^^^^^^^^^^ pattern `(2..=u8::MAX, _)` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(u8, u8)` -error[E0004]: non-exhaustive patterns: `((4_u8..=u8::MAX))` not covered +error[E0004]: non-exhaustive patterns: `((4..=u8::MAX))` not covered --> $DIR/exhaustiveness-non-exhaustive.rs:9:11 | LL | match ((0u8,),) { - | ^^^^^^^^^ pattern `((4_u8..=u8::MAX))` not covered + | ^^^^^^^^^ pattern `((4..=u8::MAX))` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `((u8,),)` -error[E0004]: non-exhaustive patterns: `(Some(2_u8..=u8::MAX))` not covered +error[E0004]: non-exhaustive patterns: `(Some(2..=u8::MAX))` not covered --> $DIR/exhaustiveness-non-exhaustive.rs:13:11 | LL | match (Some(0u8),) { - | ^^^^^^^^^^^^ pattern `(Some(2_u8..=u8::MAX))` not covered + | ^^^^^^^^^^^^ pattern `(Some(2..=u8::MAX))` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(Option,)` diff --git a/src/test/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr b/src/test/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr index 61175b84ee1de..8355959c249e4 100644 --- a/src/test/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr +++ b/src/test/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr @@ -1,8 +1,8 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding: `i32::MIN..=-1` and `3..=i32::MAX` not covered --> $DIR/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs:2:10 | LL | let (0 | (1 | 2)) = 0; - | ^^^^^^^^^^^ patterns `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered + | ^^^^^^^^^^^ patterns `i32::MIN..=-1` and `3..=i32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html @@ -12,11 +12,11 @@ help: you might want to use `if let` to ignore the variant that isn't matched LL | if let (0 | (1 | 2)) = 0 { /* */ } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0004]: non-exhaustive patterns: `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered +error[E0004]: non-exhaustive patterns: `i32::MIN..=-1` and `3..=i32::MAX` not covered --> $DIR/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs:3:11 | LL | match 0 { - | ^ patterns `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered + | ^ patterns `i32::MIN..=-1` and `3..=i32::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` diff --git a/src/test/ui/pattern/usefulness/guards.stderr b/src/test/ui/pattern/usefulness/guards.stderr index 61f7facb330da..7a5fd66ce003d 100644 --- a/src/test/ui/pattern/usefulness/guards.stderr +++ b/src/test/ui/pattern/usefulness/guards.stderr @@ -1,8 +1,8 @@ -error[E0004]: non-exhaustive patterns: `128_u8..=u8::MAX` not covered +error[E0004]: non-exhaustive patterns: `128..=u8::MAX` not covered --> $DIR/guards.rs:12:11 | LL | match 0u8 { - | ^^^ pattern `128_u8..=u8::MAX` not covered + | ^^^ pattern `128..=u8::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` diff --git a/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr b/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr index b1440375494b1..48dabdcc2bca5 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr +++ b/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr @@ -79,11 +79,11 @@ LL | m!(0u128, 0..=ALMOST_MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` -error[E0004]: non-exhaustive patterns: `5_u128..=u128::MAX` not covered +error[E0004]: non-exhaustive patterns: `5..=u128::MAX` not covered --> $DIR/exhaustiveness.rs:61:8 | LL | m!(0u128, 0..=4); - | ^^^^^ pattern `5_u128..=u128::MAX` not covered + | ^^^^^ pattern `5..=u128::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` @@ -97,11 +97,11 @@ LL | m!(0u128, 1..=u128::MAX); = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` -error[E0004]: non-exhaustive patterns: `(126_u8..=127_u8, false)` not covered +error[E0004]: non-exhaustive patterns: `(126..=127, false)` not covered --> $DIR/exhaustiveness.rs:70:11 | LL | match (0u8, true) { - | ^^^^^^^^^^^ pattern `(126_u8..=127_u8, false)` not covered + | ^^^^^^^^^^^ pattern `(126..=127, false)` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(u8, bool)` diff --git a/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr b/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr index ffc8433403fd5..95187fa0b35d0 100644 --- a/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr +++ b/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr @@ -1,8 +1,8 @@ -error[E0004]: non-exhaustive patterns: `&[0_u8..=64_u8, _, _, _]` and `&[66_u8..=u8::MAX, _, _, _]` not covered +error[E0004]: non-exhaustive patterns: `&[0..=64, _, _, _]` and `&[66..=u8::MAX, _, _, _]` not covered --> $DIR/match-byte-array-patterns-2.rs:4:11 | LL | match buf { - | ^^^ patterns `&[0_u8..=64_u8, _, _, _]` and `&[66_u8..=u8::MAX, _, _, _]` not covered + | ^^^ patterns `&[0..=64, _, _, _]` and `&[66..=u8::MAX, _, _, _]` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[u8; 4]` diff --git a/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr b/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr index a35d61e4b710b..cbfe3a5e97489 100644 --- a/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr +++ b/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr @@ -1,8 +1,8 @@ -error[E0004]: non-exhaustive patterns: `i32::MIN..=0_i32` and `2_i32..=i32::MAX` not covered +error[E0004]: non-exhaustive patterns: `i32::MIN..=0` and `2..=i32::MAX` not covered --> $DIR/match-non-exhaustive.rs:2:11 | LL | match 0 { 1 => () } - | ^ patterns `i32::MIN..=0_i32` and `2_i32..=i32::MAX` not covered + | ^ patterns `i32::MIN..=0` and `2..=i32::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-match.rs b/src/test/ui/pattern/usefulness/non-exhaustive-match.rs index 4ff12aa2ff5e2..af9513874b44a 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-match.rs +++ b/src/test/ui/pattern/usefulness/non-exhaustive-match.rs @@ -11,8 +11,8 @@ fn main() { match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered None => {} } - match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, i32::MIN..=3_i32)` - // and `(_, _, 5_i32..=i32::MAX)` not covered + match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, i32::MIN..=3)` + // and `(_, _, 5..=i32::MAX)` not covered (_, _, 4) => {} } match (T::A, T::A) { //~ ERROR non-exhaustive patterns: `(A, A)` and `(B, B)` not covered diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr index c953cd314406e..c29637d74a9ba 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr @@ -36,11 +36,11 @@ LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `Option` -error[E0004]: non-exhaustive patterns: `(_, _, i32::MIN..=3_i32)` and `(_, _, 5_i32..=i32::MAX)` not covered +error[E0004]: non-exhaustive patterns: `(_, _, i32::MIN..=3)` and `(_, _, 5..=i32::MAX)` not covered --> $DIR/non-exhaustive-match.rs:14:11 | LL | match (2, 3, 4) { - | ^^^^^^^^^ patterns `(_, _, i32::MIN..=3_i32)` and `(_, _, 5_i32..=i32::MAX)` not covered + | ^^^^^^^^^ patterns `(_, _, i32::MIN..=3)` and `(_, _, 5..=i32::MAX)` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(i32, i32, i32)` diff --git a/src/test/ui/pattern/usefulness/refutable-pattern-errors.rs b/src/test/ui/pattern/usefulness/refutable-pattern-errors.rs index 7c9aa51e7484c..cc0a0abd10c69 100644 --- a/src/test/ui/pattern/usefulness/refutable-pattern-errors.rs +++ b/src/test/ui/pattern/usefulness/refutable-pattern-errors.rs @@ -3,5 +3,5 @@ fn func((1, (Some(1), 2..=3)): (isize, (Option, isize))) { } fn main() { let (1, (Some(1), 2..=3)) = (1, (None, 2)); - //~^ ERROR refutable pattern in local binding: `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered + //~^ ERROR refutable pattern in local binding: `(i32::MIN..=0, _)` and `(2..=i32::MAX, _)` not covered } diff --git a/src/test/ui/pattern/usefulness/refutable-pattern-errors.stderr b/src/test/ui/pattern/usefulness/refutable-pattern-errors.stderr index 74ec646e31cca..027371936d3c9 100644 --- a/src/test/ui/pattern/usefulness/refutable-pattern-errors.stderr +++ b/src/test/ui/pattern/usefulness/refutable-pattern-errors.stderr @@ -6,11 +6,11 @@ LL | fn func((1, (Some(1), 2..=3)): (isize, (Option, isize))) { } | = note: the matched value is of type `(isize, (Option, isize))` -error[E0005]: refutable pattern in local binding: `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered +error[E0005]: refutable pattern in local binding: `(i32::MIN..=0, _)` and `(2..=i32::MAX, _)` not covered --> $DIR/refutable-pattern-errors.rs:5:9 | LL | let (1, (Some(1), 2..=3)) = (1, (None, 2)); - | ^^^^^^^^^^^^^^^^^^^^^ patterns `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered + | ^^^^^^^^^^^^^^^^^^^^^ patterns `(i32::MIN..=0, _)` and `(2..=i32::MAX, _)` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html diff --git a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs index ac819dce6db2b..53fd5a5e3a51f 100644 --- a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs +++ b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs @@ -1,6 +1,6 @@ fn main() { let A = 3; - //~^ ERROR refutable pattern in local binding: `i32::MIN..=1_i32` and + //~^ ERROR refutable pattern in local binding: `i32::MIN..=1` and //~| interpreted as a constant pattern, not a new variable //~| HELP introduce a variable instead //~| SUGGESTION a_var diff --git a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr index af64c09d5cadb..bfff3d3b8ec06 100644 --- a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr +++ b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding: `i32::MIN..=1` and `3..=i32::MAX` not covered --> $DIR/const-pat-non-exaustive-let-new-var.rs:2:9 | LL | let A = 3;