mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Plumb through param_env to note_type_err
This commit is contained in:
parent
b8bb2968ce
commit
1920c66a8d
@ -65,6 +65,7 @@ impl<'tcx> UniverseInfo<'tcx> {
|
|||||||
UniverseInfoInner::RelateTys { expected, found } => {
|
UniverseInfoInner::RelateTys { expected, found } => {
|
||||||
let err = mbcx.infcx.err_ctxt().report_mismatched_types(
|
let err = mbcx.infcx.err_ctxt().report_mismatched_types(
|
||||||
&cause,
|
&cause,
|
||||||
|
mbcx.param_env,
|
||||||
expected,
|
expected,
|
||||||
found,
|
found,
|
||||||
TypeError::RegionsPlaceholderMismatch,
|
TypeError::RegionsPlaceholderMismatch,
|
||||||
@ -480,12 +481,11 @@ fn try_extract_error_from_region_constraints<'a, 'tcx>(
|
|||||||
.try_report_from_nll()
|
.try_report_from_nll()
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
if let SubregionOrigin::Subtype(trace) = cause {
|
if let SubregionOrigin::Subtype(trace) = cause {
|
||||||
Some(
|
Some(infcx.err_ctxt().report_and_explain_type_error(
|
||||||
infcx.err_ctxt().report_and_explain_type_error(
|
*trace,
|
||||||
*trace,
|
infcx.tcx.param_env(generic_param_scope),
|
||||||
TypeError::RegionsPlaceholderMismatch,
|
TypeError::RegionsPlaceholderMismatch,
|
||||||
),
|
))
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -360,6 +360,7 @@ fn check_opaque_type_well_formed<'tcx>(
|
|||||||
.err_ctxt()
|
.err_ctxt()
|
||||||
.report_mismatched_types(
|
.report_mismatched_types(
|
||||||
&ObligationCause::misc(definition_span, def_id),
|
&ObligationCause::misc(definition_span, def_id),
|
||||||
|
param_env,
|
||||||
opaque_ty,
|
opaque_ty,
|
||||||
definition_ty,
|
definition_ty,
|
||||||
err,
|
err,
|
||||||
|
@ -282,6 +282,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
|||||||
let emitted = report_trait_method_mismatch(
|
let emitted = report_trait_method_mismatch(
|
||||||
infcx,
|
infcx,
|
||||||
cause,
|
cause,
|
||||||
|
param_env,
|
||||||
terr,
|
terr,
|
||||||
(trait_m, trait_sig),
|
(trait_m, trait_sig),
|
||||||
(impl_m, impl_sig),
|
(impl_m, impl_sig),
|
||||||
@ -575,10 +576,10 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
|||||||
hir.get_if_local(impl_m.def_id)
|
hir.get_if_local(impl_m.def_id)
|
||||||
.and_then(|node| node.fn_decl())
|
.and_then(|node| node.fn_decl())
|
||||||
.map(|decl| (decl.output.span(), Cow::from("return type in trait"), false)),
|
.map(|decl| (decl.output.span(), Cow::from("return type in trait"), false)),
|
||||||
Some(infer::ValuePairs::Terms(ExpectedFound {
|
Some(param_env.and(infer::ValuePairs::Terms(ExpectedFound {
|
||||||
expected: trait_return_ty.into(),
|
expected: trait_return_ty.into(),
|
||||||
found: impl_return_ty.into(),
|
found: impl_return_ty.into(),
|
||||||
})),
|
}))),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
@ -602,6 +603,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
|||||||
let emitted = report_trait_method_mismatch(
|
let emitted = report_trait_method_mismatch(
|
||||||
infcx,
|
infcx,
|
||||||
cause,
|
cause,
|
||||||
|
param_env,
|
||||||
terr,
|
terr,
|
||||||
(trait_m, trait_sig),
|
(trait_m, trait_sig),
|
||||||
(impl_m, impl_sig),
|
(impl_m, impl_sig),
|
||||||
@ -915,6 +917,7 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
|||||||
fn report_trait_method_mismatch<'tcx>(
|
fn report_trait_method_mismatch<'tcx>(
|
||||||
infcx: &InferCtxt<'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
mut cause: ObligationCause<'tcx>,
|
mut cause: ObligationCause<'tcx>,
|
||||||
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
terr: TypeError<'tcx>,
|
terr: TypeError<'tcx>,
|
||||||
(trait_m, trait_sig): (ty::AssocItem, ty::FnSig<'tcx>),
|
(trait_m, trait_sig): (ty::AssocItem, ty::FnSig<'tcx>),
|
||||||
(impl_m, impl_sig): (ty::AssocItem, ty::FnSig<'tcx>),
|
(impl_m, impl_sig): (ty::AssocItem, ty::FnSig<'tcx>),
|
||||||
@ -1000,10 +1003,10 @@ fn report_trait_method_mismatch<'tcx>(
|
|||||||
&mut diag,
|
&mut diag,
|
||||||
&cause,
|
&cause,
|
||||||
trait_err_span.map(|sp| (sp, Cow::from("type in trait"), false)),
|
trait_err_span.map(|sp| (sp, Cow::from("type in trait"), false)),
|
||||||
Some(infer::ValuePairs::PolySigs(ExpectedFound {
|
Some(param_env.and(infer::ValuePairs::PolySigs(ExpectedFound {
|
||||||
expected: ty::Binder::dummy(trait_sig),
|
expected: ty::Binder::dummy(trait_sig),
|
||||||
found: ty::Binder::dummy(impl_sig),
|
found: ty::Binder::dummy(impl_sig),
|
||||||
})),
|
}))),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
@ -1797,10 +1800,10 @@ fn compare_const_predicate_entailment<'tcx>(
|
|||||||
&mut diag,
|
&mut diag,
|
||||||
&cause,
|
&cause,
|
||||||
trait_c_span.map(|span| (span, Cow::from("type in trait"), false)),
|
trait_c_span.map(|span| (span, Cow::from("type in trait"), false)),
|
||||||
Some(infer::ValuePairs::Terms(ExpectedFound {
|
Some(param_env.and(infer::ValuePairs::Terms(ExpectedFound {
|
||||||
expected: trait_ty.into(),
|
expected: trait_ty.into(),
|
||||||
found: impl_ty.into(),
|
found: impl_ty.into(),
|
||||||
})),
|
}))),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
@ -646,10 +646,10 @@ pub fn check_function_signature<'tcx>(
|
|||||||
&mut diag,
|
&mut diag,
|
||||||
&cause,
|
&cause,
|
||||||
None,
|
None,
|
||||||
Some(infer::ValuePairs::PolySigs(ExpectedFound {
|
Some(param_env.and(infer::ValuePairs::PolySigs(ExpectedFound {
|
||||||
expected: expected_sig,
|
expected: expected_sig,
|
||||||
found: actual_sig,
|
found: actual_sig,
|
||||||
})),
|
}))),
|
||||||
err,
|
err,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
@ -364,6 +364,7 @@ pub(crate) fn coerce_unsized_info<'tcx>(
|
|||||||
.err_ctxt()
|
.err_ctxt()
|
||||||
.report_mismatched_types(
|
.report_mismatched_types(
|
||||||
&cause,
|
&cause,
|
||||||
|
param_env,
|
||||||
mk_ptr(mt_b.ty),
|
mk_ptr(mt_b.ty),
|
||||||
target,
|
target,
|
||||||
ty::error::TypeError::Mutability,
|
ty::error::TypeError::Mutability,
|
||||||
|
@ -862,7 +862,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// FIXME(effects): better diagnostic
|
// FIXME(effects): better diagnostic
|
||||||
self.err_ctxt().report_mismatched_consts(&cause, effect, param, e).emit();
|
self.err_ctxt()
|
||||||
|
.report_mismatched_consts(&cause, self.param_env, effect, param, e)
|
||||||
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1723,6 +1723,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
|||||||
}) => {
|
}) => {
|
||||||
err = fcx.err_ctxt().report_mismatched_types(
|
err = fcx.err_ctxt().report_mismatched_types(
|
||||||
cause,
|
cause,
|
||||||
|
fcx.param_env,
|
||||||
expected,
|
expected,
|
||||||
found,
|
found,
|
||||||
coercion_error,
|
coercion_error,
|
||||||
@ -1752,6 +1753,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
|||||||
}) => {
|
}) => {
|
||||||
err = fcx.err_ctxt().report_mismatched_types(
|
err = fcx.err_ctxt().report_mismatched_types(
|
||||||
cause,
|
cause,
|
||||||
|
fcx.param_env,
|
||||||
expected,
|
expected,
|
||||||
found,
|
found,
|
||||||
coercion_error,
|
coercion_error,
|
||||||
@ -1787,6 +1789,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
|||||||
_ => {
|
_ => {
|
||||||
err = fcx.err_ctxt().report_mismatched_types(
|
err = fcx.err_ctxt().report_mismatched_types(
|
||||||
cause,
|
cause,
|
||||||
|
fcx.param_env,
|
||||||
expected,
|
expected,
|
||||||
found,
|
found,
|
||||||
coercion_error,
|
coercion_error,
|
||||||
@ -1897,7 +1900,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
|||||||
block_or_return_id: hir::HirId,
|
block_or_return_id: hir::HirId,
|
||||||
expression: Option<&'tcx hir::Expr<'tcx>>,
|
expression: Option<&'tcx hir::Expr<'tcx>>,
|
||||||
) -> Diag<'infcx> {
|
) -> Diag<'infcx> {
|
||||||
let mut err = fcx.err_ctxt().report_mismatched_types(cause, expected, found, ty_err);
|
let mut err =
|
||||||
|
fcx.err_ctxt().report_mismatched_types(cause, fcx.param_env, expected, found, ty_err);
|
||||||
|
|
||||||
let due_to_block = matches!(fcx.tcx.hir_node(block_or_return_id), hir::Node::Block(..));
|
let due_to_block = matches!(fcx.tcx.hir_node(block_or_return_id), hir::Node::Block(..));
|
||||||
|
|
||||||
|
@ -191,7 +191,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
self.at(cause, self.param_env)
|
self.at(cause, self.param_env)
|
||||||
.sup(DefineOpaqueTypes::Yes, expected, actual)
|
.sup(DefineOpaqueTypes::Yes, expected, actual)
|
||||||
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
|
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
|
||||||
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
|
.map_err(|e| {
|
||||||
|
self.err_ctxt().report_mismatched_types(cause, self.param_env, expected, actual, e)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn demand_eqtype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
|
pub(crate) fn demand_eqtype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
|
||||||
@ -218,7 +220,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
self.at(cause, self.param_env)
|
self.at(cause, self.param_env)
|
||||||
.eq(DefineOpaqueTypes::Yes, expected, actual)
|
.eq(DefineOpaqueTypes::Yes, expected, actual)
|
||||||
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
|
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
|
||||||
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
|
.map_err(|e| {
|
||||||
|
self.err_ctxt().report_mismatched_types(cause, self.param_env, expected, actual, e)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn demand_coerce(
|
pub(crate) fn demand_coerce(
|
||||||
@ -271,7 +275,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let expr = expr.peel_drop_temps();
|
let expr = expr.peel_drop_temps();
|
||||||
let cause = self.misc(expr.span);
|
let cause = self.misc(expr.span);
|
||||||
let expr_ty = self.resolve_vars_if_possible(checked_ty);
|
let expr_ty = self.resolve_vars_if_possible(checked_ty);
|
||||||
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e);
|
let mut err =
|
||||||
|
self.err_ctxt().report_mismatched_types(&cause, self.param_env, expected, expr_ty, e);
|
||||||
|
|
||||||
self.emit_coerce_suggestions(&mut err, expr, expr_ty, expected, expected_ty_expr, Some(e));
|
self.emit_coerce_suggestions(&mut err, expr, expr_ty, expected, expected_ty_expr, Some(e));
|
||||||
|
|
||||||
|
@ -827,6 +827,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
formal_and_expected_inputs[mismatch_idx.into()],
|
formal_and_expected_inputs[mismatch_idx.into()],
|
||||||
provided_arg_tys[mismatch_idx.into()].0,
|
provided_arg_tys[mismatch_idx.into()].0,
|
||||||
),
|
),
|
||||||
|
self.param_env,
|
||||||
terr,
|
terr,
|
||||||
);
|
);
|
||||||
err.span_label(
|
err.span_label(
|
||||||
@ -912,7 +913,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let trace =
|
let trace =
|
||||||
mk_trace(provided_span, formal_and_expected_inputs[*expected_idx], provided_ty);
|
mk_trace(provided_span, formal_and_expected_inputs[*expected_idx], provided_ty);
|
||||||
if !matches!(trace.cause.as_failure_code(*e), FailureCode::Error0308) {
|
if !matches!(trace.cause.as_failure_code(*e), FailureCode::Error0308) {
|
||||||
let mut err = self.err_ctxt().report_and_explain_type_error(trace, *e);
|
let mut err =
|
||||||
|
self.err_ctxt().report_and_explain_type_error(trace, self.param_env, *e);
|
||||||
suggest_confusable(&mut err);
|
suggest_confusable(&mut err);
|
||||||
reported = Some(err.emit());
|
reported = Some(err.emit());
|
||||||
return false;
|
return false;
|
||||||
@ -940,7 +942,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let (formal_ty, expected_ty) = formal_and_expected_inputs[*expected_idx];
|
let (formal_ty, expected_ty) = formal_and_expected_inputs[*expected_idx];
|
||||||
let (provided_ty, provided_arg_span) = provided_arg_tys[*provided_idx];
|
let (provided_ty, provided_arg_span) = provided_arg_tys[*provided_idx];
|
||||||
let trace = mk_trace(provided_arg_span, (formal_ty, expected_ty), provided_ty);
|
let trace = mk_trace(provided_arg_span, (formal_ty, expected_ty), provided_ty);
|
||||||
let mut err = self.err_ctxt().report_and_explain_type_error(trace, *err);
|
let mut err =
|
||||||
|
self.err_ctxt().report_and_explain_type_error(trace, self.param_env, *err);
|
||||||
self.emit_coerce_suggestions(
|
self.emit_coerce_suggestions(
|
||||||
&mut err,
|
&mut err,
|
||||||
provided_args[*provided_idx],
|
provided_args[*provided_idx],
|
||||||
@ -1113,7 +1116,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
&mut err,
|
&mut err,
|
||||||
&trace.cause,
|
&trace.cause,
|
||||||
None,
|
None,
|
||||||
Some(trace.values),
|
Some(self.param_env.and(trace.values)),
|
||||||
e,
|
e,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
@ -538,7 +538,13 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
|||||||
// to the feature, like the self type can't reference method args.
|
// to the feature, like the self type can't reference method args.
|
||||||
if self.tcx.features().arbitrary_self_types() {
|
if self.tcx.features().arbitrary_self_types() {
|
||||||
self.err_ctxt()
|
self.err_ctxt()
|
||||||
.report_mismatched_types(&cause, method_self_ty, self_ty, terr)
|
.report_mismatched_types(
|
||||||
|
&cause,
|
||||||
|
self.param_env,
|
||||||
|
method_self_ty,
|
||||||
|
self_ty,
|
||||||
|
terr,
|
||||||
|
)
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
// This has/will have errored in wfcheck, which we cannot depend on from here, as typeck on functions
|
// This has/will have errored in wfcheck, which we cannot depend on from here, as typeck on functions
|
||||||
|
@ -2300,10 +2300,10 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||||||
&mut diag,
|
&mut diag,
|
||||||
&cause,
|
&cause,
|
||||||
None,
|
None,
|
||||||
Some(ValuePairs::PolySigs(ExpectedFound {
|
Some(param_env.and(ValuePairs::PolySigs(ExpectedFound {
|
||||||
expected: ty::Binder::dummy(expected_sig),
|
expected: ty::Binder::dummy(expected_sig),
|
||||||
found: ty::Binder::dummy(sig),
|
found: ty::Binder::dummy(sig),
|
||||||
})),
|
}))),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
@ -75,6 +75,7 @@ use crate::errors::{ObligationCauseFailureCode, TypeErrorAdditionalDiags};
|
|||||||
use crate::infer;
|
use crate::infer;
|
||||||
use crate::infer::relate::{self, RelateResult, TypeRelation};
|
use crate::infer::relate::{self, RelateResult, TypeRelation};
|
||||||
use crate::infer::{InferCtxt, TypeTrace, ValuePairs};
|
use crate::infer::{InferCtxt, TypeTrace, ValuePairs};
|
||||||
|
use crate::solve::deeply_normalize_for_diagnostics;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
|
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
|
||||||
};
|
};
|
||||||
@ -145,21 +146,31 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
pub fn report_mismatched_types(
|
pub fn report_mismatched_types(
|
||||||
&self,
|
&self,
|
||||||
cause: &ObligationCause<'tcx>,
|
cause: &ObligationCause<'tcx>,
|
||||||
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
expected: Ty<'tcx>,
|
expected: Ty<'tcx>,
|
||||||
actual: Ty<'tcx>,
|
actual: Ty<'tcx>,
|
||||||
err: TypeError<'tcx>,
|
err: TypeError<'tcx>,
|
||||||
) -> Diag<'a> {
|
) -> Diag<'a> {
|
||||||
self.report_and_explain_type_error(TypeTrace::types(cause, true, expected, actual), err)
|
self.report_and_explain_type_error(
|
||||||
|
TypeTrace::types(cause, true, expected, actual),
|
||||||
|
param_env,
|
||||||
|
err,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_mismatched_consts(
|
pub fn report_mismatched_consts(
|
||||||
&self,
|
&self,
|
||||||
cause: &ObligationCause<'tcx>,
|
cause: &ObligationCause<'tcx>,
|
||||||
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
expected: ty::Const<'tcx>,
|
expected: ty::Const<'tcx>,
|
||||||
actual: ty::Const<'tcx>,
|
actual: ty::Const<'tcx>,
|
||||||
err: TypeError<'tcx>,
|
err: TypeError<'tcx>,
|
||||||
) -> Diag<'a> {
|
) -> Diag<'a> {
|
||||||
self.report_and_explain_type_error(TypeTrace::consts(cause, true, expected, actual), err)
|
self.report_and_explain_type_error(
|
||||||
|
TypeTrace::consts(cause, true, expected, actual),
|
||||||
|
param_env,
|
||||||
|
err,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
||||||
@ -1133,7 +1144,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
diag: &mut Diag<'_>,
|
diag: &mut Diag<'_>,
|
||||||
cause: &ObligationCause<'tcx>,
|
cause: &ObligationCause<'tcx>,
|
||||||
secondary_span: Option<(Span, Cow<'static, str>, bool)>,
|
secondary_span: Option<(Span, Cow<'static, str>, bool)>,
|
||||||
mut values: Option<ValuePairs<'tcx>>,
|
mut values: Option<ty::ParamEnvAnd<'tcx, ValuePairs<'tcx>>>,
|
||||||
terr: TypeError<'tcx>,
|
terr: TypeError<'tcx>,
|
||||||
prefer_label: bool,
|
prefer_label: bool,
|
||||||
) {
|
) {
|
||||||
@ -1241,8 +1252,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
let (expected_found, exp_found, is_simple_error, values) = match values {
|
let (expected_found, exp_found, is_simple_error, values) = match values {
|
||||||
None => (None, Mismatch::Fixed("type"), false, None),
|
None => (None, Mismatch::Fixed("type"), false, None),
|
||||||
Some(values) => {
|
Some(ty::ParamEnvAnd { param_env: _, value: values }) => {
|
||||||
let values = self.resolve_vars_if_possible(values);
|
let mut values = self.resolve_vars_if_possible(values);
|
||||||
let (is_simple_error, exp_found) = match values {
|
let (is_simple_error, exp_found) = match values {
|
||||||
ValuePairs::Terms(ExpectedFound { expected, found }) => {
|
ValuePairs::Terms(ExpectedFound { expected, found }) => {
|
||||||
match (expected.unpack(), found.unpack()) {
|
match (expected.unpack(), found.unpack()) {
|
||||||
@ -1773,6 +1784,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
pub fn report_and_explain_type_error(
|
pub fn report_and_explain_type_error(
|
||||||
&self,
|
&self,
|
||||||
trace: TypeTrace<'tcx>,
|
trace: TypeTrace<'tcx>,
|
||||||
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
terr: TypeError<'tcx>,
|
terr: TypeError<'tcx>,
|
||||||
) -> Diag<'a> {
|
) -> Diag<'a> {
|
||||||
debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);
|
debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);
|
||||||
@ -1784,7 +1796,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
self.type_error_additional_suggestions(&trace, terr),
|
self.type_error_additional_suggestions(&trace, terr),
|
||||||
);
|
);
|
||||||
let mut diag = self.dcx().create_err(failure_code);
|
let mut diag = self.dcx().create_err(failure_code);
|
||||||
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr, false);
|
self.note_type_err(
|
||||||
|
&mut diag,
|
||||||
|
&trace.cause,
|
||||||
|
None,
|
||||||
|
Some(param_env.and(trace.values)),
|
||||||
|
terr,
|
||||||
|
false,
|
||||||
|
);
|
||||||
diag
|
diag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +295,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
let mut err = match origin {
|
let mut err = match origin {
|
||||||
infer::Subtype(box trace) => {
|
infer::Subtype(box trace) => {
|
||||||
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
|
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
|
||||||
let mut err = self.report_and_explain_type_error(trace, terr);
|
let mut err = self.report_and_explain_type_error(
|
||||||
|
trace,
|
||||||
|
self.tcx.param_env(generic_param_scope),
|
||||||
|
terr,
|
||||||
|
);
|
||||||
match (*sub, *sup) {
|
match (*sub, *sup) {
|
||||||
(ty::RePlaceholder(_), ty::RePlaceholder(_)) => {}
|
(ty::RePlaceholder(_), ty::RePlaceholder(_)) => {}
|
||||||
(ty::RePlaceholder(_), _) => {
|
(ty::RePlaceholder(_), _) => {
|
||||||
@ -646,7 +650,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
infer::Subtype(box trace) => {
|
infer::Subtype(box trace) => {
|
||||||
let terr = TypeError::RegionsPlaceholderMismatch;
|
let terr = TypeError::RegionsPlaceholderMismatch;
|
||||||
return self.report_and_explain_type_error(trace, terr);
|
return self.report_and_explain_type_error(
|
||||||
|
trace,
|
||||||
|
self.tcx.param_env(generic_param_scope),
|
||||||
|
terr,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return self.report_concrete_failure(
|
return self.report_concrete_failure(
|
||||||
|
@ -1290,7 +1290,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
(
|
(
|
||||||
Some((
|
Some((
|
||||||
data.projection_term,
|
data.projection_term,
|
||||||
false,
|
|
||||||
self.resolve_vars_if_possible(normalized_term),
|
self.resolve_vars_if_possible(normalized_term),
|
||||||
data.term,
|
data.term,
|
||||||
)),
|
)),
|
||||||
@ -1335,7 +1334,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
derive_better_type_error(lhs, rhs)
|
derive_better_type_error(lhs, rhs)
|
||||||
{
|
{
|
||||||
(
|
(
|
||||||
Some((lhs, true, self.resolve_vars_if_possible(expected_term), rhs)),
|
Some((lhs, self.resolve_vars_if_possible(expected_term), rhs)),
|
||||||
better_type_err,
|
better_type_err,
|
||||||
)
|
)
|
||||||
} else if let Some(rhs) = rhs.to_alias_term()
|
} else if let Some(rhs) = rhs.to_alias_term()
|
||||||
@ -1343,7 +1342,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
derive_better_type_error(rhs, lhs)
|
derive_better_type_error(rhs, lhs)
|
||||||
{
|
{
|
||||||
(
|
(
|
||||||
Some((rhs, true, self.resolve_vars_if_possible(expected_term), lhs)),
|
Some((rhs, self.resolve_vars_if_possible(expected_term), lhs)),
|
||||||
better_type_err,
|
better_type_err,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@ -1354,7 +1353,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let msg = values
|
let msg = values
|
||||||
.and_then(|(predicate, _, normalized_term, expected_term)| {
|
.and_then(|(predicate, normalized_term, expected_term)| {
|
||||||
self.maybe_detailed_projection_msg(predicate, normalized_term, expected_term)
|
self.maybe_detailed_projection_msg(predicate, normalized_term, expected_term)
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
@ -1431,8 +1430,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
&mut diag,
|
&mut diag,
|
||||||
&obligation.cause,
|
&obligation.cause,
|
||||||
secondary_span,
|
secondary_span,
|
||||||
values.map(|(_, _, normalized_ty, expected_ty)| {
|
values.map(|(_, normalized_ty, expected_ty)| {
|
||||||
infer::ValuePairs::Terms(ExpectedFound::new(true, expected_ty, normalized_ty))
|
obligation.param_env.and(infer::ValuePairs::Terms(ExpectedFound::new(
|
||||||
|
true,
|
||||||
|
expected_ty,
|
||||||
|
normalized_ty,
|
||||||
|
)))
|
||||||
}),
|
}),
|
||||||
err,
|
err,
|
||||||
false,
|
false,
|
||||||
@ -2654,6 +2657,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
};
|
};
|
||||||
self.report_and_explain_type_error(
|
self.report_and_explain_type_error(
|
||||||
TypeTrace::trait_refs(&cause, true, expected_trait_ref, found_trait_ref),
|
TypeTrace::trait_refs(&cause, true, expected_trait_ref, found_trait_ref),
|
||||||
|
obligation.param_env,
|
||||||
terr,
|
terr,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -2744,6 +2748,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
{
|
{
|
||||||
return Ok(self.report_and_explain_type_error(
|
return Ok(self.report_and_explain_type_error(
|
||||||
TypeTrace::trait_refs(&obligation.cause, true, expected_trait_ref, found_trait_ref),
|
TypeTrace::trait_refs(&obligation.cause, true, expected_trait_ref, found_trait_ref),
|
||||||
|
obligation.param_env,
|
||||||
ty::error::TypeError::Mismatch,
|
ty::error::TypeError::Mismatch,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -287,6 +287,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
FulfillmentErrorCode::Subtype(ref expected_found, ref err) => self
|
FulfillmentErrorCode::Subtype(ref expected_found, ref err) => self
|
||||||
.report_mismatched_types(
|
.report_mismatched_types(
|
||||||
&error.obligation.cause,
|
&error.obligation.cause,
|
||||||
|
error.obligation.param_env,
|
||||||
expected_found.expected,
|
expected_found.expected,
|
||||||
expected_found.found,
|
expected_found.found,
|
||||||
*err,
|
*err,
|
||||||
@ -295,6 +296,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
FulfillmentErrorCode::ConstEquate(ref expected_found, ref err) => {
|
FulfillmentErrorCode::ConstEquate(ref expected_found, ref err) => {
|
||||||
let mut diag = self.report_mismatched_consts(
|
let mut diag = self.report_mismatched_consts(
|
||||||
&error.obligation.cause,
|
&error.obligation.cause,
|
||||||
|
error.obligation.param_env,
|
||||||
expected_found.expected,
|
expected_found.expected,
|
||||||
expected_found.found,
|
expected_found.found,
|
||||||
*err,
|
*err,
|
||||||
|
Loading…
Reference in New Issue
Block a user