Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format and fix rebase
  • Loading branch information
estebank committed Dec 30, 2019
commit 3a9c3f92ccc2056e73a88840afde6b9df0dbf7ec
10 changes: 3 additions & 7 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};
Expand Down Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down