@@ -436,6 +436,16 @@ fn is_repr_nullable_ptr<'tcx>(variants: &Vec<Rc<ty::VariantInfo<'tcx>>>) -> bool
436
436
false
437
437
}
438
438
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
+
439
449
impl < ' a , ' tcx > ImproperCTypesVisitor < ' a , ' tcx > {
440
450
/// Check if the given type is "ffi-safe" (has a stable, well-defined
441
451
/// representation which can be exported to C code).
@@ -638,11 +648,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
638
648
}
639
649
640
650
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) ;
646
652
647
653
match ImproperCTypesVisitor :: check_type_for_ffi ( self , & mut FnvHashSet ( ) , tty) {
648
654
FfiResult :: FfiSafe => { }
@@ -707,7 +713,10 @@ impl LintPass for ImproperCTypes {
707
713
check_ty ( cx, & * input. ty ) ;
708
714
}
709
715
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
+ }
711
720
}
712
721
}
713
722
0 commit comments