rename query and use NoSolution
This commit is contained in:
parent
a85b0101e6
commit
57ad73aa27
@ -34,6 +34,7 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::infer::canonical::OriginalQueryValues;
|
||||
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
|
||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
|
||||
@ -172,7 +173,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
(relation.param_env(), a.ty(), b.ty()),
|
||||
&mut OriginalQueryValues::default(),
|
||||
);
|
||||
if let Err(()) = self.tcx.check_const_param_definitely_unequal(canonical) {
|
||||
|
||||
if let Err(NoSolution) = self.tcx.check_tys_might_be_eq(canonical) {
|
||||
self.tcx.sess.delay_span_bug(
|
||||
DUMMY_SP,
|
||||
&format!("cannot relate consts of different types (a={:?}, b={:?})", a, b,),
|
||||
|
@ -2172,7 +2172,7 @@ rustc_queries! {
|
||||
/// Used in `super_combine_consts` to ICE if the type of the two consts are definitely not going to end up being
|
||||
/// equal to eachother. This might return `Ok` even if the types are unequal, but will never return `Err` if
|
||||
/// the types might be equal.
|
||||
query check_const_param_definitely_unequal(arg: Canonical<'tcx, (ty::ParamEnv<'tcx>, Ty<'tcx>, Ty<'tcx>)>) -> Result<(), ()> {
|
||||
query check_tys_might_be_eq(arg: Canonical<'tcx, (ty::ParamEnv<'tcx>, Ty<'tcx>, Ty<'tcx>)>) -> Result<(), NoSolution> {
|
||||
desc { "check whether two const param are definitely not equal to eachother"}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_infer::infer::canonical::Canonical;
|
||||
use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
|
||||
use rustc_infer::traits::query::NoSolution;
|
||||
use rustc_infer::{infer::outlives::env::OutlivesEnvironment, traits::FulfillmentError};
|
||||
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeVisitable};
|
||||
use rustc_span::DUMMY_SP;
|
||||
@ -134,10 +135,10 @@ pub fn type_allowed_to_implement_copy<'tcx>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn check_const_param_definitely_unequal<'tcx>(
|
||||
pub fn check_tys_might_be_eq<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
canonical: Canonical<'tcx, (ParamEnv<'tcx>, Ty<'tcx>, Ty<'tcx>)>,
|
||||
) -> Result<(), ()> {
|
||||
) -> Result<(), NoSolution> {
|
||||
let (infcx, (param_env, ty_a, ty_b), _) =
|
||||
tcx.infer_ctxt().build_with_canonical(DUMMY_SP, &canonical);
|
||||
let ocx = ObligationCtxt::new(&infcx);
|
||||
@ -147,5 +148,5 @@ pub fn check_const_param_definitely_unequal<'tcx>(
|
||||
// we don't get errors from obligations being ambiguous.
|
||||
let errors = ocx.select_where_possible();
|
||||
|
||||
if errors.len() > 0 || result.is_err() { Err(()) } else { Ok(()) }
|
||||
if errors.len() > 0 || result.is_err() { Err(NoSolution) } else { Ok(()) }
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
||||
specialization_graph_of: specialize::specialization_graph_provider,
|
||||
specializes: specialize::specializes,
|
||||
subst_and_check_impossible_predicates,
|
||||
check_const_param_definitely_unequal: misc::check_const_param_definitely_unequal,
|
||||
check_tys_might_be_eq: misc::check_tys_might_be_eq,
|
||||
is_impossible_method,
|
||||
..*providers
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user