use crate::hir::Node;
use crate::infer::opaque_types;
use crate::middle::region;
-use crate::traits::{MatchExpressionArmCause, ObligationCause, ObligationCauseCode};
+use crate::traits::{IfExpressionCause, MatchExpressionArmCause, ObligationCause};
+use crate::traits::{ObligationCauseCode};
use crate::ty::error::TypeError;
use crate::ty::{self, subst::{Subst, SubstsRef}, Region, Ty, TyCtxt, TypeFoldable};
use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
}
}
},
- ObligationCauseCode::IfExpression { then, outer, semicolon } => {
+ ObligationCauseCode::IfExpression(box IfExpressionCause { then, outer, semicolon }) => {
err.span_label(then, "expected because of this");
outer.map(|sp| err.span_label(sp, "if and else have incompatible types"));
if let Some(sp) = semicolon {
// `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
-static_assert_size!(PendingPredicateObligation<'_>, 144);
+static_assert_size!(PendingPredicateObligation<'_>, 136);
impl<'a, 'tcx> FulfillmentContext<'tcx> {
/// Creates a new fulfillment context.
// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
-static_assert_size!(PredicateObligation<'_>, 120);
+static_assert_size!(PredicateObligation<'_>, 112);
/// The reason why we incurred this obligation; used for error reporting.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
MatchExpressionArmPattern { span: Span, ty: Ty<'tcx> },
/// Computing common supertype in an if expression
- IfExpression {
- then: Span,
- outer: Option<Span>,
- semicolon: Option<Span>,
- },
+ IfExpression(Box<IfExpressionCause>),
/// Computing common supertype of an if expression with no else counter-part
IfExpressionWithNoElse,
// `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
-static_assert_size!(ObligationCauseCode<'_>, 40);
+static_assert_size!(ObligationCauseCode<'_>, 32);
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct MatchExpressionArmCause<'tcx> {
pub discrim_hir_id: hir::HirId,
}
+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+pub struct IfExpressionCause {
+ pub then: Span,
+ pub outer: Option<Span>,
+ pub semicolon: Option<Span>,
+}
+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DerivedObligationCause<'tcx> {
/// The trait reference of the parent obligation that led to the
super::MatchExpressionArmPattern { span, ty } => {
tcx.lift(&ty).map(|ty| super::MatchExpressionArmPattern { span, ty })
}
- super::IfExpression { then, outer, semicolon } => Some(super::IfExpression {
- then,
- outer,
- semicolon,
- }),
+ super::IfExpression(box super::IfExpressionCause { then, outer, semicolon }) => {
+ Some(super::IfExpression(box super::IfExpressionCause {
+ then,
+ outer,
+ semicolon,
+ }))
+ }
super::IfExpressionWithNoElse => Some(super::IfExpressionWithNoElse),
super::MainFunctionType => Some(super::MainFunctionType),
super::StartFunctionType => Some(super::StartFunctionType),
use crate::check::coercion::CoerceMany;
use rustc::hir::{self, ExprKind};
use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
-use rustc::traits::{MatchExpressionArmCause, ObligationCause, ObligationCauseCode};
+use rustc::traits::{IfExpressionCause, MatchExpressionArmCause, ObligationCause};
+use rustc::traits::{ObligationCauseCode};
use rustc::ty::Ty;
use syntax_pos::Span;
};
// Finally construct the cause:
- self.cause(error_sp, ObligationCauseCode::IfExpression {
+ self.cause(error_sp, ObligationCauseCode::IfExpression(box IfExpressionCause {
then: then_sp,
outer: outer_sp,
semicolon: remove_semicolon,
- })
+ }))
}
fn demand_discriminant_type(