提交 05cfb3f5 编写于 作者: V varkor

Rename Def::{Param, Foreign} to Def::{TyParam, TyForeign}

上级 08f3685a
......@@ -53,13 +53,13 @@ pub enum Def {
Existential(DefId),
/// `type Foo = Bar;`
TyAlias(DefId),
Foreign(DefId),
TyForeign(DefId),
TraitAlias(DefId),
AssociatedTy(DefId),
/// `existential type Foo: Bar;`
AssociatedExistential(DefId),
PrimTy(hir::PrimTy),
Param(DefId),
TyParam(DefId),
SelfTy(Option<DefId> /* trait */, Option<DefId> /* impl */),
ToolMod, // e.g. `rustfmt` in `#[rustfmt::skip]`
......@@ -269,10 +269,10 @@ pub fn def_id(&self) -> DefId {
Def::Fn(id) | Def::Mod(id) | Def::Static(id, _) |
Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) |
Def::TyAlias(id) | Def::TraitAlias(id) |
Def::AssociatedTy(id) | Def::Param(id) | Def::Struct(id) | Def::StructCtor(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::Existential(id) | Def::AssociatedExistential(id) | Def::Foreign(id) => {
Def::Existential(id) | Def::AssociatedExistential(id) | Def::TyForeign(id) => {
id
}
......@@ -311,11 +311,11 @@ pub fn kind_name(&self) -> &'static str {
Def::StructCtor(.., CtorKind::Fictive) => bug!("impossible struct constructor"),
Def::Union(..) => "union",
Def::Trait(..) => "trait",
Def::Foreign(..) => "foreign type",
Def::TyForeign(..) => "foreign type",
Def::Method(..) => "method",
Def::Const(..) => "constant",
Def::AssociatedConst(..) => "associated constant",
Def::Param(..) => "type parameter",
Def::TyParam(..) => "type parameter",
Def::PrimTy(..) => "builtin type",
Def::Local(..) => "local variable",
Def::Upvar(..) => "closure capture",
......
......@@ -1213,7 +1213,7 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext) -> hir::Ty {
None,
P(hir::Path {
span,
def: Def::Param(DefId::local(def_index)),
def: Def::TyParam(DefId::local(def_index)),
segments: hir_vec![hir::PathSegment::from_ident(ident)],
}),
))
......@@ -2352,7 +2352,7 @@ fn lower_generics(
if path.segments.len() == 1
&& bound_pred.bound_generic_params.is_empty() =>
{
if let Some(Def::Param(def_id)) = self.resolver
if let Some(Def::TyParam(def_id)) = self.resolver
.get_resolution(bound_pred.bounded_ty.id)
.map(|d| d.base_def())
{
......
......@@ -453,7 +453,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
match item.node {
ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)),
ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)),
ForeignItemKind::Type => Some(Def::Foreign(def_id)),
ForeignItemKind::Type => Some(Def::TyForeign(def_id)),
}
}
NodeTraitItem(item) => {
......@@ -499,7 +499,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
NodeGenericParam(param) => {
Some(match param.kind {
GenericParamKind::Lifetime { .. } => Def::Local(param.id),
GenericParamKind::Type { .. } => Def::Param(self.local_def_id(param.id)),
GenericParamKind::Type { .. } => Def::TyParam(self.local_def_id(param.id)),
})
}
}
......
......@@ -1010,9 +1010,9 @@ fn to_stable_hash_key(&self,
AssociatedTy(def_id),
AssociatedExistential(def_id),
PrimTy(prim_ty),
Param(def_id),
TyParam(def_id),
SelfTy(trait_def_id, impl_def_id),
Foreign(def_id),
TyForeign(def_id),
Fn(def_id),
Const(def_id),
Static(def_id, is_mutbl),
......
......@@ -1326,7 +1326,7 @@ fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::GenericBound]) {
_ => continue,
};
if def == Def::Param(param_def_id) {
if def == Def::TyParam(param_def_id) {
add_bounds(&mut set, &data.bounds);
}
}
......
......@@ -1510,7 +1510,7 @@ fn is_type_variable_assoc(qpath: &hir::QPath) -> bool {
match ty.node {
hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => {
match path.def {
Def::Param(_) => true,
Def::TyParam(_) => true,
_ => false
}
}
......
......@@ -429,7 +429,7 @@ fn to_def(&self, did: DefId) -> Option<Def> {
EntryKind::Trait(_) => Def::Trait(did),
EntryKind::Enum(..) => Def::Enum(did),
EntryKind::MacroDef(_) => Def::Macro(did, MacroKind::Bang),
EntryKind::ForeignType => Def::Foreign(did),
EntryKind::ForeignType => Def::TyForeign(did),
EntryKind::ForeignMod |
EntryKind::GlobalAsm |
......
......@@ -656,7 +656,7 @@ fn build_reduced_graph_for_foreign_item(&mut self, item: &ForeignItem, expansion
(Def::Static(self.definitions.local_def_id(item.id), m), ValueNS)
}
ForeignItemKind::Ty => {
(Def::Foreign(self.definitions.local_def_id(item.id)), TypeNS)
(Def::TyForeign(self.definitions.local_def_id(item.id)), TypeNS)
}
ForeignItemKind::Macro(_) => unreachable!(),
};
......@@ -692,7 +692,7 @@ fn build_reduced_graph_for_external_crate_def(&mut self, parent: Module<'a>, chi
span);
self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion));
}
Def::Variant(..) | Def::TyAlias(..) | Def::Foreign(..) => {
Def::Variant(..) | Def::TyAlias(..) | Def::TyForeign(..) => {
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
}
Def::Fn(..) | Def::Static(..) | Def::Const(..) | Def::VariantCtor(..) => {
......
......@@ -204,14 +204,14 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
"`Self` type implicitly declared here, on the `impl`");
}
},
Def::Param(typaram_defid) => {
Def::TyParam(typaram_defid) => {
if let Some(typaram_span) = resolver.definitions.opt_span(typaram_defid) {
err.span_label(typaram_span, "type variable from outer function");
}
},
_ => {
bug!("TypeParametersFromOuterFunction should only be used with Def::SelfTy or \
Def::Param")
Def::TyParam")
}
}
......@@ -537,9 +537,9 @@ fn is_expected(self, def: Def) -> bool {
PathSource::Type => match def {
Def::Struct(..) | Def::Union(..) | Def::Enum(..) |
Def::Trait(..) | Def::TyAlias(..) | Def::AssociatedTy(..) |
Def::PrimTy(..) | Def::Param(..) | Def::SelfTy(..) |
Def::PrimTy(..) | Def::TyParam(..) | Def::SelfTy(..) |
Def::Existential(..) |
Def::Foreign(..) => true,
Def::TyForeign(..) => true,
_ => false,
},
PathSource::Trait(AliasPossibility::No) => match def {
......@@ -2359,7 +2359,7 @@ fn with_type_parameter_rib<'b, F>(&'b mut self, type_parameters: TypeParameters<
seen_bindings.entry(ident).or_insert(param.ident.span);
// Plain insert (no renaming).
let def = Def::Param(self.definitions.local_def_id(param.id));
let def = Def::TyParam(self.definitions.local_def_id(param.id));
function_type_rib.bindings.insert(ident, def);
self.record_def(param.id, PathResolution::new(def));
}
......@@ -3765,7 +3765,7 @@ fn adjust_local_def(&mut self,
}
}
}
Def::Param(..) | Def::SelfTy(..) => {
Def::TyParam(..) | Def::SelfTy(..) => {
for rib in ribs {
match rib.kind {
NormalRibKind | TraitOrImplItemRibKind | ClosureRibKind(..) |
......
......@@ -747,13 +747,13 @@ fn fn_type(path: &ast::Path) -> bool {
HirDef::Union(def_id) |
HirDef::Enum(def_id) |
HirDef::TyAlias(def_id) |
HirDef::Foreign(def_id) |
HirDef::TyForeign(def_id) |
HirDef::TraitAlias(def_id) |
HirDef::AssociatedExistential(def_id) |
HirDef::AssociatedTy(def_id) |
HirDef::Trait(def_id) |
HirDef::Existential(def_id) |
HirDef::Param(def_id) => {
HirDef::TyParam(def_id) => {
let span = self.span_from_span(sub_span);
Some(Ref {
kind: RefKind::Type,
......
......@@ -1240,7 +1240,7 @@ pub fn associated_path_def_to_ty(&self,
}
}
(&ty::Param(_), Def::SelfTy(Some(param_did), None)) |
(&ty::Param(_), Def::Param(param_did)) => {
(&ty::Param(_), Def::TyParam(param_did)) => {
match self.find_bound_for_assoc_item(param_did, assoc_name, span) {
Ok(bound) => bound,
Err(ErrorReported) => return (tcx.types.err, Def::Err),
......@@ -1387,7 +1387,7 @@ pub fn def_to_ty(&self,
)
}
Def::Enum(did) | Def::TyAlias(did) | Def::Struct(did) |
Def::Union(did) | Def::Foreign(did) => {
Def::Union(did) | Def::TyForeign(did) => {
assert_eq!(opt_self_ty, None);
self.prohibit_generics(path.segments.split_last().unwrap().1);
self.ast_path_to_ty(span, did, path.segments.last().unwrap())
......@@ -1401,7 +1401,7 @@ pub fn def_to_ty(&self,
tcx.parent_def_id(did).unwrap(),
path.segments.last().unwrap())
}
Def::Param(did) => {
Def::TyParam(did) => {
assert_eq!(opt_self_ty, None);
self.prohibit_generics(&path.segments);
......
......@@ -830,7 +830,7 @@ fn visit_ty(&mut self, ty: &'v hir::Ty) {
hir::intravisit::walk_ty(self, ty);
match ty.node {
hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => {
if let hir::def::Def::Param(def_id) = path.def {
if let hir::def::Def::TyParam(def_id) = path.def {
if def_id == self.1 {
self.0 = Some(ty.span);
}
......
......@@ -350,7 +350,7 @@ fn is_param<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node {
match path.def {
Def::SelfTy(Some(def_id), None) |
Def::Param(def_id) => {
Def::TyParam(def_id) => {
def_id == tcx.hir.local_def_id(param_id)
}
_ => false
......
......@@ -83,7 +83,7 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa
ret.extend(build_impls(cx, did, true));
clean::EnumItem(build_enum(cx, did))
}
Def::Foreign(did) => {
Def::TyForeign(did) => {
record_extern_fqn(cx, did, clean::TypeKind::Foreign);
ret.extend(build_impls(cx, did, false));
clean::ForeignTypeItem
......
......@@ -2411,7 +2411,7 @@ fn clean(&self, cx: &DocContext) -> Type {
return new_ty;
}
if let Def::Param(did) = path.def {
if let Def::TyParam(did) = path.def {
if let Some(bounds) = cx.impl_trait_bounds.borrow_mut().remove(&did) {
return ImplTrait(bounds);
}
......@@ -2460,7 +2460,7 @@ fn clean(&self, cx: &DocContext) -> Type {
}
hir::GenericParamKind::Type { ref default, .. } => {
let ty_param_def =
Def::Param(cx.tcx.hir.local_def_id(param.id));
Def::TyParam(cx.tcx.hir.local_def_id(param.id));
let mut j = 0;
let type_ = generic_args.args.iter().find_map(|arg| {
match arg {
......@@ -3710,10 +3710,10 @@ fn resolve_type(cx: &DocContext,
Def::SelfTy(..) if path.segments.len() == 1 => {
return Generic(keywords::SelfType.name().to_string());
}
Def::Param(..) if path.segments.len() == 1 => {
Def::TyParam(..) if path.segments.len() == 1 => {
return Generic(format!("{:#}", path));
}
Def::SelfTy(..) | Def::Param(..) | Def::AssociatedTy(..) => true,
Def::SelfTy(..) | Def::TyParam(..) | Def::AssociatedTy(..) => true,
_ => false,
};
let did = register_def(&*cx, path.def);
......@@ -3731,7 +3731,7 @@ pub fn register_def(cx: &DocContext, def: Def) -> DefId {
Def::Struct(i) => (i, TypeKind::Struct),
Def::Union(i) => (i, TypeKind::Union),
Def::Mod(i) => (i, TypeKind::Module),
Def::Foreign(i) => (i, TypeKind::Foreign),
Def::TyForeign(i) => (i, TypeKind::Foreign),
Def::Const(i) => (i, TypeKind::Const),
Def::Static(i, _) => (i, TypeKind::Static),
Def::Variant(i) => (cx.tcx.parent_def_id(i).expect("cannot get parent def id"),
......
......@@ -234,7 +234,7 @@ pub fn ty_param_to_ty(&self, param: ty::GenericParamDef) -> hir::Ty {
None,
P(hir::Path {
span: DUMMY_SP,
def: Def::Param(param.def_id),
def: Def::TyParam(param.def_id),
segments: HirVec::from_vec(vec![
hir::PathSegment::from_ident(Ident::from_interned_str(param.name))
]),
......
......@@ -267,7 +267,7 @@ fn inherits_doc_hidden(cx: &core::DocContext, mut node: ast::NodeId) -> bool {
Def::Struct(did) |
Def::Union(did) |
Def::Enum(did) |
Def::Foreign(did) |
Def::TyForeign(did) |
Def::TyAlias(did) if !self_is_hidden => {
self.cx.access_levels.borrow_mut().map.insert(did, AccessLevel::Public);
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册