]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/borrow_check/nll/type_check/input_output.rs
Use `eq_opaque_type_and_type` when type-checking closure signatures
[rust.git] / src / librustc_mir / borrow_check / nll / type_check / input_output.rs
index 99661b1f7370ab888f7b8ff1f1c5f9d2e651bf51..35fb677c053cb99ae7d5955be1144fb8d2b5e739 100644 (file)
@@ -12,7 +12,7 @@
 use rustc::mir::*;
 use rustc::ty::Ty;
 
-use rustc_data_structures::indexed_vec::Idx;
+use rustc_index::vec::Idx;
 use syntax_pos::Span;
 
 use super::{Locations, TypeChecker};
@@ -134,15 +134,27 @@ pub(super) fn equate_inputs_and_outputs(
         };
 
         // If the user explicitly annotated the output types, enforce those.
+        // Note that this only happens for closures.
         if let Some(user_provided_sig) = user_provided_sig {
             let user_provided_output_ty = user_provided_sig.output();
             let user_provided_output_ty =
                 self.normalize(user_provided_output_ty, Locations::All(output_span));
-            self.equate_normalized_input_or_output(
-                user_provided_output_ty,
+            if let Err(err) = self.eq_opaque_type_and_type(
                 mir_output_ty,
-                output_span,
-            );
+                user_provided_output_ty,
+                self.mir_def_id,
+                Locations::All(output_span),
+                ConstraintCategory::BoringNoLocation
+            ) {
+                span_mirbug!(
+                    self,
+                    Location::START,
+                    "equate_inputs_and_outputs: `{:?}=={:?}` failed with `{:?}`",
+                    mir_output_ty,
+                    user_provided_output_ty,
+                    err
+                );
+            }
         }
     }