Prefer iterator to vec
This commit is contained in:
parent
e9e3d5703b
commit
e5825c29c3
21 changed files with 55 additions and 64 deletions
|
@ -1459,10 +1459,9 @@ impl<'a> LoweringContext<'a> {
|
|||
return n;
|
||||
}
|
||||
assert!(!def_id.is_local());
|
||||
let n = self.cstore
|
||||
.item_generics_cloned_untracked(def_id, self.sess)
|
||||
.lifetimes()
|
||||
.len();
|
||||
let item_generics =
|
||||
self.cstore.item_generics_cloned_untracked(def_id, self.sess);
|
||||
let n = item_generics.lifetimes().count();
|
||||
self.type_def_lifetime_params.insert(def_id, n);
|
||||
n
|
||||
});
|
||||
|
|
|
@ -1660,7 +1660,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
.or_insert_with(|| {
|
||||
tcx.generics_of(def_id)
|
||||
.types()
|
||||
.iter()
|
||||
.map(|def| def.object_lifetime_default)
|
||||
.collect()
|
||||
})
|
||||
|
|
|
@ -378,7 +378,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
flags.push(("_Self".to_string(), Some(self.tcx.type_of(def.did).to_string())));
|
||||
}
|
||||
|
||||
for param in generics.types().iter() {
|
||||
for param in generics.types() {
|
||||
let name = param.name.to_string();
|
||||
let ty = trait_ref.substs.type_for_def(param);
|
||||
let ty_str = ty.to_string();
|
||||
|
|
|
@ -284,7 +284,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// We can't monomorphize things like `fn foo<A>(...)`.
|
||||
if !self.generics_of(method.def_id).types().is_empty() {
|
||||
if self.generics_of(method.def_id).types().count() != 0 {
|
||||
return Some(MethodViolationCode::Generic);
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
|
|||
let name = tcx.item_name(trait_def_id);
|
||||
let generics = tcx.generics_of(trait_def_id);
|
||||
let parser = Parser::new(&self.0);
|
||||
let types = generics.types();
|
||||
let mut types = generics.types();
|
||||
let mut result = Ok(());
|
||||
for token in parser {
|
||||
match token {
|
||||
|
@ -254,7 +254,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
|
|||
// `{ThisTraitsName}` is allowed
|
||||
Position::ArgumentNamed(s) if s == name => (),
|
||||
// So is `{A}` if A is a type parameter
|
||||
Position::ArgumentNamed(s) => match types.iter().find(|t| {
|
||||
Position::ArgumentNamed(s) => match types.find(|t| {
|
||||
t.name == s
|
||||
}) {
|
||||
Some(_) => (),
|
||||
|
@ -288,7 +288,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
|
|||
let name = tcx.item_name(trait_ref.def_id);
|
||||
let trait_str = tcx.item_path_str(trait_ref.def_id);
|
||||
let generics = tcx.generics_of(trait_ref.def_id);
|
||||
let generic_map = generics.types().iter().map(|param| {
|
||||
let generic_map = generics.types().map(|param| {
|
||||
(param.name.to_string(),
|
||||
trait_ref.substs.type_for_def(param).to_string())
|
||||
}).collect::<FxHashMap<String, String>>();
|
||||
|
|
|
@ -803,28 +803,28 @@ impl<'a, 'gcx, 'tcx> Generics {
|
|||
self.parent_count + self.own_count()
|
||||
}
|
||||
|
||||
pub fn lifetimes(&self) -> Vec<&RegionParameterDef> {
|
||||
pub fn lifetimes(&self) -> impl DoubleEndedIterator<Item = &RegionParameterDef> {
|
||||
self.params.iter().filter_map(|p| {
|
||||
if let GenericParam::Lifetime(lt) = p {
|
||||
Some(lt)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).collect()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn types(&self) -> Vec<&TypeParameterDef> {
|
||||
pub fn types(&self) -> impl DoubleEndedIterator<Item = &TypeParameterDef> {
|
||||
self.params.iter().filter_map(|p| {
|
||||
if let GenericParam::Type(ty) = p {
|
||||
Some(ty)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).collect()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn has_type_parameters(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
|
||||
if self.types().len() != 0 {
|
||||
if self.types().count() != 0 {
|
||||
return true;
|
||||
}
|
||||
if let Some(parent_def_id) = self.parent {
|
||||
|
@ -885,7 +885,7 @@ impl<'a, 'gcx, 'tcx> Generics {
|
|||
// And it can be seen that in both cases, to move from a substs
|
||||
// offset to a generics offset you just have to offset by the
|
||||
// number of regions.
|
||||
let type_param_offset = self.lifetimes().len();
|
||||
let type_param_offset = self.lifetimes().count();
|
||||
|
||||
let has_self = self.has_self && self.parent.is_none();
|
||||
let is_separated_self = type_param_offset != 0 && idx == 0 && has_self;
|
||||
|
|
|
@ -242,8 +242,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
|
|||
where FR: FnMut(&ty::RegionParameterDef, &[Kind<'tcx>]) -> ty::Region<'tcx>,
|
||||
FT: FnMut(&ty::TypeParameterDef, &[Kind<'tcx>]) -> Ty<'tcx> {
|
||||
// Handle Self first, before all regions.
|
||||
let types = defs.types();
|
||||
let mut types = types.iter();
|
||||
let mut types = defs.types();
|
||||
let mut skip_self = defs.parent.is_none() && defs.has_self;
|
||||
if skip_self {
|
||||
let def = types.next().unwrap();
|
||||
|
|
|
@ -310,10 +310,10 @@ impl PrintContext {
|
|||
if let Some(def_id) = generics.parent {
|
||||
// Methods.
|
||||
assert!(is_value_path);
|
||||
child_types = generics.types().len();
|
||||
child_types = generics.types().count();
|
||||
generics = tcx.generics_of(def_id);
|
||||
num_regions = generics.lifetimes().len();
|
||||
num_types = generics.types().len();
|
||||
num_regions = generics.lifetimes().count();
|
||||
num_types = generics.types().count();
|
||||
|
||||
if has_self {
|
||||
print!(f, self, write("<"), print_display(substs.type_at(0)), write(" as "))?;
|
||||
|
@ -328,8 +328,8 @@ impl PrintContext {
|
|||
assert_eq!(has_self, false);
|
||||
} else {
|
||||
// Types and traits.
|
||||
num_regions = generics.lifetimes().len();
|
||||
num_types = generics.types().len();
|
||||
num_regions = generics.lifetimes().count();
|
||||
num_types = generics.types().count();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ impl PrintContext {
|
|||
if generics.types().last().map_or(false, |def| def.has_default) {
|
||||
if let Some(substs) = tcx.lift(&substs) {
|
||||
let tps = substs.types().rev().skip(child_types);
|
||||
for (def, actual) in generics.types().iter().rev().zip(tps) {
|
||||
for (def, actual) in generics.types().rev().zip(tps) {
|
||||
if !def.has_default {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1108,7 +1108,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
continue;
|
||||
}
|
||||
|
||||
if !tcx.generics_of(method.def_id).types().is_empty() {
|
||||
if tcx.generics_of(method.def_id).types().count() != 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -357,7 +357,7 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
|
|||
|
||||
// FIXME: when we make this a hard error, this should have its
|
||||
// own error code.
|
||||
let message = if !tcx.generics_of(def_id).types().is_empty() {
|
||||
let message = if tcx.generics_of(def_id).types().count() != 0 {
|
||||
format!("#[derive] can't be used on a #[repr(packed)] struct with \
|
||||
type parameters (error E0133)")
|
||||
} else {
|
||||
|
|
|
@ -399,7 +399,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
|||
|
||||
impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> {
|
||||
fn generics(&mut self) -> &mut Self {
|
||||
for def in &self.ev.tcx.generics_of(self.item_def_id).types() {
|
||||
for def in self.ev.tcx.generics_of(self.item_def_id).types() {
|
||||
if def.has_default {
|
||||
self.ev.tcx.type_of(def.def_id).visit_with(self);
|
||||
}
|
||||
|
@ -1335,7 +1335,7 @@ struct SearchInterfaceForPrivateItemsVisitor<'a, 'tcx: 'a> {
|
|||
|
||||
impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
|
||||
fn generics(&mut self) -> &mut Self {
|
||||
for def in &self.tcx.generics_of(self.item_def_id).types() {
|
||||
for def in self.tcx.generics_of(self.item_def_id).types() {
|
||||
if def.has_default {
|
||||
self.tcx.type_of(def.def_id).visit_with(self);
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
let mut names = generics.parent.map_or(vec![], |def_id| {
|
||||
get_type_parameter_names(cx, cx.tcx.generics_of(def_id))
|
||||
});
|
||||
names.extend(generics.types().iter().map(|param| param.name));
|
||||
names.extend(generics.types().map(|param| param.name));
|
||||
names
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
|||
// whatever & would get replaced with).
|
||||
let decl_generics = tcx.generics_of(def_id);
|
||||
let num_types_provided = parameters.types.len();
|
||||
let expected_num_region_params = decl_generics.lifetimes().len();
|
||||
let expected_num_region_params = decl_generics.lifetimes().count();
|
||||
let supplied_num_region_params = parameters.lifetimes.len();
|
||||
if expected_num_region_params != supplied_num_region_params {
|
||||
report_lifetime_number_error(tcx, span,
|
||||
|
@ -221,9 +221,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
|||
assert_eq!(decl_generics.has_self, self_ty.is_some());
|
||||
|
||||
// Check the number of type parameters supplied by the user.
|
||||
let ty_param_defs = &decl_generics.types()[self_ty.is_some() as usize..];
|
||||
let ty_param_defs =
|
||||
decl_generics.types().skip(self_ty.is_some() as usize).collect::<Vec<_>>();
|
||||
if !infer_types || num_types_provided > ty_param_defs.len() {
|
||||
check_type_argument_count(tcx, span, num_types_provided, ty_param_defs);
|
||||
check_type_argument_count(tcx, span, num_types_provided, &ty_param_defs);
|
||||
}
|
||||
|
||||
let is_object = self_ty.map_or(false, |ty| ty.sty == TRAIT_OBJECT_DUMMY_SELF);
|
||||
|
@ -254,7 +255,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
|||
return ty;
|
||||
}
|
||||
|
||||
let i = i - self_ty.is_some() as usize - decl_generics.lifetimes().len();
|
||||
let i = i - self_ty.is_some() as usize - decl_generics.lifetimes().count();
|
||||
if i < num_types_provided {
|
||||
// A provided type parameter.
|
||||
self.ast_ty_to_ty(¶meters.types[i])
|
||||
|
|
|
@ -377,7 +377,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// but found 0" it's confusing, because it looks like there
|
||||
// are zero. Since I don't quite know how to phrase things at
|
||||
// the moment, give a kind of vague error message.
|
||||
if trait_params.len() != impl_params.len() {
|
||||
if trait_params.count() != impl_params.count() {
|
||||
let mut err = struct_span_err!(tcx.sess,
|
||||
span,
|
||||
E0195,
|
||||
|
@ -574,8 +574,8 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
-> Result<(), ErrorReported> {
|
||||
let impl_m_generics = tcx.generics_of(impl_m.def_id);
|
||||
let trait_m_generics = tcx.generics_of(trait_m.def_id);
|
||||
let num_impl_m_type_params = impl_m_generics.types().len();
|
||||
let num_trait_m_type_params = trait_m_generics.types().len();
|
||||
let num_impl_m_type_params = impl_m_generics.types().count();
|
||||
let num_trait_m_type_params = trait_m_generics.types().count();
|
||||
if num_impl_m_type_params != num_trait_m_type_params {
|
||||
let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap();
|
||||
let impl_m_item = tcx.hir.expect_impl_item(impl_m_node_id);
|
||||
|
@ -728,7 +728,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
let mut error_found = false;
|
||||
let impl_m_generics = tcx.generics_of(impl_m.def_id);
|
||||
let trait_m_generics = tcx.generics_of(trait_m.def_id);
|
||||
for (impl_ty, trait_ty) in impl_m_generics.types().iter().zip(trait_m_generics.types().iter()) {
|
||||
for (impl_ty, trait_ty) in impl_m_generics.types().zip(trait_m_generics.types()) {
|
||||
if impl_ty.synthetic != trait_ty.synthetic {
|
||||
let impl_node_id = tcx.hir.as_local_node_id(impl_ty.def_id).unwrap();
|
||||
let impl_span = tcx.hir.span(impl_node_id);
|
||||
|
|
|
@ -45,7 +45,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
let i_n_tps = tcx.generics_of(def_id).types().len();
|
||||
let i_n_tps = tcx.generics_of(def_id).types().count();
|
||||
if i_n_tps != n_tps {
|
||||
let span = match it.node {
|
||||
hir::ForeignItemFn(_, _, ref generics) => generics.span,
|
||||
|
@ -346,7 +346,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
};
|
||||
|
||||
let def_id = tcx.hir.local_def_id(it.id);
|
||||
let i_n_tps = tcx.generics_of(def_id).types().len();
|
||||
let i_n_tps = tcx.generics_of(def_id).types().count();
|
||||
let name = it.name.as_str();
|
||||
|
||||
let (n_tps, inputs, output) = match &*name {
|
||||
|
|
|
@ -332,7 +332,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
|||
parent_substs.type_at(i)
|
||||
} else if let Some(ast_ty)
|
||||
= provided.as_ref().and_then(|p| {
|
||||
p.types.get(i - parent_substs.len() - method_generics.lifetimes().len())
|
||||
p.types.get(i - parent_substs.len() - method_generics.lifetimes().count())
|
||||
})
|
||||
{
|
||||
self.to_ty(ast_ty)
|
||||
|
|
|
@ -1239,7 +1239,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
|
|||
} else {
|
||||
for item in &m.items {
|
||||
let generics = tcx.generics_of(tcx.hir.local_def_id(item.id));
|
||||
if !generics.types().is_empty() {
|
||||
if generics.types().count() != 0 {
|
||||
let mut err = struct_span_err!(tcx.sess, item.span, E0044,
|
||||
"foreign items may not have type parameters");
|
||||
err.span_label(item.span, "can't have type parameters");
|
||||
|
@ -4799,7 +4799,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
// Skip over the lifetimes in the same segment.
|
||||
if let Some((_, generics)) = segment {
|
||||
i -= generics.lifetimes().len();
|
||||
i -= generics.lifetimes().count();
|
||||
}
|
||||
|
||||
if let Some(ast_ty) = types.get(i) {
|
||||
|
@ -4920,9 +4920,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
// Check provided type parameters.
|
||||
let type_defs = segment.map_or(vec![], |(_, generics)| {
|
||||
if generics.parent.is_none() {
|
||||
generics.types()[generics.has_self as usize..].to_vec()
|
||||
generics.types().skip(generics.has_self as usize).collect()
|
||||
} else {
|
||||
generics.types()
|
||||
generics.types().collect()
|
||||
}
|
||||
});
|
||||
let required_len = type_defs.iter().take_while(|d| !d.has_default).count();
|
||||
|
@ -4957,7 +4957,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// Check provided lifetime parameters.
|
||||
let lifetime_defs = segment.map_or(vec![], |(_, generics)| generics.lifetimes());
|
||||
let lifetime_defs = segment.map_or(vec![], |(_, generics)| generics.lifetimes().collect());
|
||||
let required_len = lifetime_defs.len();
|
||||
|
||||
// Prohibit explicit lifetime arguments if late bound lifetime parameters are present.
|
||||
|
@ -4968,7 +4968,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let primary_msg = "cannot specify lifetime arguments explicitly \
|
||||
if late bound lifetime parameters are present";
|
||||
let note_msg = "the late bound lifetime parameter is introduced here";
|
||||
if !is_method_call && (lifetimes.len() > lifetime_defs.len() ||
|
||||
if !is_method_call && (lifetimes.len() > required_len ||
|
||||
lifetimes.len() < required_len && !infer_lifetimes) {
|
||||
let mut err = self.tcx.sess.struct_span_err(lifetimes[0].span, primary_msg);
|
||||
err.span_note(span_late, note_msg);
|
||||
|
@ -4983,9 +4983,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
if lifetimes.len() > lifetime_defs.len() {
|
||||
let span = lifetimes[lifetime_defs.len()].span;
|
||||
let expected_text = count_lifetime_params(lifetime_defs.len());
|
||||
if lifetimes.len() > required_len {
|
||||
let span = lifetimes[required_len].span;
|
||||
let expected_text = count_lifetime_params(required_len);
|
||||
let actual_text = count_lifetime_params(lifetimes.len());
|
||||
struct_span_err!(self.tcx.sess, span, E0088,
|
||||
"too many lifetime parameters provided: \
|
||||
|
@ -4994,7 +4994,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
.span_label(span, format!("expected {}", expected_text))
|
||||
.emit();
|
||||
} else if lifetimes.len() < required_len && !infer_lifetimes {
|
||||
let expected_text = count_lifetime_params(lifetime_defs.len());
|
||||
let expected_text = count_lifetime_params(required_len);
|
||||
let actual_text = count_lifetime_params(lifetimes.len());
|
||||
struct_span_err!(self.tcx.sess, span, E0090,
|
||||
"too few lifetime parameters provided: \
|
||||
|
@ -5014,8 +5014,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
let segment = segment.map(|(path_segment, generics)| {
|
||||
let explicit = !path_segment.infer_types;
|
||||
let impl_trait = generics.types().iter()
|
||||
.any(|ty_param| {
|
||||
let impl_trait = generics.types().any(|ty_param| {
|
||||
match ty_param.synthetic {
|
||||
Some(ImplTrait) => true,
|
||||
_ => false,
|
||||
|
|
|
@ -642,7 +642,6 @@ fn reject_shadowing_type_parameters(tcx: TyCtxt, def_id: DefId) {
|
|||
let generics = tcx.generics_of(def_id);
|
||||
let parent = tcx.generics_of(generics.parent.unwrap());
|
||||
let impl_params: FxHashMap<_, _> = parent.types()
|
||||
.iter()
|
||||
.map(|tp| (tp.name, tp.def_id))
|
||||
.collect();
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
tcx, &impl_predicates.predicates.as_slice(), impl_trait_ref, &mut input_parameters);
|
||||
|
||||
// Disallow ANY unconstrained type parameters.
|
||||
for (ty_param, param) in impl_generics.types().iter().zip(impl_hir_generics.ty_params()) {
|
||||
for (ty_param, param) in impl_generics.types().zip(impl_hir_generics.ty_params()) {
|
||||
let param_ty = ty::ParamTy::for_def(ty_param);
|
||||
if !input_parameters.contains(&ctp::Parameter::from(param_ty)) {
|
||||
report_unused_parameter(tcx, param.span, "type", ¶m_ty.to_string());
|
||||
|
@ -114,7 +114,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
// Disallow unconstrained lifetimes, but only if they appear in assoc types.
|
||||
let lifetimes_in_associated_types: FxHashSet<_> = impl_item_refs.iter()
|
||||
.map(|item_ref| tcx.hir.local_def_id(item_ref.id.node_id))
|
||||
.map(|item_ref| tcx.hir.local_def_id(item_ref.id.node_id))
|
||||
.filter(|&def_id| {
|
||||
let item = tcx.associated_item(def_id);
|
||||
item.kind == ty::AssociatedKind::Type && item.defaultness.has_value()
|
||||
|
@ -122,15 +122,11 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
.flat_map(|def_id| {
|
||||
ctp::parameters_for(&tcx.type_of(def_id), true)
|
||||
}).collect();
|
||||
for (ty_lifetime, lifetime) in impl_generics.lifetimes().iter()
|
||||
.zip(impl_hir_generics.lifetimes())
|
||||
{
|
||||
for (ty_lifetime, lifetime) in impl_generics.lifetimes().zip(impl_hir_generics.lifetimes()) {
|
||||
let param = ctp::Parameter::from(ty_lifetime.to_early_bound_region_data());
|
||||
|
||||
if
|
||||
lifetimes_in_associated_types.contains(¶m) && // (*)
|
||||
!input_parameters.contains(¶m)
|
||||
{
|
||||
if lifetimes_in_associated_types.contains(¶m) && // (*)
|
||||
!input_parameters.contains(¶m) {
|
||||
report_unused_parameter(tcx, lifetime.lifetime.span,
|
||||
"lifetime", &lifetime.lifetime.name.name().to_string());
|
||||
}
|
||||
|
|
|
@ -226,7 +226,6 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
|||
fn generics_to_path_params(&self, generics: ty::Generics) -> hir::PathParameters {
|
||||
let lifetimes = HirVec::from_vec(
|
||||
generics.lifetimes()
|
||||
.iter()
|
||||
.map(|p| {
|
||||
let name = if p.name == "" {
|
||||
hir::LifetimeName::Static
|
||||
|
|
|
@ -1800,7 +1800,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
|
|||
// Bounds in the type_params and lifetimes fields are repeated in the
|
||||
// predicates field (see rustc_typeck::collect::ty_generics), so remove
|
||||
// them.
|
||||
let stripped_typarams = gens.types().iter().filter_map(|tp| {
|
||||
let stripped_typarams = gens.types().filter_map(|tp| {
|
||||
if tp.name == keywords::SelfType.name().as_str() {
|
||||
assert_eq!(tp.index, 0);
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue