1
Fork 0

use slice patterns for checking for elements of slice

This commit is contained in:
Yotam Ofek 2025-01-18 07:44:37 +00:00
parent 7ae198b08d
commit ce0b72a99c

View file

@ -2242,14 +2242,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
mut path: Vec<Segment>, mut path: Vec<Segment>,
parent_scope: &ParentScope<'ra>, parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)> { ) -> Option<(Vec<Segment>, Option<String>)> {
match (path.get(0), path.get(1)) { match path[..] {
// `{{root}}::ident::...` on both editions. // `{{root}}::ident::...` on both editions.
// On 2015 `{{root}}` is usually added implicitly. // On 2015 `{{root}}` is usually added implicitly.
(Some(fst), Some(snd)) [first, second, ..]
if fst.ident.name == kw::PathRoot && !snd.ident.is_path_segment_keyword() => {} if first.ident.name == kw::PathRoot && !second.ident.is_path_segment_keyword() => {}
// `ident::...` on 2018. // `ident::...` on 2018.
(Some(fst), _) [first, ..]
if fst.ident.span.at_least_rust_2018() && !fst.ident.is_path_segment_keyword() => 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. // Insert a placeholder that's later replaced by `self`/`super`/etc.
path.insert(0, Segment::from_ident(Ident::empty())); path.insert(0, Segment::from_ident(Ident::empty()));