It's not about types or consts, but the lack of regions
This commit is contained in:
parent
ead49f0beb
commit
c7b6ebdf7c
30 changed files with 71 additions and 77 deletions
|
@ -236,9 +236,9 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
|||
}
|
||||
|
||||
Err(ErrorHandled::TooGeneric) => {
|
||||
let err = if uv.has_infer_types_or_consts() {
|
||||
let err = if uv.has_non_region_infer() {
|
||||
NotConstEvaluatable::MentionsInfer
|
||||
} else if uv.has_param_types_or_consts() {
|
||||
} else if uv.has_non_region_param() {
|
||||
NotConstEvaluatable::MentionsParam
|
||||
} else {
|
||||
let guar = infcx.tcx.sess.delay_span_bug(span, format!("Missing value for constant, but no error reported?"));
|
||||
|
@ -254,7 +254,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
|||
}
|
||||
Err(ErrorHandled::Reported(e)) => Err(NotConstEvaluatable::Error(e)),
|
||||
Ok(_) => {
|
||||
if uv.substs.has_param_types_or_consts() {
|
||||
if uv.substs.has_non_region_param() {
|
||||
assert!(matches!(infcx.tcx.def_kind(uv.def.did), DefKind::AnonConst));
|
||||
let mir_body = infcx.tcx.mir_for_ctfe_opt_const_arg(uv.def);
|
||||
|
||||
|
|
|
@ -661,7 +661,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
);
|
||||
}
|
||||
}
|
||||
} else if !trait_ref.has_infer_types_or_consts()
|
||||
} else if !trait_ref.has_non_region_infer()
|
||||
&& self.predicate_can_apply(obligation.param_env, trait_ref)
|
||||
{
|
||||
// If a where-clause may be useful, remind the
|
||||
|
@ -2093,7 +2093,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// Pick the first substitution that still contains inference variables as the one
|
||||
// we're going to emit an error for. If there are none (see above), fall back to
|
||||
// a more general error.
|
||||
let subst = data.trait_ref.substs.iter().find(|s| s.has_infer_types_or_consts());
|
||||
let subst = data.trait_ref.substs.iter().find(|s| s.has_non_region_infer());
|
||||
|
||||
let mut err = if let Some(subst) = subst {
|
||||
self.emit_inference_failure_err(body_id, span, subst, ErrorCode::E0283, true)
|
||||
|
@ -2323,7 +2323,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
.substs
|
||||
.iter()
|
||||
.chain(Some(data.term.into_arg()))
|
||||
.find(|g| g.has_infer_types_or_consts());
|
||||
.find(|g| g.has_non_region_infer());
|
||||
if let Some(subst) = subst {
|
||||
let mut err = self.emit_inference_failure_err(
|
||||
body_id,
|
||||
|
@ -2352,7 +2352,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
if predicate.references_error() || self.is_tainted_by_errors() {
|
||||
return;
|
||||
}
|
||||
let subst = data.substs.iter().find(|g| g.has_infer_types_or_consts());
|
||||
let subst = data.substs.iter().find(|g| g.has_non_region_infer());
|
||||
if let Some(subst) = subst {
|
||||
let err = self.emit_inference_failure_err(
|
||||
body_id,
|
||||
|
|
|
@ -1231,7 +1231,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
return;
|
||||
}
|
||||
let trait_pred = self.resolve_vars_if_possible(trait_pred);
|
||||
if trait_pred.has_infer_types_or_consts() {
|
||||
if trait_pred.has_non_region_infer() {
|
||||
// Do not ICE while trying to find if a reborrow would succeed on a trait with
|
||||
// unresolved bindings.
|
||||
return;
|
||||
|
|
|
@ -279,7 +279,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
|||
|
||||
debug!(?obligation, "pre-resolve");
|
||||
|
||||
if obligation.predicate.has_infer_types_or_consts() {
|
||||
if obligation.predicate.has_non_region_infer() {
|
||||
obligation.predicate =
|
||||
self.selcx.infcx().resolve_vars_if_possible(obligation.predicate);
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
|||
)
|
||||
}
|
||||
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
||||
if c1.has_infer_types_or_consts() || c2.has_infer_types_or_consts() {
|
||||
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
||||
ProcessResult::Unchanged
|
||||
} else {
|
||||
// Two different constants using generic parameters ~> error.
|
||||
|
@ -726,11 +726,11 @@ fn substs_infer_vars<'a, 'tcx>(
|
|||
.resolve_vars_if_possible(substs)
|
||||
.skip_binder() // ok because this check doesn't care about regions
|
||||
.iter()
|
||||
.filter(|arg| arg.has_infer_types_or_consts())
|
||||
.filter(|arg| arg.has_non_region_infer())
|
||||
.flat_map(|arg| {
|
||||
let mut walker = arg.walk();
|
||||
while let Some(c) = walker.next() {
|
||||
if !c.has_infer_types_or_consts() {
|
||||
if !c.has_non_region_infer() {
|
||||
walker.visited.remove(&c);
|
||||
walker.skip_current_subtree();
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ pub fn can_type_implement_copy<'tcx>(
|
|||
// to begin with, and point to the bad field's span instead.
|
||||
let cause = if field
|
||||
.ty(tcx, traits::InternalSubsts::identity_for_item(tcx, adt.did()))
|
||||
.has_param_types_or_consts()
|
||||
.has_non_region_param()
|
||||
{
|
||||
parent_cause.clone()
|
||||
} else {
|
||||
|
|
|
@ -170,7 +170,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
|
|||
result
|
||||
);
|
||||
|
||||
if result && ty.has_infer_types_or_consts() {
|
||||
if result && ty.has_non_region_infer() {
|
||||
// Because of inference "guessing", selection can sometimes claim
|
||||
// to succeed while the success requires a guess. To ensure
|
||||
// this function's result remains infallible, we must confirm
|
||||
|
|
|
@ -1488,7 +1488,7 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
|
|||
candidate_set.push_candidate(ctor(data));
|
||||
|
||||
if potentially_unnormalized_candidates
|
||||
&& !obligation.predicate.has_infer_types_or_consts()
|
||||
&& !obligation.predicate.has_non_region_infer()
|
||||
{
|
||||
// HACK: Pick the first trait def candidate for a fully
|
||||
// inferred predicate. This is to allow duplicates that
|
||||
|
|
|
@ -174,7 +174,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
debug!(?stack, ?candidates, "winnowed to {} candidates", candidates.len());
|
||||
|
||||
let needs_infer = stack.obligation.predicate.has_infer_types_or_consts();
|
||||
let needs_infer = stack.obligation.predicate.has_non_region_infer();
|
||||
|
||||
// If there are STILL multiple candidates, we can further
|
||||
// reduce the list by dropping duplicates -- including
|
||||
|
@ -889,11 +889,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &TraitObligation<'tcx>,
|
||||
candidates: &mut SelectionCandidateSet<'tcx>,
|
||||
) {
|
||||
if obligation.has_param_types_or_consts() {
|
||||
if obligation.has_non_region_param() {
|
||||
return;
|
||||
}
|
||||
|
||||
if obligation.has_infer_types_or_consts() {
|
||||
if obligation.has_non_region_infer() {
|
||||
candidates.ambiguous = true;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -728,7 +728,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
)
|
||||
}
|
||||
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
||||
if c1.has_infer_types_or_consts() || c2.has_infer_types_or_consts() {
|
||||
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
||||
Ok(EvaluatedToAmbig)
|
||||
} else {
|
||||
// Two different constants using generic parameters ~> error.
|
||||
|
@ -1520,7 +1520,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
if !generics.params.is_empty()
|
||||
&& obligation.predicate.substs[generics.parent_count..]
|
||||
.iter()
|
||||
.any(|&p| p.has_infer_types_or_consts() && self.infcx.shallow_resolve(p) != p)
|
||||
.any(|&p| p.has_non_region_infer() && self.infcx.shallow_resolve(p) != p)
|
||||
{
|
||||
ProjectionMatchesProjection::Ambiguous
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue