@@ -1120,11 +1120,15 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11201120 . map ( |method| resolve_ty ( method. ty ) ) )
11211121 }
11221122
1123+ pub fn errors_since_creation ( & self ) -> bool {
1124+ self . tcx . sess . err_count ( ) - self . err_count_on_creation != 0
1125+ }
1126+
11231127 pub fn node_type ( & self , id : ast:: NodeId ) -> Ty < ' tcx > {
11241128 match self . tables . borrow ( ) . node_types . get ( & id) {
11251129 Some ( & t) => t,
11261130 // FIXME
1127- None if self . tcx . sess . err_count ( ) - self . err_count_on_creation != 0 =>
1131+ None if self . errors_since_creation ( ) =>
11281132 self . tcx . types . err ,
11291133 None => {
11301134 self . tcx . sess . bug (
@@ -1147,7 +1151,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11471151 free_regions : & FreeRegionMap ,
11481152 subject_node_id : ast:: NodeId ) {
11491153 let errors = self . region_vars . resolve_regions ( free_regions, subject_node_id) ;
1150- self . report_region_errors ( & errors) ; // see error_reporting.rs
1154+ if !self . errors_since_creation ( ) {
1155+ // As a heuristic, just skip reporting region errors
1156+ // altogether if other errors have been reported while
1157+ // this infcx was in use. This is totally hokey but
1158+ // otherwise we have a hard time separating legit region
1159+ // errors from silly ones.
1160+ self . report_region_errors ( & errors) ; // see error_reporting.rs
1161+ }
11511162 }
11521163
11531164 pub fn ty_to_string ( & self , t : Ty < ' tcx > ) -> String {
0 commit comments