@@ -47,7 +47,7 @@ You can read more about trait objects in the Trait Objects section of the Refere
47
47
https://doc.rust-lang.org/reference/types.html#trait-objects";
48
48
49
49
fn is_number(text: &str) -> bool {
50
- text.chars().all(|c: char| c.is_digit(10 ))
50
+ text.chars().all(|c: char| c.is_ascii_digit( ))
51
51
}
52
52
53
53
/// Information about the expected type at the top level of type checking a pattern.
@@ -262,8 +262,9 @@ enum InheritedRefMatchRule {
262
262
/// pattern matches a given type:
263
263
/// - If the underlying type is not a reference, a reference pattern may eat the inherited reference;
264
264
/// - If the underlying type is a reference, a reference pattern matches if it can eat either one
265
- /// of the underlying and inherited references. E.g. a `&mut` pattern is allowed if either the
266
- /// underlying type is `&mut` or the inherited reference is `&mut`.
265
+ /// of the underlying and inherited references. E.g. a `&mut` pattern is allowed if either the
266
+ /// underlying type is `&mut` or the inherited reference is `&mut`.
267
+ ///
267
268
/// If `false`, a reference pattern is only matched against the underlying type.
268
269
/// This is `false` for stable Rust and `true` for both the `ref_pat_eat_one_layer_2024` and
269
270
/// `ref_pat_eat_one_layer_2024_structural` feature gates.
@@ -1069,7 +1070,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1069
1070
{
1070
1071
if !self.tcx.features().mut_ref() {
1071
1072
feature_err(
1072
- & self.tcx.sess,
1073
+ self.tcx.sess,
1073
1074
sym::mut_ref,
1074
1075
pat.span.until(ident.span),
1075
1076
"binding cannot be both mutable and by-reference",
@@ -1487,31 +1488,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1487
1488
opt_def_id: Option<hir::def_id::DefId>,
1488
1489
ident: Ident,
1489
1490
) -> bool {
1490
- match opt_def_id {
1491
- Some(def_id) => match self.tcx.hir_get_if_local(def_id) {
1492
- Some(hir::Node::Item(hir::Item {
1493
- kind: hir::ItemKind::Const(_, _, _, body_id),
1494
- ..
1495
- })) => match self.tcx.hir_node(body_id.hir_id) {
1496
- hir::Node::Expr(expr) => {
1497
- if hir::is_range_literal(expr) {
1498
- let span = self.tcx.hir_span(body_id.hir_id);
1499
- if let Ok(snip) = self.tcx.sess.source_map().span_to_snippet(span) {
1500
- e.span_suggestion_verbose(
1501
- ident.span,
1502
- "you may want to move the range into the match block",
1503
- snip,
1504
- Applicability::MachineApplicable,
1505
- );
1506
- return true;
1507
- }
1508
- }
1509
- }
1510
- _ => (),
1511
- },
1512
- _ => (),
1513
- },
1514
- _ => (),
1491
+ if let Some(def_id) = opt_def_id
1492
+ && let Some(hir::Node::Item(hir::Item {
1493
+ kind: hir::ItemKind::Const(_, _, _, body_id),
1494
+ ..
1495
+ })) = self.tcx.hir_get_if_local(def_id)
1496
+ && let hir::Node::Expr(expr) = self.tcx.hir_node(body_id.hir_id)
1497
+ && hir::is_range_literal(expr)
1498
+ {
1499
+ let span = self.tcx.hir_span(body_id.hir_id);
1500
+ if let Ok(snip) = self.tcx.sess.source_map().span_to_snippet(span) {
1501
+ e.span_suggestion_verbose(
1502
+ ident.span,
1503
+ "you may want to move the range into the match block",
1504
+ snip,
1505
+ Applicability::MachineApplicable,
1506
+ );
1507
+ return true;
1508
+ }
1515
1509
}
1516
1510
false
1517
1511
}
@@ -1529,7 +1523,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1529
1523
1530
1524
if let Some(span) = self.tcx.hir_res_span(pat_res) {
1531
1525
e.span_label(span, format!("{} defined here", res.descr()));
1532
- if let [hir::PathSegment { ident, .. }] = &* segments {
1526
+ if let [hir::PathSegment { ident, .. }] = segments {
1533
1527
e.span_label(
1534
1528
pat_span,
1535
1529
format!(
@@ -1557,17 +1551,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1557
1551
_ => (None, None),
1558
1552
};
1559
1553
1560
- let is_range = match type_def_id.and_then(|id| self.tcx.as_lang_item(id)) {
1554
+ let is_range = matches!(
1555
+ type_def_id.and_then(|id| self.tcx.as_lang_item(id)),
1561
1556
Some(
1562
1557
LangItem::Range
1563
- | LangItem::RangeFrom
1564
- | LangItem::RangeTo
1565
- | LangItem::RangeFull
1566
- | LangItem::RangeInclusiveStruct
1567
- | LangItem::RangeToInclusive,
1568
- ) => true,
1569
- _ => false,
1570
- };
1558
+ | LangItem::RangeFrom
1559
+ | LangItem::RangeTo
1560
+ | LangItem::RangeFull
1561
+ | LangItem::RangeInclusiveStruct
1562
+ | LangItem::RangeToInclusive,
1563
+ )
1564
+ );
1571
1565
if is_range {
1572
1566
if !self.maybe_suggest_range_literal(&mut e, item_def_id, *ident) {
1573
1567
let msg = "constants only support matching by type, \
0 commit comments