add TypingMode::Borrowck
This commit is contained in:
parent
990201cb78
commit
509a144eed
131 changed files with 888 additions and 747 deletions
|
@ -330,6 +330,7 @@ where
|
|||
// During analysis, opaques are rigid unless they may be defined by
|
||||
// the current body.
|
||||
TypingMode::Analysis { defining_opaque_types: non_rigid_opaques }
|
||||
| TypingMode::Borrowck { defining_opaque_types: non_rigid_opaques }
|
||||
| TypingMode::PostBorrowckAnalysis { defined_opaque_types: non_rigid_opaques } => {
|
||||
!def_id.as_local().is_some_and(|def_id| non_rigid_opaques.contains(&def_id))
|
||||
}
|
||||
|
|
|
@ -96,6 +96,42 @@ where
|
|||
);
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
}
|
||||
// Very similar to `TypingMode::Analysis` with some notably differences:
|
||||
// - we accept opaque types even if they have non-universal arguments
|
||||
// - we do a structural lookup instead of semantically unifying regions
|
||||
// - the hidden type starts out as the type from HIR typeck with fresh region
|
||||
// variables instead of a fully unconstrained inference variable
|
||||
TypingMode::Borrowck { defining_opaque_types } => {
|
||||
let Some(def_id) = opaque_ty
|
||||
.def_id
|
||||
.as_local()
|
||||
.filter(|&def_id| defining_opaque_types.contains(&def_id))
|
||||
else {
|
||||
self.structurally_instantiate_normalizes_to_term(goal, goal.predicate.alias);
|
||||
return self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
|
||||
};
|
||||
|
||||
let opaque_type_key = ty::OpaqueTypeKey { def_id, args: opaque_ty.args };
|
||||
let actual = self
|
||||
.register_hidden_type_in_storage(opaque_type_key, expected)
|
||||
.unwrap_or_else(|| {
|
||||
let actual =
|
||||
cx.type_of_opaque_hir_typeck(def_id).instantiate(cx, opaque_ty.args);
|
||||
let actual = fold_regions(cx, actual, |re, _dbi| match re.kind() {
|
||||
ty::ReErased => self.next_region_var(),
|
||||
_ => re,
|
||||
});
|
||||
actual
|
||||
});
|
||||
self.eq(goal.param_env, expected, actual)?;
|
||||
self.add_item_bounds_for_hidden_type(
|
||||
def_id.into(),
|
||||
opaque_ty.args,
|
||||
goal.param_env,
|
||||
expected,
|
||||
);
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
}
|
||||
TypingMode::PostBorrowckAnalysis { defined_opaque_types } => {
|
||||
let Some(def_id) = opaque_ty
|
||||
.def_id
|
||||
|
|
|
@ -62,6 +62,7 @@ where
|
|||
response_no_constraints(cx, input, Certainty::overflow(false))
|
||||
}
|
||||
TypingMode::Analysis { .. }
|
||||
| TypingMode::Borrowck { .. }
|
||||
| TypingMode::PostBorrowckAnalysis { .. }
|
||||
| TypingMode::PostAnalysis => Err(NoSolution),
|
||||
},
|
||||
|
|
|
@ -72,6 +72,7 @@ where
|
|||
(ty::ImplPolarity::Reservation, _) => match ecx.typing_mode() {
|
||||
TypingMode::Coherence => Certainty::AMBIGUOUS,
|
||||
TypingMode::Analysis { .. }
|
||||
| TypingMode::Borrowck { .. }
|
||||
| TypingMode::PostBorrowckAnalysis { .. }
|
||||
| TypingMode::PostAnalysis => return Err(NoSolution),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue