Skip to content

Commit

Permalink
Fix missing generic parameters from future_prelude_collision lint s…
Browse files Browse the repository at this point in the history
…uggestion
  • Loading branch information
jam1garner authored and nikomatsakis committed Jun 14, 2021
1 parent eb5e0af commit 93c60f2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion compiler/rustc_typeck/src/check/method/mod.rs
Expand Up @@ -544,7 +544,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let probe::PickKind::TraitPick = pick.kind {
if !matches!(tcx.crate_name(pick.item.def_id.krate), sym::std | sym::core) {
tcx.struct_span_lint_hir(FUTURE_PRELUDE_COLLISION, expr_id, span, |lint| {
let trait_name = tcx.def_path_str(pick.item.container.assert_trait());
let trait_def_id = pick.item.container.assert_trait();
let trait_generics = tcx.generics_of(trait_def_id);
let parameter_count = trait_generics.count() - (trait_generics.has_self as usize);

let trait_name = if parameter_count == 0 {
tcx.def_path_str(trait_def_id)
} else {
format!(
"{}<{}>",
tcx.def_path_str(trait_def_id),
std::iter::repeat("_").take(parameter_count).collect::<Vec<_>>().join(", ")
)
};

let mut lint = lint.build(&format!(
"trait-associated function `{}` will become ambiguous in Rust 2021",
Expand Down

0 comments on commit 93c60f2

Please sign in to comment.