Skip to content

Commit ec48b4e

Browse files
committed
preliminary integration of "pick constraints" into nll solver
1 parent 3b5a727 commit ec48b4e

File tree

5 files changed

+231
-127
lines changed

5 files changed

+231
-127
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
385385
option_regions: _,
386386
} => {
387387
let hidden_ty = self.resolve_vars_if_possible(&hidden_ty);
388-
opaque_types::report_unexpected_hidden_region(
388+
opaque_types::unexpected_hidden_region_diagnostic(
389389
self.tcx,
390390
Some(region_scope_tree),
391391
opaque_type_def_id,
392392
hidden_ty,
393393
pick_region,
394-
);
394+
).emit();
395395
}
396396
}
397397
}

src/librustc/infer/opaque_types/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor};
99
use crate::ty::subst::{InternalSubsts, Kind, SubstsRef, UnpackedKind};
1010
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt};
1111
use crate::util::nodemap::DefIdMap;
12+
use errors::DiagnosticBuilder;
1213
use rustc_data_structures::fx::FxHashMap;
1314
use std::rc::Rc;
1415

@@ -499,13 +500,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
499500
}
500501
}
501502

502-
pub fn report_unexpected_hidden_region(
503+
pub fn unexpected_hidden_region_diagnostic(
503504
tcx: TyCtxt<'tcx>,
504505
region_scope_tree: Option<&region::ScopeTree>,
505506
opaque_type_def_id: DefId,
506507
hidden_ty: Ty<'tcx>,
507508
hidden_region: ty::Region<'tcx>,
508-
) {
509+
) -> DiagnosticBuilder<'tcx> {
509510
let span = tcx.def_span(opaque_type_def_id);
510511
let mut err = struct_span_err!(
511512
tcx.sess,
@@ -573,7 +574,7 @@ pub fn report_unexpected_hidden_region(
573574
}
574575
}
575576

576-
err.emit();
577+
err
577578
}
578579

579580
// Visitor that requires that (almost) all regions in the type visited outlive
@@ -724,13 +725,13 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
724725
None => {
725726
if !self.map_missing_regions_to_empty && !self.tainted_by_errors {
726727
if let Some(hidden_ty) = self.hidden_ty.take() {
727-
report_unexpected_hidden_region(
728+
unexpected_hidden_region_diagnostic(
728729
self.tcx,
729730
None,
730731
self.opaque_type_def_id,
731732
hidden_ty,
732733
r,
733-
);
734+
).emit();
734735
}
735736
}
736737
self.tcx.lifetimes.re_empty

src/librustc_mir/borrow_check/nll/pick_constraints.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ impl<'tcx> PickConstraintSet<'tcx, ty::RegionVid> {
7171
p_c: &PickConstraint<'tcx>,
7272
mut to_region_vid: impl FnMut(ty::Region<'tcx>) -> ty::RegionVid,
7373
) {
74+
debug!("push_constraint(p_c={:?})", p_c);
7475
let pick_region_vid: ty::RegionVid = to_region_vid(p_c.pick_region);
7576
let next_constraint = self.first_constraints.get(&pick_region_vid).cloned();
7677
let start_index = self.option_regions.len();
7778
let end_index = start_index + p_c.option_regions.len();
79+
debug!("push_constraint: pick_region_vid={:?}", pick_region_vid);
7880
let constraint_index = self.constraints.push(NllPickConstraint {
7981
next_constraint,
8082
pick_region_vid,
@@ -136,6 +138,12 @@ impl<'tcx, R> PickConstraintSet<'tcx, R>
136138
where
137139
R: Copy + Hash + Eq,
138140
{
141+
crate fn all_indices(
142+
&self,
143+
) -> impl Iterator<Item = NllPickConstraintIndex> {
144+
self.constraints.indices()
145+
}
146+
139147
/// Iterate down the constraint indices associated with a given
140148
/// peek-region. You can then use `option_regions` and other
141149
/// methods to access data.

0 commit comments

Comments
 (0)