Skip to content

Commit 9cd875b

Browse files
committed
use slice patterns for checking for elements of slice
1 parent 1cd010b commit 9cd875b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -2242,14 +2242,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22422242
mut path: Vec<Segment>,
22432243
parent_scope: &ParentScope<'ra>,
22442244
) -> Option<(Vec<Segment>, Option<String>)> {
2245-
match (path.get(0), path.get(1)) {
2245+
match path[..] {
22462246
// `{{root}}::ident::...` on both editions.
22472247
// On 2015 `{{root}}` is usually added implicitly.
2248-
(Some(fst), Some(snd))
2249-
if fst.ident.name == kw::PathRoot && !snd.ident.is_path_segment_keyword() => {}
2248+
[first, second, ..]
2249+
if first.ident.name == kw::PathRoot && !second.ident.is_path_segment_keyword() => {}
22502250
// `ident::...` on 2018.
2251-
(Some(fst), _)
2252-
if fst.ident.span.at_least_rust_2018() && !fst.ident.is_path_segment_keyword() =>
2251+
[first, ..]
2252+
if first.ident.span.at_least_rust_2018()
2253+
&& !first.ident.is_path_segment_keyword() =>
22532254
{
22542255
// Insert a placeholder that's later replaced by `self`/`super`/etc.
22552256
path.insert(0, Segment::from_ident(Ident::empty()));

0 commit comments

Comments
 (0)