@@ -130,7 +130,7 @@ use syntax_pos::{self, BytePos, Span, MultiSpan};
130
130
use rustc:: hir:: intravisit:: { self , Visitor , NestedVisitorMap } ;
131
131
use rustc:: hir:: itemlikevisit:: ItemLikeVisitor ;
132
132
use rustc:: hir:: map:: Node ;
133
- use rustc:: hir:: { self , PatKind } ;
133
+ use rustc:: hir:: { self , PatKind , Item_ } ;
134
134
use rustc:: middle:: lang_items;
135
135
136
136
mod autoderef;
@@ -1133,7 +1133,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
1133
1133
if let Some ( panic_impl_did) = fcx. tcx . lang_items ( ) . panic_impl ( ) {
1134
1134
if panic_impl_did == fn_hir_id. owner_def_id ( ) {
1135
1135
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 {
1137
1137
fcx. tcx . sess . span_err (
1138
1138
decl. output . span ( ) ,
1139
1139
"return type should be `!`" ,
@@ -1161,6 +1161,17 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
1161
1161
"argument should be `&PanicInfo`" ,
1162
1162
) ;
1163
1163
}
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
+ }
1164
1175
} else {
1165
1176
fcx. tcx . sess . span_err ( span, "function should have one argument" ) ;
1166
1177
}
0 commit comments