@@ -23,7 +23,7 @@ use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId};
2323use rustc_hir as hir;
2424use rustc_hir:: def:: { CtorOf , DefKind , Namespace , Res } ;
2525use rustc_hir:: def_id:: DefId ;
26- use rustc_hir:: intravisit:: Visitor ;
26+ use rustc_hir:: intravisit:: { walk_generics , Visitor } ;
2727use rustc_hir:: print;
2828use rustc_hir:: { Constness , ExprKind , GenericArg , GenericArgs } ;
2929use rustc_infer:: traits;
@@ -838,18 +838,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
838838 }
839839 } ,
840840 ) ;
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- }
853841
854842 self . complain_about_missing_type_params (
855843 missing_type_params,
@@ -2734,7 +2722,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
27342722 }
27352723 hir:: TyKind :: BareFn ( ref bf) => {
27362724 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+ ) )
27382732 }
27392733 hir:: TyKind :: TraitObject ( ref bounds, ref lifetime) => {
27402734 self . conv_object_ty_poly_trait_ref ( ast_ty. span , bounds, lifetime)
@@ -2917,7 +2911,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29172911 unsafety : hir:: Unsafety ,
29182912 abi : abi:: Abi ,
29192913 decl : & hir:: FnDecl < ' _ > ,
2920- generic_params : & [ hir:: GenericParam < ' _ > ] ,
2914+ generics : & hir:: Generics < ' _ > ,
29212915 ident_span : Option < Span > ,
29222916 ) -> ty:: PolyFnSig < ' tcx > {
29232917 debug ! ( "ty_of_fn" ) ;
@@ -2929,6 +2923,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29292923 for ty in decl. inputs {
29302924 visitor. visit_ty ( ty) ;
29312925 }
2926+ walk_generics ( & mut visitor, generics) ;
2927+
29322928 let input_tys = decl. inputs . iter ( ) . map ( |a| self . ty_of_arg ( a, None ) ) ;
29332929 let output_ty = match decl. output {
29342930 hir:: FnRetTy :: Return ( ref output) => {
@@ -2950,7 +2946,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29502946 crate :: collect:: placeholder_type_error (
29512947 tcx,
29522948 ident_span. map ( |sp| sp. shrink_to_hi ( ) ) . unwrap_or ( DUMMY_SP ) ,
2953- generic_params ,
2949+ & generics . params [ .. ] ,
29542950 visitor. 0 ,
29552951 ident_span. is_some ( ) ,
29562952 ) ;
@@ -2976,8 +2972,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29762972 tcx. sess,
29772973 decl. output. span( ) ,
29782974 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" ,
29812976 lifetime_name
29822977 ) ;
29832978 if let ty:: BrAnon ( _) = * br {
@@ -2988,8 +2983,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29882983 // though we can easily give a hint that ought to be
29892984 // relevant.
29902985 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" ,
29932987 ) ;
29942988 }
29952989 err. emit ( ) ;
0 commit comments