Skip to content

Commit 1a56184

Browse files
authored
Rollup merge of #142530 - fee1-dead-contrib:push-klusvwusyqvq, r=compiler-errors
use `if let` guards where possible these crates already enable the feature
2 parents dc16682 + 96fd9fc commit 1a56184

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ pub(crate) fn expand_test_or_bench(
118118

119119
let (item, is_stmt) = match item {
120120
Annotatable::Item(i) => (i, false),
121-
Annotatable::Stmt(stmt) if matches!(stmt.kind, ast::StmtKind::Item(_)) => {
122-
// FIXME: Use an 'if let' guard once they are implemented
123-
if let ast::StmtKind::Item(i) = stmt.kind { (i, true) } else { unreachable!() }
124-
}
121+
Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true),
125122
other => {
126123
not_testable_error(cx, attr_sp, None);
127124
return vec![other];

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,23 +2273,18 @@ impl<'a> Parser<'a> {
22732273
),
22742274
// Also catches `fn foo(&a)`.
22752275
PatKind::Ref(ref inner_pat, mutab)
2276-
if matches!(inner_pat.clone().kind, PatKind::Ident(..)) =>
2276+
if let PatKind::Ident(_, ident, _) = inner_pat.clone().kind =>
22772277
{
2278-
match inner_pat.clone().kind {
2279-
PatKind::Ident(_, ident, _) => {
2280-
let mutab = mutab.prefix_str();
2281-
(
2282-
ident,
2283-
"self: ",
2284-
format!("{ident}: &{mutab}TypeName"),
2285-
"_: ",
2286-
pat.span.shrink_to_lo(),
2287-
pat.span,
2288-
pat.span.shrink_to_lo(),
2289-
)
2290-
}
2291-
_ => unreachable!(),
2292-
}
2278+
let mutab = mutab.prefix_str();
2279+
(
2280+
ident,
2281+
"self: ",
2282+
format!("{ident}: &{mutab}TypeName"),
2283+
"_: ",
2284+
pat.span.shrink_to_lo(),
2285+
pat.span,
2286+
pat.span.shrink_to_lo(),
2287+
)
22932288
}
22942289
_ => {
22952290
// Otherwise, try to get a type and emit a suggestion.

0 commit comments

Comments
 (0)