Fix tidy check
This commit is contained in:
parent
335770267a
commit
734ce4ae1a
3 changed files with 22 additions and 15 deletions
|
@ -20,7 +20,7 @@ use hir::map as hir_map;
|
|||
use hir::def::Def;
|
||||
use hir::def_id::{DefId, CrateNum};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use ty::{self, TyCtxt, GenericParamDefKind};
|
||||
use ty::{self, TyCtxt};
|
||||
use ty::query::Providers;
|
||||
use middle::privacy;
|
||||
use session::config;
|
||||
|
|
|
@ -316,7 +316,8 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
|||
// variables.
|
||||
let method_generics = self.tcx.generics_of(pick.item.def_id);
|
||||
let supress_mismatch = self.fcx.check_impl_trait(self.span, segment, &method_generics);
|
||||
self.fcx.check_generic_arg_count(self.span, &segment, &method_generics, true, supress_mismatch);
|
||||
self.fcx.check_generic_arg_count(self.span, &segment, &method_generics, true,
|
||||
supress_mismatch);
|
||||
|
||||
// Create subst for early-bound lifetime parameters, combining
|
||||
// parameters from the type and those from the method.
|
||||
|
@ -324,14 +325,18 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
|||
let provided = &segment.args;
|
||||
let own_counts = method_generics.own_counts();
|
||||
// FIXME(varkor): Separating out the parameters is messy.
|
||||
let lifetimes: Vec<_> = provided.iter().flat_map(|data| data.args.iter().filter_map(|arg| match arg {
|
||||
GenericArg::Lifetime(ty) => Some(ty),
|
||||
_ => None,
|
||||
})).collect();
|
||||
let types: Vec<_> = provided.iter().flat_map(|data| data.args.iter().filter_map(|arg| match arg {
|
||||
GenericArg::Type(ty) => Some(ty),
|
||||
_ => None,
|
||||
})).collect();
|
||||
let lifetimes: Vec<_> = provided.iter().flat_map(|data| {
|
||||
data.args.iter().filter_map(|arg| match arg {
|
||||
GenericArg::Lifetime(ty) => Some(ty),
|
||||
_ => None,
|
||||
})
|
||||
}).collect();
|
||||
let types: Vec<_> = provided.iter().flat_map(|data| {
|
||||
data.args.iter().filter_map(|arg| match arg {
|
||||
GenericArg::Type(ty) => Some(ty),
|
||||
_ => None,
|
||||
})
|
||||
}).collect();
|
||||
Substs::for_item(self.tcx, pick.item.def_id, |param, _| {
|
||||
let i = param.index as usize;
|
||||
if i < parent_substs.len() {
|
||||
|
@ -339,13 +344,15 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
|||
} else {
|
||||
match param.kind {
|
||||
GenericParamDefKind::Lifetime => {
|
||||
if let Some(lifetime) = lifetimes.get(i - parent_substs.len()) {
|
||||
let idx = i - parent_substs.len();
|
||||
if let Some(lifetime) = lifetimes.get(idx) {
|
||||
return AstConv::ast_region_to_region(
|
||||
self.fcx, lifetime, Some(param)).into();
|
||||
}
|
||||
}
|
||||
GenericParamDefKind::Type { .. } => {
|
||||
if let Some(ast_ty) = types.get(i - parent_substs.len() - own_counts.lifetimes) {
|
||||
let idx = i - parent_substs.len() - own_counts.lifetimes;
|
||||
if let Some(ast_ty) = types.get(idx) {
|
||||
return self.to_ty(ast_ty).into();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5162,9 +5162,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let ty_accepted = ty_params.accepted;
|
||||
let ty_required = ty_params.required;
|
||||
|
||||
let count_type_params = |n| format!("{} type parameter{}", n, if n == 1 { "" } else { "s" });
|
||||
let expected_text = count_type_params(ty_accepted);
|
||||
let actual_text = count_type_params(types.len());
|
||||
let count_ty_params = |n| format!("{} type parameter{}", n, if n == 1 { "" } else { "s" });
|
||||
let expected_text = count_ty_params(ty_accepted);
|
||||
let actual_text = count_ty_params(types.len());
|
||||
if let Some((mut err, span)) = if types.len() > ty_accepted {
|
||||
// To prevent derived errors to accumulate due to extra
|
||||
// type parameters, we force instantiate_value_path to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue