//! This module contains code to equate the input/output types appearing
//! in the MIR with the expected input/output types from the function
//! signature. This requires a bit of processing, as the expected types
-//! are supplied to us before normalization and may contain existential
+//! are supplied to us before normalization and may contain opaque
//! `impl Trait` instances. In contrast, the input/output types found in
//! the MIR (specifically, in the special local variables for the
//! `RETURN_PLACE` the MIR arguments) are always fully normalized (and
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};
self.equate_normalized_input_or_output(ur_yield_ty, mir_yield_ty, yield_span);
}
- // Return types are a bit more complex. They may contain existential `impl Trait`
- // types.
+ // Return types are a bit more complex. They may contain opaque `impl Trait` types.
let mir_output_ty = body.local_decls[RETURN_PLACE].ty;
let output_span = body.local_decls[RETURN_PLACE].source_info.span;
if let Err(terr) = self.eq_opaque_type_and_type(
};
// 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
+ );
+ }
}
}