提交 ec48b4eb 编写于 作者: N Niko Matsakis

preliminary integration of "pick constraints" into nll solver

上级 3b5a7276
......@@ -385,13 +385,13 @@ pub fn report_region_errors(
option_regions: _,
} => {
let hidden_ty = self.resolve_vars_if_possible(&hidden_ty);
opaque_types::report_unexpected_hidden_region(
opaque_types::unexpected_hidden_region_diagnostic(
self.tcx,
Some(region_scope_tree),
opaque_type_def_id,
hidden_ty,
pick_region,
);
).emit();
}
}
}
......
......@@ -9,6 +9,7 @@
use crate::ty::subst::{InternalSubsts, Kind, SubstsRef, UnpackedKind};
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt};
use crate::util::nodemap::DefIdMap;
use errors::DiagnosticBuilder;
use rustc_data_structures::fx::FxHashMap;
use std::rc::Rc;
......@@ -499,13 +500,13 @@ pub fn infer_opaque_definition_from_instantiation(
}
}
pub fn report_unexpected_hidden_region(
pub fn unexpected_hidden_region_diagnostic(
tcx: TyCtxt<'tcx>,
region_scope_tree: Option<&region::ScopeTree>,
opaque_type_def_id: DefId,
hidden_ty: Ty<'tcx>,
hidden_region: ty::Region<'tcx>,
) {
) -> DiagnosticBuilder<'tcx> {
let span = tcx.def_span(opaque_type_def_id);
let mut err = struct_span_err!(
tcx.sess,
......@@ -573,7 +574,7 @@ pub fn report_unexpected_hidden_region(
}
}
err.emit();
err
}
// Visitor that requires that (almost) all regions in the type visited outlive
......@@ -724,13 +725,13 @@ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
None => {
if !self.map_missing_regions_to_empty && !self.tainted_by_errors {
if let Some(hidden_ty) = self.hidden_ty.take() {
report_unexpected_hidden_region(
unexpected_hidden_region_diagnostic(
self.tcx,
None,
self.opaque_type_def_id,
hidden_ty,
r,
);
).emit();
}
}
self.tcx.lifetimes.re_empty
......
......@@ -71,10 +71,12 @@ impl<'tcx> PickConstraintSet<'tcx, ty::RegionVid> {
p_c: &PickConstraint<'tcx>,
mut to_region_vid: impl FnMut(ty::Region<'tcx>) -> ty::RegionVid,
) {
debug!("push_constraint(p_c={:?})", p_c);
let pick_region_vid: ty::RegionVid = to_region_vid(p_c.pick_region);
let next_constraint = self.first_constraints.get(&pick_region_vid).cloned();
let start_index = self.option_regions.len();
let end_index = start_index + p_c.option_regions.len();
debug!("push_constraint: pick_region_vid={:?}", pick_region_vid);
let constraint_index = self.constraints.push(NllPickConstraint {
next_constraint,
pick_region_vid,
......@@ -136,6 +138,12 @@ impl<'tcx, R> PickConstraintSet<'tcx, R>
where
R: Copy + Hash + Eq,
{
crate fn all_indices(
&self,
) -> impl Iterator<Item = NllPickConstraintIndex> {
self.constraints.indices()
}
/// Iterate down the constraint indices associated with a given
/// peek-region. You can then use `option_regions` and other
/// methods to access data.
......
......@@ -51,6 +51,8 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
}
pub(super) fn convert_all(&mut self, query_constraints: &QueryRegionConstraints<'tcx>) {
debug!("convert_all(query_constraints={:#?})", query_constraints);
let QueryRegionConstraints { outlives, pick_constraints } = query_constraints;
// Annoying: to invoke `self.to_region_vid`, we need access to
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册