@@ -436,6 +436,16 @@ fn is_repr_nullable_ptr<'tcx>(variants: &Vec<Rc<ty::VariantInfo<'tcx>>>) -> bool
436436 false
437437}
438438
439+ fn ast_ty_to_normalized < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
440+ id : ast:: NodeId )
441+ -> Ty < ' tcx > {
442+ let tty = match tcx. ast_ty_to_ty_cache . borrow ( ) . get ( & id) {
443+ Some ( & t) => t,
444+ None => panic ! ( "ast_ty_to_ty_cache was incomplete after typeck!" )
445+ } ;
446+ infer:: normalize_associated_type ( tcx, & tty)
447+ }
448+
439449impl < ' a , ' tcx > ImproperCTypesVisitor < ' a , ' tcx > {
440450 /// Check if the given type is "ffi-safe" (has a stable, well-defined
441451 /// representation which can be exported to C code).
@@ -638,11 +648,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
638648 }
639649
640650 fn check_def ( & mut self , sp : Span , id : ast:: NodeId ) {
641- let tty = match self . cx . tcx . ast_ty_to_ty_cache . borrow ( ) . get ( & id) {
642- Some ( & t) => t,
643- None => panic ! ( "ast_ty_to_ty_cache was incomplete after typeck!" )
644- } ;
645- let tty = infer:: normalize_associated_type ( self . cx . tcx , & tty) ;
651+ let tty = ast_ty_to_normalized ( self . cx . tcx , id) ;
646652
647653 match ImproperCTypesVisitor :: check_type_for_ffi ( self , & mut FnvHashSet ( ) , tty) {
648654 FfiResult :: FfiSafe => { }
@@ -707,7 +713,10 @@ impl LintPass for ImproperCTypes {
707713 check_ty ( cx, & * input. ty ) ;
708714 }
709715 if let ast:: Return ( ref ret_ty) = decl. output {
710- check_ty ( cx, & * * ret_ty) ;
716+ let tty = ast_ty_to_normalized ( cx. tcx , ret_ty. id ) ;
717+ if !tty. is_nil ( ) {
718+ check_ty ( cx, & ret_ty) ;
719+ }
711720 }
712721 }
713722
0 commit comments