} else {
0
};
- let mut type_count = 0;
- let lifetimes = generics
- .params
- .iter()
- .filter_map(|param| match param.kind {
- GenericParamKind::Lifetime { .. } => {
- Some(Region::early(&self.tcx.hir(), &mut index, param))
- }
- GenericParamKind::Type { .. } => {
- type_count += 1;
- None
- }
- })
- .collect();
+ let mut non_lifetime_count = 0;
+ let lifetimes = generics.params.iter().filter_map(|param| match param.kind {
+ GenericParamKind::Lifetime { .. } => {
+ Some(Region::early(&self.tcx.hir(), &mut index, param))
+ }
+ GenericParamKind::Type { .. } |
+ GenericParamKind::Const { .. } => {
+ non_lifetime_count += 1;
+ None
+ }
+ }).collect();
let scope = Scope::Binder {
lifetimes,
- next_early_index: index + type_count,
+ next_early_index: index + non_lifetime_count,
abstract_type_parent: true,
track_lifetime_uses,
s: ROOT_SCOPE,
let mut elision = None;
let mut lifetimes = FxHashMap::default();
- let mut type_count = 0;
+ let mut non_lifetime_count = 0;
for param in &generics.params {
match param.kind {
GenericParamKind::Lifetime { .. } => {
lifetimes.insert(name, reg);
}
}
- GenericParamKind::Type { .. } => {
- type_count += 1;
+ GenericParamKind::Type { .. } |
+ GenericParamKind::Const { .. } => {
+ non_lifetime_count += 1;
}
}
}
- let next_early_index = index + type_count;
+ let next_early_index = index + non_lifetime_count;
if let Some(elision_region) = elision {
let scope = Scope::Elision {
let generics = &trait_item.generics;
let mut index = self.next_early_index();
debug!("visit_ty: index = {}", index);
- let mut type_count = 0;
- let lifetimes = generics
- .params
- .iter()
- .filter_map(|param| match param.kind {
- GenericParamKind::Lifetime { .. } => {
- Some(Region::early(&self.tcx.hir(), &mut index, param))
- }
- GenericParamKind::Type { .. } => {
- type_count += 1;
- None
- }
- })
- .collect();
+ let mut non_lifetime_count = 0;
+ let lifetimes = generics.params.iter().filter_map(|param| match param.kind {
+ GenericParamKind::Lifetime { .. } => {
+ Some(Region::early(&self.tcx.hir(), &mut index, param))
+ }
+ GenericParamKind::Type { .. } |
+ GenericParamKind::Const { .. } => {
+ non_lifetime_count += 1;
+ None
+ }
+ }).collect();
let scope = Scope::Binder {
lifetimes,
- next_early_index: index + type_count,
+ next_early_index: index + non_lifetime_count,
s: self.scope,
track_lifetime_uses: true,
abstract_type_parent: true,
Type(ref ty) => {
let generics = &impl_item.generics;
let mut index = self.next_early_index();
- let mut next_early_index = index;
+ let mut non_lifetime_count = 0;
debug!("visit_ty: index = {}", index);
- let lifetimes = generics
- .params
- .iter()
- .filter_map(|param| match param.kind {
- GenericParamKind::Lifetime { .. } => {
- Some(Region::early(&self.tcx.hir(), &mut index, param))
- }
- GenericParamKind::Type { .. } => {
- next_early_index += 1;
- None
- }
- })
- .collect();
+ let lifetimes = generics.params.iter().filter_map(|param| match param.kind {
+ GenericParamKind::Lifetime { .. } => {
+ Some(Region::early(&self.tcx.hir(), &mut index, param))
+ }
+ GenericParamKind::Const { .. } |
+ GenericParamKind::Type { .. } => {
+ non_lifetime_count += 1;
+ None
+ }
+ }).collect();
let scope = Scope::Binder {
lifetimes,
- next_early_index,
+ next_early_index: index + non_lifetime_count,
s: self.scope,
track_lifetime_uses: true,
abstract_type_parent: true,
let mut index = self.next_early_index();
let mut next_early_index = index;
debug!("visit_ty: index = {}", index);
- let lifetimes = generics
- .params
- .iter()
- .filter_map(|param| match param.kind {
- GenericParamKind::Lifetime { .. } => {
- Some(Region::early(&self.tcx.hir(), &mut index, param))
- }
- GenericParamKind::Type { .. } => {
- next_early_index += 1;
- None
- }
- })
- .collect();
+ let lifetimes = generics.params.iter().filter_map(|param| match param.kind {
+ GenericParamKind::Lifetime { .. } => {
+ Some(Region::early(&self.tcx.hir(), &mut index, param))
+ }
+ GenericParamKind::Type { .. } => {
+ next_early_index += 1;
+ None
+ }
+ GenericParamKind::Const { .. } => {
+ next_early_index += 1;
+ None
+ }
+ }).collect();
let scope = Scope::Binder {
lifetimes,
self.visit_ty(&ty);
}
}
+ GenericParamKind::Const { ref ty, .. } => {
+ walk_list!(self, visit_param_bound, ¶m.bounds);
+ self.visit_ty(&ty);
+ }
}
}
for predicate in &generics.where_clause.predicates {
Set1::Many => Set1::Many,
})
}
+ GenericParamKind::Const { .. } => {
+ // Generic consts don't impose any constraints.
+ None
+ }
})
.collect()
}
}
}
- let mut type_count = 0;
- let lifetimes = generics
- .params
- .iter()
- .filter_map(|param| match param.kind {
- GenericParamKind::Lifetime { .. } => {
- if self.map.late_bound.contains(¶m.id) {
- Some(Region::late(&self.tcx.hir(), param))
- } else {
- Some(Region::early(&self.tcx.hir(), &mut index, param))
- }
- }
- GenericParamKind::Type { .. } => {
- type_count += 1;
- None
+ let mut non_lifetime_count = 0;
+ let lifetimes = generics.params.iter().filter_map(|param| match param.kind {
+ GenericParamKind::Lifetime { .. } => {
+ if self.map.late_bound.contains(¶m.id) {
+ Some(Region::late(&self.tcx.hir(), param))
+ } else {
+ Some(Region::early(&self.tcx.hir(), &mut index, param))
}
- })
- .collect();
- let next_early_index = index + type_count;
+ }
+ GenericParamKind::Type { .. } |
+ GenericParamKind::Const { .. } => {
+ non_lifetime_count += 1;
+ None
+ }
+ }).collect();
+ let next_early_index = index + non_lifetime_count;
let scope = Scope::Binder {
lifetimes,
}
i += 1;
}
+ GenericArg::Const(ct) => {
+ self.visit_anon_const(&ct.value);
+ }
}
}
match param.kind {
hir::GenericParamKind::Lifetime { .. } => { /* fall through */ }
- // Types are not late-bound.
- hir::GenericParamKind::Type { .. } => continue,
+ // Neither types nor consts are late-bound.
+ hir::GenericParamKind::Type { .. }
+ | hir::GenericParamKind::Const { .. } => continue,
}
let lt_name = hir::LifetimeName::Param(param.name.modern());