Rename GenericParam to GenericParamDef
This commit is contained in:
parent
15d2759d90
commit
178a8f1139
8 changed files with 38 additions and 38 deletions
|
@ -753,7 +753,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::Generics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_stable_hash_for!(enum ty::GenericParam {
|
impl_stable_hash_for!(enum ty::GenericParamDef {
|
||||||
Lifetime(lt),
|
Lifetime(lt),
|
||||||
Type(ty)
|
Type(ty)
|
||||||
});
|
});
|
||||||
|
|
|
@ -758,16 +758,16 @@ impl ty::EarlyBoundRegion {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||||
pub enum GenericParam {
|
pub enum GenericParamDef {
|
||||||
Lifetime(RegionParameterDef),
|
Lifetime(RegionParameterDef),
|
||||||
Type(TypeParameterDef),
|
Type(TypeParameterDef),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GenericParam {
|
impl GenericParamDef {
|
||||||
pub fn index(&self) -> u32 {
|
pub fn index(&self) -> u32 {
|
||||||
match self {
|
match self {
|
||||||
GenericParam::Lifetime(lt) => lt.index,
|
GenericParamDef::Lifetime(lt) => lt.index,
|
||||||
GenericParam::Type(ty) => ty.index,
|
GenericParamDef::Type(ty) => ty.index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -785,7 +785,7 @@ impl GenericParam {
|
||||||
pub struct Generics {
|
pub struct Generics {
|
||||||
pub parent: Option<DefId>,
|
pub parent: Option<DefId>,
|
||||||
pub parent_count: usize,
|
pub parent_count: usize,
|
||||||
pub params: Vec<GenericParam>,
|
pub params: Vec<GenericParamDef>,
|
||||||
|
|
||||||
/// Reverse map to each `TypeParameterDef`'s `index` field
|
/// Reverse map to each `TypeParameterDef`'s `index` field
|
||||||
pub type_param_to_index: FxHashMap<DefId, u32>,
|
pub type_param_to_index: FxHashMap<DefId, u32>,
|
||||||
|
@ -801,7 +801,7 @@ impl<'a, 'gcx, 'tcx> Generics {
|
||||||
|
|
||||||
pub fn lifetimes(&self) -> impl DoubleEndedIterator<Item = &RegionParameterDef> {
|
pub fn lifetimes(&self) -> impl DoubleEndedIterator<Item = &RegionParameterDef> {
|
||||||
self.params.iter().filter_map(|p| {
|
self.params.iter().filter_map(|p| {
|
||||||
if let GenericParam::Lifetime(lt) = p {
|
if let GenericParamDef::Lifetime(lt) = p {
|
||||||
Some(lt)
|
Some(lt)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -811,7 +811,7 @@ impl<'a, 'gcx, 'tcx> Generics {
|
||||||
|
|
||||||
pub fn types(&self) -> impl DoubleEndedIterator<Item = &TypeParameterDef> {
|
pub fn types(&self) -> impl DoubleEndedIterator<Item = &TypeParameterDef> {
|
||||||
self.params.iter().filter_map(|p| {
|
self.params.iter().filter_map(|p| {
|
||||||
if let GenericParam::Type(ty) = p {
|
if let GenericParamDef::Type(ty) = p {
|
||||||
Some(ty)
|
Some(ty)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -821,7 +821,7 @@ impl<'a, 'gcx, 'tcx> Generics {
|
||||||
|
|
||||||
pub fn requires_monomorphization(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
|
pub fn requires_monomorphization(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
|
||||||
if self.params.iter().any(|p| {
|
if self.params.iter().any(|p| {
|
||||||
if let GenericParam::Type(_) = p { true } else { false }
|
if let GenericParamDef::Type(_) = p { true } else { false }
|
||||||
}) {
|
}) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -841,7 +841,7 @@ impl<'a, 'gcx, 'tcx> Generics {
|
||||||
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
|
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
|
||||||
// We're currently assuming that lifetimes precede other generic parameters.
|
// We're currently assuming that lifetimes precede other generic parameters.
|
||||||
match self.params[index as usize - self.has_self as usize] {
|
match self.params[index as usize - self.has_self as usize] {
|
||||||
ty::GenericParam::Lifetime(ref lt) => lt,
|
ty::GenericParamDef::Lifetime(ref lt) => lt,
|
||||||
_ => bug!("expected region parameter, but found another generic parameter")
|
_ => bug!("expected region parameter, but found another generic parameter")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -891,13 +891,13 @@ impl<'a, 'gcx, 'tcx> Generics {
|
||||||
if let Some(_) = (idx as usize).checked_sub(type_param_offset) {
|
if let Some(_) = (idx as usize).checked_sub(type_param_offset) {
|
||||||
assert!(!is_separated_self, "found a Self after type_param_offset");
|
assert!(!is_separated_self, "found a Self after type_param_offset");
|
||||||
match self.params[idx as usize] {
|
match self.params[idx as usize] {
|
||||||
ty::GenericParam::Type(ref ty) => ty,
|
ty::GenericParamDef::Type(ref ty) => ty,
|
||||||
_ => bug!("expected type parameter, but found another generic parameter")
|
_ => bug!("expected type parameter, but found another generic parameter")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert!(is_separated_self, "non-Self param before type_param_offset");
|
assert!(is_separated_self, "non-Self param before type_param_offset");
|
||||||
match self.params[type_param_offset] {
|
match self.params[type_param_offset] {
|
||||||
ty::GenericParam::Type(ref ty) => ty,
|
ty::GenericParamDef::Type(ref ty) => ty,
|
||||||
_ => bug!("expected type parameter, but found another generic parameter")
|
_ => bug!("expected type parameter, but found another generic parameter")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,10 +253,10 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
|
||||||
|
|
||||||
for def in &defs.params {
|
for def in &defs.params {
|
||||||
let param = match def {
|
let param = match def {
|
||||||
ty::GenericParam::Lifetime(ref lt) => {
|
ty::GenericParamDef::Lifetime(ref lt) => {
|
||||||
mk_region(lt, substs).into()
|
mk_region(lt, substs).into()
|
||||||
}
|
}
|
||||||
ty::GenericParam::Type(ref ty) => {
|
ty::GenericParamDef::Type(ref ty) => {
|
||||||
if skip_self {
|
if skip_self {
|
||||||
skip_self = false;
|
skip_self = false;
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -970,8 +970,8 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
.map(|param| (param.def_id, param.index))
|
.map(|param| (param.def_id, param.index))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let lifetimes = regions.into_iter().map(|lt| ty::GenericParam::Lifetime(lt));
|
let lifetimes = regions.into_iter().map(|lt| ty::GenericParamDef::Lifetime(lt));
|
||||||
let types = types.into_iter().map(|ty| ty::GenericParam::Type(ty));
|
let types = types.into_iter().map(|ty| ty::GenericParamDef::Type(ty));
|
||||||
let params = lifetimes.chain(types).collect();
|
let params = lifetimes.chain(types).collect();
|
||||||
|
|
||||||
tcx.alloc_generics(ty::Generics {
|
tcx.alloc_generics(ty::Generics {
|
||||||
|
|
|
@ -491,7 +491,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'b, 'c, 'd>,
|
tcx: TyCtxt<'b, 'c, 'd>,
|
||||||
pred: ty::Predicate<'d>,
|
pred: ty::Predicate<'d>,
|
||||||
) -> FxHashSet<GenericParam> {
|
) -> FxHashSet<GenericParamDef> {
|
||||||
pred.walk_tys()
|
pred.walk_tys()
|
||||||
.flat_map(|t| {
|
.flat_map(|t| {
|
||||||
let mut regions = FxHashSet();
|
let mut regions = FxHashSet();
|
||||||
|
@ -502,7 +502,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||||
// We only care about late bound regions, as we need to add them
|
// We only care about late bound regions, as we need to add them
|
||||||
// to the 'for<>' section
|
// to the 'for<>' section
|
||||||
&ty::ReLateBound(_, ty::BoundRegion::BrNamed(_, name)) => {
|
&ty::ReLateBound(_, ty::BoundRegion::BrNamed(_, name)) => {
|
||||||
Some(GenericParam::Lifetime(Lifetime(name.to_string())))
|
Some(GenericParamDef::Lifetime(Lifetime(name.to_string())))
|
||||||
}
|
}
|
||||||
&ty::ReVar(_) | &ty::ReEarlyBound(_) => None,
|
&ty::ReVar(_) | &ty::ReEarlyBound(_) => None,
|
||||||
_ => panic!("Unexpected region type {:?}", r),
|
_ => panic!("Unexpected region type {:?}", r),
|
||||||
|
@ -850,7 +850,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||||
|
|
||||||
for p in generic_params.iter_mut() {
|
for p in generic_params.iter_mut() {
|
||||||
match p {
|
match p {
|
||||||
&mut GenericParam::Type(ref mut ty) => {
|
&mut GenericParamDef::Type(ref mut ty) => {
|
||||||
// We never want something like 'impl<T=Foo>'
|
// We never want something like 'impl<T=Foo>'
|
||||||
ty.default.take();
|
ty.default.take();
|
||||||
|
|
||||||
|
|
|
@ -1484,7 +1484,7 @@ impl<'a, 'tcx> Clean<TyParamBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>
|
||||||
if let &ty::RegionKind::ReLateBound(..) = *reg {
|
if let &ty::RegionKind::ReLateBound(..) = *reg {
|
||||||
debug!(" hit an ReLateBound {:?}", reg);
|
debug!(" hit an ReLateBound {:?}", reg);
|
||||||
if let Some(lt) = reg.clean(cx) {
|
if let Some(lt) = reg.clean(cx) {
|
||||||
late_bounds.push(GenericParam::Lifetime(lt));
|
late_bounds.push(GenericParamDef::Lifetime(lt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1718,14 +1718,14 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
|
||||||
pub enum GenericParam {
|
pub enum GenericParamDef {
|
||||||
Lifetime(Lifetime),
|
Lifetime(Lifetime),
|
||||||
Type(TyParam),
|
Type(TyParam),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GenericParam {
|
impl GenericParamDef {
|
||||||
pub fn is_synthetic_type_param(&self) -> bool {
|
pub fn is_synthetic_type_param(&self) -> bool {
|
||||||
if let GenericParam::Type(ref t) = *self {
|
if let GenericParamDef::Type(ref t) = *self {
|
||||||
t.synthetic.is_some()
|
t.synthetic.is_some()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -1733,11 +1733,11 @@ impl GenericParam {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<GenericParam> for hir::GenericParam {
|
impl Clean<GenericParamDef> for hir::GenericParam {
|
||||||
fn clean(&self, cx: &DocContext) -> GenericParam {
|
fn clean(&self, cx: &DocContext) -> GenericParamDef {
|
||||||
match *self {
|
match *self {
|
||||||
hir::GenericParam::Lifetime(ref l) => GenericParam::Lifetime(l.clean(cx)),
|
hir::GenericParam::Lifetime(ref l) => GenericParamDef::Lifetime(l.clean(cx)),
|
||||||
hir::GenericParam::Type(ref t) => GenericParam::Type(t.clean(cx)),
|
hir::GenericParam::Type(ref t) => GenericParamDef::Type(t.clean(cx)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1745,7 +1745,7 @@ impl Clean<GenericParam> for hir::GenericParam {
|
||||||
// maybe use a Generic enum and use Vec<Generic>?
|
// maybe use a Generic enum and use Vec<Generic>?
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Default, Hash)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Default, Hash)]
|
||||||
pub struct Generics {
|
pub struct Generics {
|
||||||
pub params: Vec<GenericParam>,
|
pub params: Vec<GenericParamDef>,
|
||||||
pub where_predicates: Vec<WherePredicate>,
|
pub where_predicates: Vec<WherePredicate>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1774,7 +1774,7 @@ impl Clean<Generics> for hir::Generics {
|
||||||
WherePredicate::BoundPredicate { ty: Generic(ref name), ref mut bounds } => {
|
WherePredicate::BoundPredicate { ty: Generic(ref name), ref mut bounds } => {
|
||||||
if bounds.is_empty() {
|
if bounds.is_empty() {
|
||||||
for param in &mut g.params {
|
for param in &mut g.params {
|
||||||
if let GenericParam::Type(ref mut type_param) = *param {
|
if let GenericParamDef::Type(ref mut type_param) = *param {
|
||||||
if &type_param.name == name {
|
if &type_param.name == name {
|
||||||
mem::swap(bounds, &mut type_param.bounds);
|
mem::swap(bounds, &mut type_param.bounds);
|
||||||
break
|
break
|
||||||
|
@ -1851,11 +1851,11 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
|
||||||
Generics {
|
Generics {
|
||||||
params: gens.lifetimes()
|
params: gens.lifetimes()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|lp| GenericParam::Lifetime(lp.clean(cx)))
|
.map(|lp| GenericParamDef::Lifetime(lp.clean(cx)))
|
||||||
.chain(
|
.chain(
|
||||||
simplify::ty_params(stripped_typarams)
|
simplify::ty_params(stripped_typarams)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|tp| GenericParam::Type(tp))
|
.map(|tp| GenericParamDef::Type(tp))
|
||||||
)
|
)
|
||||||
.collect(),
|
.collect(),
|
||||||
where_predicates: simplify::where_clauses(cx, where_predicates),
|
where_predicates: simplify::where_clauses(cx, where_predicates),
|
||||||
|
@ -2348,7 +2348,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
|
||||||
pub struct PolyTrait {
|
pub struct PolyTrait {
|
||||||
pub trait_: Type,
|
pub trait_: Type,
|
||||||
pub generic_params: Vec<GenericParam>,
|
pub generic_params: Vec<GenericParamDef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
|
/// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
|
||||||
|
@ -3413,7 +3413,7 @@ impl Clean<Item> for doctree::Typedef {
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
|
||||||
pub struct BareFunctionDecl {
|
pub struct BareFunctionDecl {
|
||||||
pub unsafety: hir::Unsafety,
|
pub unsafety: hir::Unsafety,
|
||||||
pub generic_params: Vec<GenericParam>,
|
pub generic_params: Vec<GenericParamDef>,
|
||||||
pub decl: FnDecl,
|
pub decl: FnDecl,
|
||||||
pub abi: Abi,
|
pub abi: Abi,
|
||||||
}
|
}
|
||||||
|
@ -4172,7 +4172,7 @@ struct RegionDeps<'tcx> {
|
||||||
#[derive(Eq, PartialEq, Hash, Debug)]
|
#[derive(Eq, PartialEq, Hash, Debug)]
|
||||||
enum SimpleBound {
|
enum SimpleBound {
|
||||||
RegionBound(Lifetime),
|
RegionBound(Lifetime),
|
||||||
TraitBound(Vec<PathSegment>, Vec<SimpleBound>, Vec<GenericParam>, hir::TraitBoundModifier)
|
TraitBound(Vec<PathSegment>, Vec<SimpleBound>, Vec<GenericParamDef>, hir::TraitBoundModifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AutoTraitResult {
|
enum AutoTraitResult {
|
||||||
|
|
|
@ -117,11 +117,11 @@ impl<'a> fmt::Display for TyParamBounds<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for clean::GenericParam {
|
impl fmt::Display for clean::GenericParamDef {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
clean::GenericParam::Lifetime(ref lp) => write!(f, "{}", lp),
|
clean::GenericParamDef::Lifetime(ref lp) => write!(f, "{}", lp),
|
||||||
clean::GenericParam::Type(ref tp) => {
|
clean::GenericParamDef::Type(ref tp) => {
|
||||||
f.write_str(&tp.name)?;
|
f.write_str(&tp.name)?;
|
||||||
|
|
||||||
if !tp.bounds.is_empty() {
|
if !tp.bounds.is_empty() {
|
||||||
|
|
|
@ -1437,7 +1437,7 @@ impl DocFolder for Cache {
|
||||||
impl<'a> Cache {
|
impl<'a> Cache {
|
||||||
fn generics(&mut self, generics: &clean::Generics) {
|
fn generics(&mut self, generics: &clean::Generics) {
|
||||||
for param in &generics.params {
|
for param in &generics.params {
|
||||||
if let clean::GenericParam::Type(ref typ) = *param {
|
if let clean::GenericParamDef::Type(ref typ) = *param {
|
||||||
self.typarams.insert(typ.did, typ.name.clone());
|
self.typarams.insert(typ.did, typ.name.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue