Use parenthetical notation for Fn
traits
Always use the `Fn(T) -> R` format when printing closure traits instead of `Fn<(T,), Output = R>`. Fix #67100: ``` error[E0277]: expected a `Fn()` closure, found `F` --> file.rs:6:13 | 6 | call_fn(f) | ------- ^ expected an `Fn()` closure, found `F` | | | required by a bound introduced by this call | = note: wrap the `F` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `call_fn` --> file.rs:1:15 | 1 | fn call_fn<F: Fn() -> ()>(f: &F) { | ^^^^^^^^^^ required by this bound in `call_fn` help: consider further restricting this bound | 5 | fn call_any<F: std::any::Any + Fn()>(f: &F) { | ++++++ ```
This commit is contained in:
parent
8c4db851a7
commit
e6bd6c2044
43 changed files with 89 additions and 88 deletions
|
@ -29,10 +29,11 @@ use rustc_macros::extension;
|
|||
use rustc_middle::hir::map;
|
||||
use rustc_middle::traits::IsConstable;
|
||||
use rustc_middle::ty::error::TypeError::{self, Sorts};
|
||||
use rustc_middle::ty::print::PrintPolyTraitRefExt;
|
||||
use rustc_middle::ty::{
|
||||
self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, GenericArgs,
|
||||
InferTy, IsSuggestable, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
|
||||
TypeVisitableExt, TypeckResults, Upcast,
|
||||
InferTy, IsSuggestable, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable, TypeFolder,
|
||||
TypeSuperFoldable, TypeVisitableExt, TypeckResults, Upcast,
|
||||
};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
|
@ -219,15 +220,15 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
|
|||
(_, None) => predicate_constraint(hir_generics, trait_pred.upcast(tcx)),
|
||||
(None, Some((ident, []))) => (
|
||||
ident.span.shrink_to_hi(),
|
||||
format!(": {}", trait_pred.print_modifiers_and_trait_path()),
|
||||
format!(": {}", trait_pred.to_poly_trait_ref().print_trait_sugared()),
|
||||
),
|
||||
(_, Some((_, [.., bounds]))) => (
|
||||
bounds.span().shrink_to_hi(),
|
||||
format!(" + {}", trait_pred.print_modifiers_and_trait_path()),
|
||||
format!(" + {}", trait_pred.to_poly_trait_ref().print_trait_sugared()),
|
||||
),
|
||||
(Some(_), Some((_, []))) => (
|
||||
hir_generics.span.shrink_to_hi(),
|
||||
format!(": {}", trait_pred.print_modifiers_and_trait_path()),
|
||||
format!(": {}", trait_pred.to_poly_trait_ref().print_trait_sugared()),
|
||||
),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue