Skip to content

Commit d54195d

Browse files
committedFeb 11, 2022
Revert "Auto merge of rust-lang#92007 - oli-obk:lazy_tait2, r=nikomatsakis"
This reverts commit e7cc3bd, reversing changes made to 734368a.
1 parent 2d8b8f3 commit d54195d

File tree

359 files changed

+2442
-3305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

359 files changed

+2442
-3305
lines changed
 

‎compiler/rustc_borrowck/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ fn mir_borrowck<'tcx>(
124124
) -> &'tcx BorrowCheckResult<'tcx> {
125125
let (input_body, promoted) = tcx.mir_promoted(def);
126126
debug!("run query mir_borrowck: {}", tcx.def_path_str(def.did.to_def_id()));
127-
let hir_owner = tcx.hir().local_def_id_to_hir_id(def.did).owner;
128127

129-
let opt_closure_req = tcx.infer_ctxt().with_opaque_type_inference(hir_owner).enter(|infcx| {
128+
let opt_closure_req = tcx.infer_ctxt().with_opaque_type_inference(def.did).enter(|infcx| {
130129
let input_body: &Body<'_> = &input_body.borrow();
131130
let promoted: &IndexVec<_, _> = &promoted.borrow();
132131
do_mir_borrowck(&infcx, input_body, promoted, false).0
@@ -141,7 +140,7 @@ fn mir_borrowck<'tcx>(
141140
/// If `return_body_with_facts` is true, then return the body with non-erased
142141
/// region ids on which the borrow checking was performed together with Polonius
143142
/// facts.
144-
#[instrument(skip(infcx, input_body, input_promoted), fields(id=?input_body.source.with_opt_param().as_local().unwrap()), level = "debug")]
143+
#[instrument(skip(infcx, input_body, input_promoted), level = "debug")]
145144
fn do_mir_borrowck<'a, 'tcx>(
146145
infcx: &InferCtxt<'a, 'tcx>,
147146
input_body: &Body<'tcx>,

‎compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+20-38
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc_data_structures::fx::FxHashMap;
22
use rustc_data_structures::vec_map::VecMap;
33
use rustc_hir::OpaqueTyOrigin;
4+
use rustc_infer::infer::opaque_types::OpaqueTypeDecl;
45
use rustc_infer::infer::InferCtxt;
56
use rustc_middle::ty::subst::GenericArgKind;
67
use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable};
@@ -53,44 +54,27 @@ impl<'tcx> RegionInferenceContext<'tcx> {
5354
pub(crate) fn infer_opaque_types(
5455
&self,
5556
infcx: &InferCtxt<'_, 'tcx>,
56-
opaque_ty_decls: VecMap<OpaqueTypeKey<'tcx>, (Ty<'tcx>, Span, OpaqueTyOrigin)>,
57+
opaque_ty_decls: VecMap<OpaqueTypeKey<'tcx>, OpaqueTypeDecl<'tcx>>,
5758
span: Span,
5859
) -> VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>> {
5960
opaque_ty_decls
6061
.into_iter()
61-
.map(|(opaque_type_key, (concrete_type, decl_span, origin))| {
62+
.filter_map(|(opaque_type_key, decl)| {
6263
let substs = opaque_type_key.substs;
63-
// FIXME: why are the spans in decl_span often DUMMY_SP?
64-
let span = decl_span.substitute_dummy(span);
64+
let concrete_type = decl.concrete_ty;
6565
debug!(?concrete_type, ?substs);
6666

6767
let mut subst_regions = vec![self.universal_regions.fr_static];
6868
let universal_substs = infcx.tcx.fold_regions(substs, &mut false, |region, _| {
69-
if let ty::RePlaceholder(..) = region {
70-
// Higher kinded regions don't need remapping, they don't refer to anything outside of this the substs.
71-
return region;
72-
}
73-
let vid = self.to_region_vid(region);
74-
trace!(?vid);
75-
let scc = self.constraint_sccs.scc(vid);
76-
trace!(?scc);
77-
match self.scc_values.universal_regions_outlived_by(scc).find_map(|lb| {
78-
self.eval_equal(vid, lb).then_some(self.definitions[lb].external_name?)
79-
}) {
80-
Some(region) => {
81-
let vid = self.universal_regions.to_region_vid(region);
82-
subst_regions.push(vid);
83-
region
84-
}
85-
None => {
86-
subst_regions.push(vid);
87-
infcx.tcx.sess.delay_span_bug(
88-
span,
89-
"opaque type with non-universal region substs",
90-
);
91-
infcx.tcx.lifetimes.re_static
92-
}
93-
}
69+
let vid = self.universal_regions.to_region_vid(region);
70+
subst_regions.push(vid);
71+
self.definitions[vid].external_name.unwrap_or_else(|| {
72+
infcx
73+
.tcx
74+
.sess
75+
.delay_span_bug(span, "opaque type with non-universal region substs");
76+
infcx.tcx.lifetimes.re_static
77+
})
9478
});
9579

9680
subst_regions.sort();
@@ -116,14 +100,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
116100
span,
117101
);
118102

119-
(
103+
check_opaque_type_parameter_valid(
104+
infcx.tcx,
120105
opaque_type_key,
121-
if check_opaque_type_parameter_valid(infcx.tcx, opaque_type_key, origin, span) {
122-
remapped_type
123-
} else {
124-
infcx.tcx.ty_error()
125-
},
106+
OpaqueTypeDecl { concrete_ty: remapped_type, ..decl },
126107
)
108+
.then_some((opaque_type_key, remapped_type))
127109
})
128110
.collect()
129111
}
@@ -167,10 +149,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
167149
fn check_opaque_type_parameter_valid(
168150
tcx: TyCtxt<'_>,
169151
opaque_type_key: OpaqueTypeKey<'_>,
170-
origin: OpaqueTyOrigin,
171-
span: Span,
152+
decl: OpaqueTypeDecl<'_>,
172153
) -> bool {
173-
match origin {
154+
match decl.origin {
174155
// No need to check return position impl trait (RPIT)
175156
// because for type and const parameters they are correct
176157
// by construction: we convert
@@ -196,6 +177,7 @@ fn check_opaque_type_parameter_valid(
196177
// Check these
197178
OpaqueTyOrigin::TyAlias => {}
198179
}
180+
let span = decl.definition_span;
199181
let opaque_generics = tcx.generics_of(opaque_type_key.def_id);
200182
let mut seen_params: FxHashMap<_, Vec<_>> = FxHashMap::default();
201183
for (i, arg) in opaque_type_key.substs.iter().enumerate() {

0 commit comments

Comments
 (0)