@@ -130,7 +130,7 @@ use syntax_pos::{self, BytePos, Span, MultiSpan};
130130use rustc:: hir:: intravisit:: { self , Visitor , NestedVisitorMap } ;
131131use rustc:: hir:: itemlikevisit:: ItemLikeVisitor ;
132132use rustc:: hir:: map:: Node ;
133- use rustc:: hir:: { self , PatKind } ;
133+ use rustc:: hir:: { self , PatKind , Item_ } ;
134134use rustc:: middle:: lang_items;
135135
136136mod autoderef;
@@ -1133,7 +1133,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
11331133 if let Some ( panic_impl_did) = fcx. tcx . lang_items ( ) . panic_impl ( ) {
11341134 if panic_impl_did == fn_hir_id. owner_def_id ( ) {
11351135 if let Some ( panic_info_did) = fcx. tcx . lang_items ( ) . panic_info ( ) {
1136- if ret_ty . sty != ty:: TyNever {
1136+ if declared_ret_ty . sty != ty:: TyNever {
11371137 fcx. tcx . sess . span_err (
11381138 decl. output . span ( ) ,
11391139 "return type should be `!`" ,
@@ -1161,6 +1161,17 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
11611161 "argument should be `&PanicInfo`" ,
11621162 ) ;
11631163 }
1164+
1165+ if let Node :: NodeItem ( item) = fcx. tcx . hir . get ( fn_id) {
1166+ if let Item_ :: ItemFn ( _, _, _, _, ref generics, _) = item. node {
1167+ if !generics. params . is_empty ( ) {
1168+ fcx. tcx . sess . span_err (
1169+ span,
1170+ "`#[panic_implementation]` function should have no type parameters" ,
1171+ ) ;
1172+ }
1173+ }
1174+ }
11641175 } else {
11651176 fcx. tcx . sess . span_err ( span, "function should have one argument" ) ;
11661177 }
0 commit comments