Add macros for known names and paths

This commit is contained in:
Florian Diebold 2019-12-13 21:43:53 +01:00
parent 169fe4932f
commit 259c42f00e
16 changed files with 185 additions and 166 deletions

View file

@ -6,7 +6,7 @@ use std::sync::Arc;
use either::Either;
use hir_expand::{
name::{self, AsName, Name},
name::{AsName, Name, N},
InFile,
};
use ra_arena::{map::ArenaMap, Arena};
@ -90,11 +90,11 @@ impl GenericParams {
// traits get the Self type as an implicit first type parameter
let self_param_id =
generics.types.alloc(TypeParamData { name: name::SELF_TYPE, default: None });
generics.types.alloc(TypeParamData { name: N![Self], default: None });
sm.insert(self_param_id, Either::Left(src.value.clone()));
// add super traits as bounds on Self
// i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar
let self_param = TypeRef::Path(name::SELF_TYPE.into());
let self_param = TypeRef::Path(N![Self].into());
generics.fill_bounds(&src.value, self_param);
generics.fill(&mut sm, &src.value);