Remove ResolvedOpaqueTy and just use Ty, SubstsRef is already there
This commit is contained in:
parent
7f8cad2019
commit
7294f49d52
8 changed files with 40 additions and 69 deletions
|
@ -8,7 +8,7 @@ use rustc_middle::mir::{
|
|||
BasicBlock, Body, ClosureOutlivesSubject, ClosureRegionRequirements, LocalKind, Location,
|
||||
Promoted,
|
||||
};
|
||||
use rustc_middle::ty::{self, OpaqueTypeKey, RegionKind, RegionVid};
|
||||
use rustc_middle::ty::{self, OpaqueTypeKey, RegionKind, RegionVid, Ty};
|
||||
use rustc_span::symbol::sym;
|
||||
use std::env;
|
||||
use std::fmt::Debug;
|
||||
|
@ -46,7 +46,7 @@ crate type PoloniusOutput = Output<RustcFacts>;
|
|||
/// closure requirements to propagate, and any generated errors.
|
||||
crate struct NllOutput<'tcx> {
|
||||
pub regioncx: RegionInferenceContext<'tcx>,
|
||||
pub opaque_type_values: VecMap<OpaqueTypeKey<'tcx>, ty::ResolvedOpaqueTy<'tcx>>,
|
||||
pub opaque_type_values: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
|
||||
pub polonius_output: Option<Rc<PoloniusOutput>>,
|
||||
pub opt_closure_req: Option<ClosureRegionRequirements<'tcx>>,
|
||||
pub nll_errors: RegionErrors<'tcx>,
|
||||
|
@ -366,7 +366,7 @@ pub(super) fn dump_annotation<'a, 'tcx>(
|
|||
body: &Body<'tcx>,
|
||||
regioncx: &RegionInferenceContext<'tcx>,
|
||||
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
|
||||
opaque_type_values: &VecMap<OpaqueTypeKey<'tcx>, ty::ResolvedOpaqueTy<'tcx>>,
|
||||
opaque_type_values: &VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
|
||||
errors_buffer: &mut Vec<Diagnostic>,
|
||||
) {
|
||||
let tcx = infcx.tcx;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustc_data_structures::vec_map::VecMap;
|
||||
use rustc_infer::infer::InferCtxt;
|
||||
use rustc_middle::ty::{self, OpaqueTypeKey, TyCtxt, TypeFoldable};
|
||||
use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_span::Span;
|
||||
use rustc_trait_selection::opaque_types::InferCtxtExt;
|
||||
|
||||
|
@ -50,12 +50,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
pub(in crate::borrow_check) fn infer_opaque_types(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
opaque_ty_decls: VecMap<OpaqueTypeKey<'tcx>, ty::ResolvedOpaqueTy<'tcx>>,
|
||||
opaque_ty_decls: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
|
||||
span: Span,
|
||||
) -> VecMap<OpaqueTypeKey<'tcx>, ty::ResolvedOpaqueTy<'tcx>> {
|
||||
) -> VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>> {
|
||||
opaque_ty_decls
|
||||
.into_iter()
|
||||
.map(|(opaque_type_key, ty::ResolvedOpaqueTy { concrete_type, substs })| {
|
||||
.map(|(opaque_type_key, concrete_type)| {
|
||||
let substs = opaque_type_key.substs;
|
||||
debug!(?concrete_type, ?substs);
|
||||
|
||||
let mut subst_regions = vec![self.universal_regions.fr_static];
|
||||
|
@ -116,10 +117,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
universal_concrete_type,
|
||||
span,
|
||||
);
|
||||
(
|
||||
opaque_type_key,
|
||||
ty::ResolvedOpaqueTy { concrete_type: remapped_type, substs: universal_substs },
|
||||
)
|
||||
(opaque_type_key, remapped_type)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
|
@ -819,7 +819,7 @@ struct TypeChecker<'a, 'tcx> {
|
|||
reported_errors: FxHashSet<(Ty<'tcx>, Span)>,
|
||||
borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>,
|
||||
universal_region_relations: &'a UniversalRegionRelations<'tcx>,
|
||||
opaque_type_values: VecMap<OpaqueTypeKey<'tcx>, ty::ResolvedOpaqueTy<'tcx>>,
|
||||
opaque_type_values: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
|
||||
}
|
||||
|
||||
struct BorrowCheckContext<'a, 'tcx> {
|
||||
|
@ -834,7 +834,7 @@ struct BorrowCheckContext<'a, 'tcx> {
|
|||
crate struct MirTypeckResults<'tcx> {
|
||||
crate constraints: MirTypeckRegionConstraints<'tcx>,
|
||||
pub(in crate::borrow_check) universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
|
||||
crate opaque_type_values: VecMap<OpaqueTypeKey<'tcx>, ty::ResolvedOpaqueTy<'tcx>>,
|
||||
crate opaque_type_values: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
|
||||
}
|
||||
|
||||
/// A collection of region constraints that must be satisfied for the
|
||||
|
@ -1292,10 +1292,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
|
||||
let opaque_type_key =
|
||||
OpaqueTypeKey { def_id: opaque_def_id, substs: opaque_decl.substs };
|
||||
let opaque_defn_ty = match concrete_opaque_types
|
||||
let concrete_ty = match concrete_opaque_types
|
||||
.iter()
|
||||
.find(|(opaque_type_key, _)| opaque_type_key.def_id == opaque_def_id)
|
||||
.map(|(_, resolved_opaque_ty)| resolved_opaque_ty)
|
||||
.map(|(_, concrete_ty)| concrete_ty)
|
||||
{
|
||||
None => {
|
||||
if !concrete_is_opaque {
|
||||
|
@ -1309,17 +1309,16 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
Some(opaque_defn_ty) => opaque_defn_ty,
|
||||
Some(concrete_ty) => concrete_ty,
|
||||
};
|
||||
debug!("opaque_defn_ty = {:?}", opaque_defn_ty);
|
||||
let subst_opaque_defn_ty =
|
||||
opaque_defn_ty.concrete_type.subst(tcx, opaque_decl.substs);
|
||||
debug!("concrete_ty = {:?}", concrete_ty);
|
||||
let subst_opaque_defn_ty = concrete_ty.subst(tcx, opaque_decl.substs);
|
||||
let renumbered_opaque_defn_ty =
|
||||
renumber::renumber_regions(infcx, subst_opaque_defn_ty);
|
||||
|
||||
debug!(
|
||||
"eq_opaque_type_and_type: concrete_ty={:?}={:?} opaque_defn_ty={:?}",
|
||||
opaque_decl.concrete_ty, resolved_ty, renumbered_opaque_defn_ty,
|
||||
concrete_ty, resolved_ty, renumbered_opaque_defn_ty,
|
||||
);
|
||||
|
||||
if !concrete_is_opaque {
|
||||
|
@ -1330,13 +1329,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
.at(&ObligationCause::dummy(), param_env)
|
||||
.eq(opaque_decl.concrete_ty, renumbered_opaque_defn_ty)?,
|
||||
);
|
||||
opaque_type_values.insert(
|
||||
opaque_type_key,
|
||||
ty::ResolvedOpaqueTy {
|
||||
concrete_type: renumbered_opaque_defn_ty,
|
||||
substs: opaque_decl.substs,
|
||||
},
|
||||
);
|
||||
opaque_type_values.insert(opaque_type_key, renumbered_opaque_defn_ty);
|
||||
} else {
|
||||
// We're using an opaque `impl Trait` type without
|
||||
// 'revealing' it. For example, code like this:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue