From 0bb631bf715feca9ab1c2c8de7ded6e8d0585096 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 5 Mar 2022 23:53:24 +0100 Subject: [PATCH] Simplify --- crates/hir_def/src/path/lower.rs | 4 ++-- crates/hir_expand/src/mod_path.rs | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/hir_def/src/path/lower.rs b/crates/hir_def/src/path/lower.rs index f99b97178b..550f12dabd 100644 --- a/crates/hir_def/src/path/lower.rs +++ b/crates/hir_def/src/path/lower.rs @@ -3,7 +3,7 @@ use crate::intern::Interned; use either::Either; -use hir_expand::name::{known, name, AsName}; +use hir_expand::name::{name, AsName}; use syntax::ast::{self, AstNode, HasTypeBounds}; use super::AssociatedTypeBinding; @@ -54,7 +54,7 @@ pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx) -> Option { } } ast::PathSegmentKind::SelfTypeKw => { - segments.push(known::SELF_TYPE); + segments.push(name![Self]); generic_args.push(None) } ast::PathSegmentKind::Type { type_ref, trait_ref } => { diff --git a/crates/hir_expand/src/mod_path.rs b/crates/hir_expand/src/mod_path.rs index d1f0b7a87e..5e264d0398 100644 --- a/crates/hir_expand/src/mod_path.rs +++ b/crates/hir_expand/src/mod_path.rs @@ -167,13 +167,10 @@ fn convert_path( } } ast::PathSegmentKind::SelfTypeKw => { - let mut res = prefix.unwrap_or_else(|| { - ModPath::from_kind( - segment.coloncolon_token().map_or(PathKind::Plain, |_| PathKind::Abs), - ) - }); - res.segments.push(known::SELF_TYPE); - res + if prefix.is_some() { + return None; + } + ModPath::from_segments(PathKind::Plain, Some(known::SELF_TYPE)) } ast::PathSegmentKind::CrateKw => { if prefix.is_some() {