about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-03-05 23:53:24 +0100
committerLukas Wirth <lukastw97@gmail.com>2022-03-05 23:53:24 +0100
commit0bb631bf715feca9ab1c2c8de7ded6e8d0585096 (patch)
treef4cbda8a8f1f04b6594d73a7eedc339bc27740de
parentb454f11f381ab1122772a0c48c8265baa91c33d1 (diff)
downloadrust-0bb631bf715feca9ab1c2c8de7ded6e8d0585096.tar.gz
rust-0bb631bf715feca9ab1c2c8de7ded6e8d0585096.zip
Simplify
-rw-r--r--crates/hir_def/src/path/lower.rs4
-rw-r--r--crates/hir_expand/src/mod_path.rs11
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 f99b97178b4..550f12dabdc 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<Path> {
                 }
             }
             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 d1f0b7a87e3..5e264d0398d 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() {