@@ -23,7 +23,7 @@ use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId};
23
23
use rustc_hir as hir;
24
24
use rustc_hir:: def:: { CtorOf , DefKind , Namespace , Res } ;
25
25
use rustc_hir:: def_id:: DefId ;
26
- use rustc_hir:: intravisit:: Visitor ;
26
+ use rustc_hir:: intravisit:: { walk_generics , Visitor } ;
27
27
use rustc_hir:: print;
28
28
use rustc_hir:: { Constness , ExprKind , GenericArg , GenericArgs } ;
29
29
use rustc_infer:: traits;
@@ -838,18 +838,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
838
838
}
839
839
} ,
840
840
) ;
841
- if !inferred_params. is_empty ( ) {
842
- // We always collect the spans for placeholder types when evaluating `fn`s, but we
843
- // only want to emit an error complaining about them if infer types (`_`) are not
844
- // allowed. `allow_ty_infer` gates this behavior.
845
- crate :: collect:: placeholder_type_error (
846
- tcx,
847
- inferred_params[ 0 ] ,
848
- & [ ] ,
849
- inferred_params,
850
- false ,
851
- ) ;
852
- }
853
841
854
842
self . complain_about_missing_type_params (
855
843
missing_type_params,
@@ -2734,7 +2722,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2734
2722
}
2735
2723
hir:: TyKind :: BareFn ( ref bf) => {
2736
2724
require_c_abi_if_c_variadic ( tcx, & bf. decl , bf. abi , ast_ty. span ) ;
2737
- tcx. mk_fn_ptr ( self . ty_of_fn ( bf. unsafety , bf. abi , & bf. decl , & [ ] , None ) )
2725
+ tcx. mk_fn_ptr ( self . ty_of_fn (
2726
+ bf. unsafety ,
2727
+ bf. abi ,
2728
+ & bf. decl ,
2729
+ & hir:: Generics :: empty ( ) ,
2730
+ None ,
2731
+ ) )
2738
2732
}
2739
2733
hir:: TyKind :: TraitObject ( ref bounds, ref lifetime) => {
2740
2734
self . conv_object_ty_poly_trait_ref ( ast_ty. span , bounds, lifetime)
@@ -2917,7 +2911,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2917
2911
unsafety : hir:: Unsafety ,
2918
2912
abi : abi:: Abi ,
2919
2913
decl : & hir:: FnDecl < ' _ > ,
2920
- generic_params : & [ hir:: GenericParam < ' _ > ] ,
2914
+ generics : & hir:: Generics < ' _ > ,
2921
2915
ident_span : Option < Span > ,
2922
2916
) -> ty:: PolyFnSig < ' tcx > {
2923
2917
debug ! ( "ty_of_fn" ) ;
@@ -2929,6 +2923,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2929
2923
for ty in decl. inputs {
2930
2924
visitor. visit_ty ( ty) ;
2931
2925
}
2926
+ walk_generics ( & mut visitor, generics) ;
2927
+
2932
2928
let input_tys = decl. inputs . iter ( ) . map ( |a| self . ty_of_arg ( a, None ) ) ;
2933
2929
let output_ty = match decl. output {
2934
2930
hir:: FnRetTy :: Return ( ref output) => {
@@ -2950,7 +2946,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2950
2946
crate :: collect:: placeholder_type_error (
2951
2947
tcx,
2952
2948
ident_span. map ( |sp| sp. shrink_to_hi ( ) ) . unwrap_or ( DUMMY_SP ) ,
2953
- generic_params ,
2949
+ & generics . params [ .. ] ,
2954
2950
visitor. 0 ,
2955
2951
ident_span. is_some ( ) ,
2956
2952
) ;
@@ -2976,8 +2972,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2976
2972
tcx. sess,
2977
2973
decl. output. span( ) ,
2978
2974
E0581 ,
2979
- "return type references {} \
2980
- which is not constrained by the fn input types",
2975
+ "return type references {} which is not constrained by the fn input types" ,
2981
2976
lifetime_name
2982
2977
) ;
2983
2978
if let ty:: BrAnon ( _) = * br {
@@ -2988,8 +2983,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2988
2983
// though we can easily give a hint that ought to be
2989
2984
// relevant.
2990
2985
err. note (
2991
- "lifetimes appearing in an associated type \
2992
- are not considered constrained",
2986
+ "lifetimes appearing in an associated type are not considered constrained" ,
2993
2987
) ;
2994
2988
}
2995
2989
err. emit ( ) ;
0 commit comments