Rollup merge of #121359 - lcnr:typesystem-cleanup, r=compiler-errors
miscellaneous type system improvements see review comments for rationale r? `@compiler-errors`
This commit is contained in:
commit
8d27fc86f2
9 changed files with 169 additions and 151 deletions
|
@ -194,7 +194,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
ty::ConstKind::Infer(InferConst::Var(b_vid)),
|
ty::ConstKind::Infer(InferConst::Var(b_vid)),
|
||||||
) => {
|
) => {
|
||||||
self.inner.borrow_mut().const_unification_table().union(a_vid, b_vid);
|
self.inner.borrow_mut().const_unification_table().union(a_vid, b_vid);
|
||||||
return Ok(a);
|
Ok(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
|
@ -202,7 +202,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
ty::ConstKind::Infer(InferConst::EffectVar(b_vid)),
|
ty::ConstKind::Infer(InferConst::EffectVar(b_vid)),
|
||||||
) => {
|
) => {
|
||||||
self.inner.borrow_mut().effect_unification_table().union(a_vid, b_vid);
|
self.inner.borrow_mut().effect_unification_table().union(a_vid, b_vid);
|
||||||
return Ok(a);
|
Ok(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All other cases of inference with other variables are errors.
|
// All other cases of inference with other variables are errors.
|
||||||
|
@ -220,19 +220,21 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
(ty::ConstKind::Infer(InferConst::Var(vid)), _) => {
|
(ty::ConstKind::Infer(InferConst::Var(vid)), _) => {
|
||||||
return self.instantiate_const_var(vid, b);
|
self.instantiate_const_var(relation, relation.a_is_expected(), vid, b)?;
|
||||||
|
Ok(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
|
(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
|
||||||
return self.instantiate_const_var(vid, a);
|
self.instantiate_const_var(relation, !relation.a_is_expected(), vid, a)?;
|
||||||
|
Ok(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
(ty::ConstKind::Infer(InferConst::EffectVar(vid)), _) => {
|
(ty::ConstKind::Infer(InferConst::EffectVar(vid)), _) => {
|
||||||
return Ok(self.unify_effect_variable(vid, b));
|
Ok(self.unify_effect_variable(vid, b))
|
||||||
}
|
}
|
||||||
|
|
||||||
(_, ty::ConstKind::Infer(InferConst::EffectVar(vid))) => {
|
(_, ty::ConstKind::Infer(InferConst::EffectVar(vid))) => {
|
||||||
return Ok(self.unify_effect_variable(vid, a));
|
Ok(self.unify_effect_variable(vid, a))
|
||||||
}
|
}
|
||||||
|
|
||||||
(ty::ConstKind::Unevaluated(..), _) | (_, ty::ConstKind::Unevaluated(..))
|
(ty::ConstKind::Unevaluated(..), _) | (_, ty::ConstKind::Unevaluated(..))
|
||||||
|
@ -240,7 +242,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
{
|
{
|
||||||
let (a, b) = if relation.a_is_expected() { (a, b) } else { (b, a) };
|
let (a, b) = if relation.a_is_expected() { (a, b) } else { (b, a) };
|
||||||
|
|
||||||
relation.register_predicates([ty::Binder::dummy(if self.next_trait_solver() {
|
relation.register_predicates([if self.next_trait_solver() {
|
||||||
ty::PredicateKind::AliasRelate(
|
ty::PredicateKind::AliasRelate(
|
||||||
a.into(),
|
a.into(),
|
||||||
b.into(),
|
b.into(),
|
||||||
|
@ -248,14 +250,12 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
ty::PredicateKind::ConstEquate(a, b)
|
ty::PredicateKind::ConstEquate(a, b)
|
||||||
})]);
|
}]);
|
||||||
|
|
||||||
return Ok(b);
|
Ok(b)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => ty::relate::structurally_relate_consts(relation, a, b),
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::relate::structurally_relate_consts(relation, a, b)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unify_integral_variable(
|
fn unify_integral_variable(
|
||||||
|
|
|
@ -22,7 +22,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// subtyping could occur. This also does the occurs checks, detecting whether
|
/// subtyping could occur. This also does the occurs checks, detecting whether
|
||||||
/// instantiating `target_vid` would result in a cyclic type. We eagerly error
|
/// instantiating `target_vid` would result in a cyclic type. We eagerly error
|
||||||
/// in this case.
|
/// in this case.
|
||||||
#[instrument(skip(self, relation, target_is_expected), level = "debug")]
|
#[instrument(level = "debug", skip(self, relation, target_is_expected))]
|
||||||
pub(super) fn instantiate_ty_var<R: ObligationEmittingRelation<'tcx>>(
|
pub(super) fn instantiate_ty_var<R: ObligationEmittingRelation<'tcx>>(
|
||||||
&self,
|
&self,
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
|
@ -158,26 +158,22 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// As `3 + 4` contains `N` in its args, this must not succeed.
|
/// As `3 + 4` contains `N` in its args, this must not succeed.
|
||||||
///
|
///
|
||||||
/// See `tests/ui/const-generics/occurs-check/` for more examples where this is relevant.
|
/// See `tests/ui/const-generics/occurs-check/` for more examples where this is relevant.
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self, relation))]
|
||||||
pub(super) fn instantiate_const_var(
|
pub(super) fn instantiate_const_var<R: ObligationEmittingRelation<'tcx>>(
|
||||||
&self,
|
&self,
|
||||||
|
relation: &mut R,
|
||||||
|
target_is_expected: bool,
|
||||||
target_vid: ty::ConstVid,
|
target_vid: ty::ConstVid,
|
||||||
source_ct: ty::Const<'tcx>,
|
source_ct: ty::Const<'tcx>,
|
||||||
) -> RelateResult<'tcx, ty::Const<'tcx>> {
|
) -> RelateResult<'tcx, ()> {
|
||||||
let span = match self.inner.borrow_mut().const_unification_table().probe_value(target_vid) {
|
|
||||||
ConstVariableValue::Known { value } => {
|
|
||||||
bug!("instantiating a known const var: {target_vid:?} {value} {source_ct}")
|
|
||||||
}
|
|
||||||
ConstVariableValue::Unknown { origin, universe: _ } => origin.span,
|
|
||||||
};
|
|
||||||
// FIXME(generic_const_exprs): Occurs check failures for unevaluated
|
// FIXME(generic_const_exprs): Occurs check failures for unevaluated
|
||||||
// constants and generic expressions are not yet handled correctly.
|
// constants and generic expressions are not yet handled correctly.
|
||||||
let Generalization { value_may_be_infer: generalized_ct, has_unconstrained_ty_var } =
|
let Generalization { value_may_be_infer: generalized_ct, has_unconstrained_ty_var } =
|
||||||
self.generalize(span, target_vid, ty::Variance::Invariant, source_ct)?;
|
self.generalize(relation.span(), target_vid, ty::Variance::Invariant, source_ct)?;
|
||||||
|
|
||||||
debug_assert!(!generalized_ct.is_ct_infer());
|
debug_assert!(!generalized_ct.is_ct_infer());
|
||||||
if has_unconstrained_ty_var {
|
if has_unconstrained_ty_var {
|
||||||
span_bug!(span, "unconstrained ty var when generalizing `{source_ct:?}`");
|
bug!("unconstrained ty var when generalizing `{source_ct:?}`");
|
||||||
}
|
}
|
||||||
|
|
||||||
self.inner
|
self.inner
|
||||||
|
@ -185,9 +181,25 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
.const_unification_table()
|
.const_unification_table()
|
||||||
.union_value(target_vid, ConstVariableValue::Known { value: generalized_ct });
|
.union_value(target_vid, ConstVariableValue::Known { value: generalized_ct });
|
||||||
|
|
||||||
// FIXME(generic_const_exprs): We have to make sure we actually equate
|
// HACK: make sure that we `a_is_expected` continues to be
|
||||||
// `generalized_ct` and `source_ct` here.
|
// correct when relating the generalized type with the source.
|
||||||
Ok(generalized_ct)
|
if target_is_expected == relation.a_is_expected() {
|
||||||
|
relation.relate_with_variance(
|
||||||
|
ty::Variance::Invariant,
|
||||||
|
ty::VarianceDiagInfo::default(),
|
||||||
|
generalized_ct,
|
||||||
|
source_ct,
|
||||||
|
)?;
|
||||||
|
} else {
|
||||||
|
relation.relate_with_variance(
|
||||||
|
ty::Variance::Invariant,
|
||||||
|
ty::VarianceDiagInfo::default(),
|
||||||
|
source_ct,
|
||||||
|
generalized_ct,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to generalize `source_term` for the type variable `target_vid`.
|
/// Attempts to generalize `source_term` for the type variable `target_vid`.
|
||||||
|
@ -287,6 +299,49 @@ impl<'tcx> Generalizer<'_, 'tcx> {
|
||||||
ty::TermKind::Const(ct) => TypeError::CyclicConst(ct),
|
ty::TermKind::Const(ct) => TypeError::CyclicConst(ct),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An occurs check failure inside of an alias does not mean
|
||||||
|
/// that the types definitely don't unify. We may be able
|
||||||
|
/// to normalize the alias after all.
|
||||||
|
///
|
||||||
|
/// We handle this by lazily equating the alias and generalizing
|
||||||
|
/// it to an inference variable.
|
||||||
|
///
|
||||||
|
/// This is incomplete and will hopefully soon get fixed by #119106.
|
||||||
|
fn generalize_alias_ty(
|
||||||
|
&mut self,
|
||||||
|
alias: ty::AliasTy<'tcx>,
|
||||||
|
) -> Result<Ty<'tcx>, TypeError<'tcx>> {
|
||||||
|
let is_nested_alias = mem::replace(&mut self.in_alias, true);
|
||||||
|
let result = match self.relate(alias, alias) {
|
||||||
|
Ok(alias) => Ok(alias.to_ty(self.tcx())),
|
||||||
|
Err(e) => {
|
||||||
|
if is_nested_alias {
|
||||||
|
return Err(e);
|
||||||
|
} else {
|
||||||
|
let mut visitor = MaxUniverse::new();
|
||||||
|
alias.visit_with(&mut visitor);
|
||||||
|
let infer_replacement_is_complete =
|
||||||
|
self.for_universe.can_name(visitor.max_universe())
|
||||||
|
&& !alias.has_escaping_bound_vars();
|
||||||
|
if !infer_replacement_is_complete {
|
||||||
|
warn!("may incompletely handle alias type: {alias:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("generalization failure in alias");
|
||||||
|
Ok(self.infcx.next_ty_var_in_universe(
|
||||||
|
TypeVariableOrigin {
|
||||||
|
kind: TypeVariableOriginKind::MiscVariable,
|
||||||
|
span: self.span,
|
||||||
|
},
|
||||||
|
self.for_universe,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
self.in_alias = is_nested_alias;
|
||||||
|
result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
||||||
|
@ -433,43 +488,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Alias(kind, data) => {
|
ty::Alias(_, data) => self.generalize_alias_ty(data),
|
||||||
// An occurs check failure inside of an alias does not mean
|
|
||||||
// that the types definitely don't unify. We may be able
|
|
||||||
// to normalize the alias after all.
|
|
||||||
//
|
|
||||||
// We handle this by lazily equating the alias and generalizing
|
|
||||||
// it to an inference variable.
|
|
||||||
let is_nested_alias = mem::replace(&mut self.in_alias, true);
|
|
||||||
let result = match self.relate(data, data) {
|
|
||||||
Ok(data) => Ok(Ty::new_alias(self.tcx(), kind, data)),
|
|
||||||
Err(e) => {
|
|
||||||
if is_nested_alias {
|
|
||||||
return Err(e);
|
|
||||||
} else {
|
|
||||||
let mut visitor = MaxUniverse::new();
|
|
||||||
t.visit_with(&mut visitor);
|
|
||||||
let infer_replacement_is_complete =
|
|
||||||
self.for_universe.can_name(visitor.max_universe())
|
|
||||||
&& !t.has_escaping_bound_vars();
|
|
||||||
if !infer_replacement_is_complete {
|
|
||||||
warn!("may incompletely handle alias type: {t:?}");
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!("generalization failure in alias");
|
|
||||||
Ok(self.infcx.next_ty_var_in_universe(
|
|
||||||
TypeVariableOrigin {
|
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: self.span,
|
|
||||||
},
|
|
||||||
self.for_universe,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
self.in_alias = is_nested_alias;
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => relate::structurally_relate_tys(self, t, t),
|
_ => relate::structurally_relate_tys(self, t, t),
|
||||||
}?;
|
}?;
|
||||||
|
|
|
@ -85,25 +85,16 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Do not emit an error if normalization is known to fail but instead
|
self.fulfill_cx.register_predicate_obligation(infcx, obligation);
|
||||||
// keep the projection unnormalized. This is the case for projections
|
let errors = self.fulfill_cx.select_all_or_error(infcx);
|
||||||
// with a `T: Trait` where-clause and opaque types outside of the defining
|
if !errors.is_empty() {
|
||||||
// scope.
|
return Err(errors);
|
||||||
let result = if infcx.predicate_may_hold(&obligation) {
|
}
|
||||||
self.fulfill_cx.register_predicate_obligation(infcx, obligation);
|
|
||||||
let errors = self.fulfill_cx.select_all_or_error(infcx);
|
|
||||||
if !errors.is_empty() {
|
|
||||||
return Err(errors);
|
|
||||||
}
|
|
||||||
let ty = infcx.resolve_vars_if_possible(new_infer_ty);
|
|
||||||
|
|
||||||
// Alias is guaranteed to be fully structurally resolved,
|
|
||||||
// so we can super fold here.
|
|
||||||
ty.try_super_fold_with(self)?
|
|
||||||
} else {
|
|
||||||
alias_ty.try_super_fold_with(self)?
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// Alias is guaranteed to be fully structurally resolved,
|
||||||
|
// so we can super fold here.
|
||||||
|
let ty = infcx.resolve_vars_if_possible(new_infer_ty);
|
||||||
|
let result = ty.try_super_fold_with(self)?;
|
||||||
self.depth -= 1;
|
self.depth -= 1;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
@ -178,6 +169,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
|
||||||
Ok(t)
|
Ok(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip(self), ret)]
|
||||||
fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
|
fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
|
||||||
let infcx = self.at.infcx;
|
let infcx = self.at.infcx;
|
||||||
debug_assert_eq!(ty, infcx.shallow_resolve(ty));
|
debug_assert_eq!(ty, infcx.shallow_resolve(ty));
|
||||||
|
@ -204,6 +196,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip(self), ret)]
|
||||||
fn try_fold_const(&mut self, ct: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
|
fn try_fold_const(&mut self, ct: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
|
||||||
let infcx = self.at.infcx;
|
let infcx = self.at.infcx;
|
||||||
debug_assert_eq!(ct, infcx.shallow_resolve(ct));
|
debug_assert_eq!(ct, infcx.shallow_resolve(ct));
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
use crate::solve::EvalCtxt;
|
||||||
|
use rustc_middle::traits::solve::{Certainty, Goal, QueryResult};
|
||||||
|
use rustc_middle::ty;
|
||||||
|
|
||||||
|
impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||||
|
#[instrument(level = "debug", skip(self), ret)]
|
||||||
|
pub(super) fn normalize_anon_const(
|
||||||
|
&mut self,
|
||||||
|
goal: Goal<'tcx, ty::NormalizesTo<'tcx>>,
|
||||||
|
) -> QueryResult<'tcx> {
|
||||||
|
if let Some(normalized_const) = self.try_const_eval_resolve(
|
||||||
|
goal.param_env,
|
||||||
|
ty::UnevaluatedConst::new(goal.predicate.alias.def_id, goal.predicate.alias.args),
|
||||||
|
self.tcx()
|
||||||
|
.type_of(goal.predicate.alias.def_id)
|
||||||
|
.no_bound_vars()
|
||||||
|
.expect("const ty should not rely on other generics"),
|
||||||
|
) {
|
||||||
|
self.eq(goal.param_env, normalized_const, goal.predicate.term.ct().unwrap())?;
|
||||||
|
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||||
|
} else {
|
||||||
|
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,8 +18,9 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_middle::ty::{ToPredicate, TypeVisitableExt};
|
use rustc_middle::ty::{ToPredicate, TypeVisitableExt};
|
||||||
use rustc_span::{sym, ErrorGuaranteed, DUMMY_SP};
|
use rustc_span::{sym, ErrorGuaranteed, DUMMY_SP};
|
||||||
|
|
||||||
|
mod anon_const;
|
||||||
mod inherent;
|
mod inherent;
|
||||||
mod opaques;
|
mod opaque_types;
|
||||||
mod weak_types;
|
mod weak_types;
|
||||||
|
|
||||||
impl<'tcx> EvalCtxt<'_, 'tcx> {
|
impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||||
|
@ -31,34 +32,34 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||||
let def_id = goal.predicate.def_id();
|
let def_id = goal.predicate.def_id();
|
||||||
match self.tcx().def_kind(def_id) {
|
match self.tcx().def_kind(def_id) {
|
||||||
DefKind::AssocTy | DefKind::AssocConst => {
|
DefKind::AssocTy | DefKind::AssocConst => {
|
||||||
// To only compute normalization once for each projection we only
|
match self.tcx().associated_item(def_id).container {
|
||||||
// assemble normalization candidates if the expected term is an
|
ty::AssocItemContainer::TraitContainer => {
|
||||||
// unconstrained inference variable.
|
// To only compute normalization once for each projection we only
|
||||||
//
|
// assemble normalization candidates if the expected term is an
|
||||||
// Why: For better cache hits, since if we have an unconstrained RHS then
|
// unconstrained inference variable.
|
||||||
// there are only as many cache keys as there are (canonicalized) alias
|
//
|
||||||
// types in each normalizes-to goal. This also weakens inference in a
|
// Why: For better cache hits, since if we have an unconstrained RHS then
|
||||||
// forwards-compatible way so we don't use the value of the RHS term to
|
// there are only as many cache keys as there are (canonicalized) alias
|
||||||
// affect candidate assembly for projections.
|
// types in each normalizes-to goal. This also weakens inference in a
|
||||||
//
|
// forwards-compatible way so we don't use the value of the RHS term to
|
||||||
// E.g. for `<T as Trait>::Assoc == u32` we recursively compute the goal
|
// affect candidate assembly for projections.
|
||||||
// `exists<U> <T as Trait>::Assoc == U` and then take the resulting type for
|
//
|
||||||
// `U` and equate it with `u32`. This means that we don't need a separate
|
// E.g. for `<T as Trait>::Assoc == u32` we recursively compute the goal
|
||||||
// projection cache in the solver, since we're piggybacking off of regular
|
// `exists<U> <T as Trait>::Assoc == U` and then take the resulting type for
|
||||||
// goal caching.
|
// `U` and equate it with `u32`. This means that we don't need a separate
|
||||||
if self.term_is_fully_unconstrained(goal) {
|
// projection cache in the solver, since we're piggybacking off of regular
|
||||||
match self.tcx().associated_item(def_id).container {
|
// goal caching.
|
||||||
ty::AssocItemContainer::TraitContainer => {
|
if self.term_is_fully_unconstrained(goal) {
|
||||||
let candidates = self.assemble_and_evaluate_candidates(goal);
|
let candidates = self.assemble_and_evaluate_candidates(goal);
|
||||||
self.merge_candidates(candidates)
|
self.merge_candidates(candidates)
|
||||||
}
|
} else {
|
||||||
ty::AssocItemContainer::ImplContainer => {
|
self.set_normalizes_to_hack_goal(goal);
|
||||||
self.normalize_inherent_associated_type(goal)
|
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
ty::AssocItemContainer::ImplContainer => {
|
||||||
self.set_normalizes_to_hack_goal(goal);
|
self.normalize_inherent_associated_type(goal)
|
||||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DefKind::AnonConst => self.normalize_anon_const(goal),
|
DefKind::AnonConst => self.normalize_anon_const(goal),
|
||||||
|
@ -67,26 +68,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||||
kind => bug!("unknown DefKind {} in projection goal: {goal:#?}", kind.descr(def_id)),
|
kind => bug!("unknown DefKind {} in projection goal: {goal:#?}", kind.descr(def_id)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(self), ret)]
|
|
||||||
fn normalize_anon_const(
|
|
||||||
&mut self,
|
|
||||||
goal: Goal<'tcx, ty::NormalizesTo<'tcx>>,
|
|
||||||
) -> QueryResult<'tcx> {
|
|
||||||
if let Some(normalized_const) = self.try_const_eval_resolve(
|
|
||||||
goal.param_env,
|
|
||||||
ty::UnevaluatedConst::new(goal.predicate.alias.def_id, goal.predicate.alias.args),
|
|
||||||
self.tcx()
|
|
||||||
.type_of(goal.predicate.alias.def_id)
|
|
||||||
.no_bound_vars()
|
|
||||||
.expect("const ty should not rely on other generics"),
|
|
||||||
) {
|
|
||||||
self.eq(goal.param_env, normalized_const, goal.predicate.term.ct().unwrap())?;
|
|
||||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
|
||||||
} else {
|
|
||||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
|
impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())`
|
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())`
|
||||||
--> $DIR/associated-type.rs:31:1
|
--> $DIR/associated-type.rs:31:1
|
||||||
|
|
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
|
||||||
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), _)>` for type `for<'a> fn(&'a (), _)`
|
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), _)>` for type `for<'a> fn(&'a (), _)`
|
||||||
--> $DIR/associated-type.rs:31:1
|
--> $DIR/associated-type.rs:31:1
|
||||||
|
|
|
|
||||||
|
|
|
@ -13,14 +13,14 @@ LL | #![feature(lazy_type_alias)]
|
||||||
= note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
|
= note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
|
||||||
= note: `#[warn(incomplete_features)]` on by default
|
= note: `#[warn(incomplete_features)]` on by default
|
||||||
|
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }
|
||||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) })
|
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }
|
||||||
error[E0119]: conflicting implementations of trait `Overlap<fn(_)>` for type `fn(_)`
|
error[E0119]: conflicting implementations of trait `Overlap<fn(_)>` for type `fn(_)`
|
||||||
--> $DIR/issue-118950-root-region.rs:19:1
|
--> $DIR/issue-118950-root-region.rs:19:1
|
||||||
|
|
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue