aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/type_ref.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-03-24 16:00:29 +0000
committerLukas Wirth <[email protected]>2021-03-29 16:11:28 +0100
commitbb6e1bf811bce09fdab115a4257e47cc0d5ddc82 (patch)
tree7fa2802e317177ef9da00a442fddb75528d9b56b /crates/hir_def/src/type_ref.rs
parentbb1d925dab36372c6bd1fb5671bb68ce938ff009 (diff)
Lower traits to TraitRef instead of TypeRef
Diffstat (limited to 'crates/hir_def/src/type_ref.rs')
-rw-r--r--crates/hir_def/src/type_ref.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/hir_def/src/type_ref.rs b/crates/hir_def/src/type_ref.rs
index 049b2e462..b7484ed0d 100644
--- a/crates/hir_def/src/type_ref.rs
+++ b/crates/hir_def/src/type_ref.rs
@@ -51,6 +51,25 @@ impl Rawness {
51 } 51 }
52} 52}
53 53
54#[derive(Clone, PartialEq, Eq, Hash, Debug)]
55pub enum TraitRef {
56 Path(Path),
57 Error,
58}
59
60impl TraitRef {
61 /// Converts an `ast::PathType` to a `hir::TraitRef`.
62 pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self {
63 // FIXME: Use `Path::from_src`
64 match node {
65 ast::Type::PathType(path) => path
66 .path()
67 .and_then(|it| ctx.lower_path(it))
68 .map_or(TraitRef::Error, TraitRef::Path),
69 _ => TraitRef::Error,
70 }
71 }
72}
54/// Compare ty::Ty 73/// Compare ty::Ty
55#[derive(Clone, PartialEq, Eq, Hash, Debug)] 74#[derive(Clone, PartialEq, Eq, Hash, Debug)]
56pub enum TypeRef { 75pub enum TypeRef {