use syntax::ext::base::MacroKind;
use syntax_pos::Span;
use hir;
+use ty;
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum CtorKind {
Trait(DefId),
TyAlias(DefId),
TyForeign(DefId),
+ TraitAlias(DefId),
AssociatedTy(DefId),
PrimTy(hir::PrimTy),
TyParam(DefId),
/// `base_def` is definition of resolved part of the
/// path, `unresolved_segments` is the number of unresolved
/// segments.
-/// module::Type::AssocX::AssocY::MethodOrAssocType
-/// ^~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-/// base_def unresolved_segments = 3
///
-/// <T as Trait>::AssocX::AssocY::MethodOrAssocType
-/// ^~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
-/// base_def unresolved_segments = 2
+/// ```text
+/// module::Type::AssocX::AssocY::MethodOrAssocType
+/// ^~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+/// base_def unresolved_segments = 3
+///
+/// <T as Trait>::AssocX::AssocY::MethodOrAssocType
+/// ^~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
+/// base_def unresolved_segments = 2
+/// ```
#[derive(Copy, Clone, Debug)]
pub struct PathResolution {
base_def: Def,
pub def: Def,
/// The span of the target definition.
pub span: Span,
+ /// The visibility of the export.
+ /// We include non-`pub` exports for hygienic macros that get used from extern crates.
+ pub vis: ty::Visibility,
+ /// True if from a `use` or and `extern crate`.
+ /// Used in rustdoc.
+ pub is_import: bool,
}
impl CtorKind {
pub fn def_id(&self) -> DefId {
match *self {
Def::Fn(id) | Def::Mod(id) | Def::Static(id, _) |
- Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) | Def::TyAlias(id) |
+ Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) |
+ Def::TyAlias(id) | Def::TraitAlias(id) |
Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
Def::AssociatedConst(id) | Def::Macro(id, ..) |
Def::VariantCtor(.., CtorKind::Fictive) => "struct variant",
Def::Enum(..) => "enum",
Def::TyAlias(..) => "type alias",
+ Def::TraitAlias(..) => "trait alias",
Def::AssociatedTy(..) => "associated type",
Def::Struct(..) => "struct",
Def::StructCtor(.., CtorKind::Fn) => "tuple struct",