1
Fork 0

Format and fix rebase

This commit is contained in:
Esteban Küber 2019-12-26 13:25:04 -08:00
parent fb52883690
commit 3a9c3f92cc
2 changed files with 13 additions and 15 deletions

View file

@ -2,12 +2,13 @@
//! The main routine here is `ast_ty_to_ty()`; each use is parameterized by an
//! instance of `AstConv`.
use crate::collect::PlaceholderHirTyCollector;
use crate::hir::def::{CtorOf, DefKind, Res};
use crate::hir::def_id::DefId;
use crate::hir::intravisit::Visitor;
use crate::hir::print;
use crate::hir::ptr::P;
use crate::hir::{self, ExprKind, GenericArg, GenericArgs, HirVec};
use crate::hir::intravisit::Visitor;
use crate::lint;
use crate::middle::lang_items::SizedTraitLangItem;
use crate::middle::resolve_lifetime as rl;
@ -16,7 +17,6 @@ use crate::require_c_abi_if_c_variadic;
use crate::util::common::ErrorReported;
use crate::util::nodemap::FxHashMap;
use errors::{Applicability, DiagnosticId};
use crate::collect::PlaceholderHirTyCollector;
use rustc::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
use rustc::traits;
use rustc::ty::subst::{self, InternalSubsts, Subst, SubstsRef};
@ -2786,11 +2786,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
hir::Return(ref output) => {
let mut visitor = PlaceholderHirTyCollector::new();
visitor.visit_ty(output);
let is_infer = if let hir::TyKind::Infer = output.kind {
true
} else {
false
};
let is_infer = if let hir::TyKind::Infer = output.kind { true } else { false };
if (is_infer || !visitor.0.is_empty()) && !self.allow_ty_infer() {
output_placeholder_types.extend(visitor.0);
tcx.types.err

View file

@ -135,10 +135,13 @@ crate fn placeholder_type_error(
) {
if !placeholder_types.is_empty() {
let possible_names = ["T", "K", "L", "A", "B", "C"];
let used_names = generics.iter().filter_map(|p| match p.name {
hir::ParamName::Plain(ident) => Some(ident.name),
_ => None,
}).collect::<Vec<_>>();
let used_names = generics
.iter()
.filter_map(|p| match p.name {
hir::ParamName::Plain(ident) => Some(ident.name),
_ => None,
})
.collect::<Vec<_>>();
let mut type_name = "ParamName";
for name in &possible_names {
@ -147,10 +150,9 @@ crate fn placeholder_type_error(
break;
}
}
let mut sugg: Vec<_> = placeholder_types.iter()
.map(|sp| (*sp, type_name.to_string()))
.collect();
let mut sugg: Vec<_> =
placeholder_types.iter().map(|sp| (*sp, type_name.to_string())).collect();
if generics.is_empty() {
sugg.push((ident_span.shrink_to_hi(), format!("<{}>", type_name)));
} else {