diff options
| author | Yotam Ofek <yotam.ofek@gmail.com> | 2025-01-18 07:44:37 +0000 |
|---|---|---|
| committer | Yotam Ofek <yotam.ofek@gmail.com> | 2025-01-21 07:40:54 +0000 |
| commit | ce0b72a99c4c71c3b72c85549fafe5d0beb4cee4 (patch) | |
| tree | ea14a4dcfeb3a89b07760cd5182e2a36dfeb1fee /compiler/rustc_resolve/src/diagnostics.rs | |
| parent | 7ae198b08dc422662136c5158b482859b159ec50 (diff) | |
| download | rust-ce0b72a99c4c71c3b72c85549fafe5d0beb4cee4.tar.gz rust-ce0b72a99c4c71c3b72c85549fafe5d0beb4cee4.zip | |
use slice patterns for checking for elements of slice
Diffstat (limited to 'compiler/rustc_resolve/src/diagnostics.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 66a04eb0617..0da27a9c071 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2242,14 +2242,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { mut path: Vec<Segment>, parent_scope: &ParentScope<'ra>, ) -> Option<(Vec<Segment>, Option<String>)> { - match (path.get(0), path.get(1)) { + match path[..] { // `{{root}}::ident::...` on both editions. // On 2015 `{{root}}` is usually added implicitly. - (Some(fst), Some(snd)) - if fst.ident.name == kw::PathRoot && !snd.ident.is_path_segment_keyword() => {} + [first, second, ..] + if first.ident.name == kw::PathRoot && !second.ident.is_path_segment_keyword() => {} // `ident::...` on 2018. - (Some(fst), _) - if fst.ident.span.at_least_rust_2018() && !fst.ident.is_path_segment_keyword() => + [first, ..] + if first.ident.span.at_least_rust_2018() + && !first.ident.is_path_segment_keyword() => { // Insert a placeholder that's later replaced by `self`/`super`/etc. path.insert(0, Segment::from_ident(Ident::empty())); |
