Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errors
Use more slice patterns inside the compiler Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'. r? ghost
This commit is contained in:
commit
32e0fe129d
40 changed files with 191 additions and 221 deletions
|
@ -676,7 +676,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
match &expr.kind {
|
||||
ExprKind::Path(None, ast::Path { segments, .. })
|
||||
if segments.len() == 1 =>
|
||||
if let [segment] = segments.as_slice() =>
|
||||
{
|
||||
if self.token == token::Colon
|
||||
&& self.look_ahead(1, |token| {
|
||||
|
@ -693,8 +693,8 @@ impl<'a> Parser<'a> {
|
|||
let snapshot = self.create_snapshot_for_diagnostic();
|
||||
let label = Label {
|
||||
ident: Ident::from_str_and_span(
|
||||
&format!("'{}", segments[0].ident),
|
||||
segments[0].ident.span,
|
||||
&format!("'{}", segment.ident),
|
||||
segment.ident.span,
|
||||
),
|
||||
};
|
||||
match self.parse_expr_labeled(label, false) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue