1
Fork 0

Rollup merge of #108294 - compiler-errors:arbitary-sugg-binder, r=TaKO8Ki

Place binder correctly for arbitrary trait bound suggestion

suggest `for<'a> &'a T: Trait` instead of `&'a T: for<'a> T`.
This commit is contained in:
Matthias Krüger 2023-03-09 12:11:52 +01:00 committed by GitHub
commit ac258e9e02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 2 deletions

View file

@ -117,7 +117,7 @@ pub fn suggest_arbitrary_trait_bound<'tcx>(
}
let param_name = trait_pred.skip_binder().self_ty().to_string();
let mut constraint = trait_pred.print_modifiers_and_trait_path().to_string();
let mut constraint = trait_pred.to_string();
if let Some((name, term)) = associated_ty {
// FIXME: this case overlaps with code in TyCtxt::note_and_explain_type_err.
@ -144,7 +144,7 @@ pub fn suggest_arbitrary_trait_bound<'tcx>(
this requirement",
if generics.where_clause_span.is_empty() { "introducing a" } else { "extending the" },
),
format!("{} {}: {}", generics.add_where_or_trailing_comma(), param_name, constraint),
format!("{} {constraint}", generics.add_where_or_trailing_comma()),
Applicability::MaybeIncorrect,
);
true