diff options
Diffstat (limited to 'crates/hir_def/src/type_ref.rs')
-rw-r--r-- | crates/hir_def/src/type_ref.rs | 19 |
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)] | ||
55 | pub enum TraitRef { | ||
56 | Path(Path), | ||
57 | Error, | ||
58 | } | ||
59 | |||
60 | impl 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)] |
56 | pub enum TypeRef { | 75 | pub enum TypeRef { |