diff options
Diffstat (limited to 'src/librustc/ty')
| -rw-r--r-- | src/librustc/ty/item_path.rs | 1 | ||||
| -rw-r--r-- | src/librustc/ty/mod.rs | 12 | ||||
| -rw-r--r-- | src/librustc/ty/util.rs | 9 |
3 files changed, 10 insertions, 12 deletions
diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index 417e14054d2..9328de4f6a0 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -311,6 +311,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { data @ DefPathData::Misc | data @ DefPathData::TypeNs(..) | data @ DefPathData::Trait(..) | + data @ DefPathData::TraitAlias(..) | data @ DefPathData::AssocTypeInTrait(..) | data @ DefPathData::AssocTypeInImpl(..) | data @ DefPathData::AssocExistentialInImpl(..) | diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index f1b36e8def8..dd315cf42ce 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -3170,18 +3170,6 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option<DefI None } -/// Returns `true` if `def_id` is a trait alias. -pub fn is_trait_alias(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> bool { - if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { - if let Node::Item(item) = tcx.hir().get(node_id) { - if let hir::ItemKind::TraitAlias(..) = item.node { - return true; - } - } - } - false -} - /// See `ParamEnv` struct definition for details. fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index e989ef823e9..75fc0f716a2 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -526,6 +526,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } + /// True if `def_id` refers to a trait alias (i.e., `trait Foo = ...;`). + pub fn is_trait_alias(self, def_id: DefId) -> bool { + if let DefPathData::TraitAlias(_) = self.def_key(def_id).disambiguated_data.data { + true + } else { + false + } + } + /// True if this def-id refers to the implicit constructor for /// a tuple struct like `struct Foo(u32)`. pub fn is_struct_constructor(self, def_id: DefId) -> bool { |
