Skip to content

Commit 66b664c

Browse files
committed
more rename
1 parent 4d41177 commit 66b664c

File tree

7 files changed

+36
-28
lines changed

7 files changed

+36
-28
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ pub fn provide(providers: &mut Providers) {
116116
/// Provider for `query mir_borrowck`. Similar to `typeck`, this must
117117
/// only be called for typeck roots which will then borrowck all
118118
/// nested bodies as well.
119-
fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> Result<&HiddenTypes<'_>, ErrorGuaranteed> {
119+
fn mir_borrowck(
120+
tcx: TyCtxt<'_>,
121+
def: LocalDefId,
122+
) -> Result<&DefinitionSiteHiddenTypes<'_>, ErrorGuaranteed> {
120123
assert!(!tcx.is_typeck_child(def.to_def_id()));
121124
let (input_body, _) = tcx.mir_promoted(def);
122125
debug!("run query mir_borrowck: {}", tcx.def_path_str(def));
@@ -127,7 +130,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> Result<&HiddenTypes<'_>, Er
127130
Err(guar)
128131
} else if input_body.should_skip() {
129132
debug!("Skipping borrowck because of injected body");
130-
let opaque_types = HiddenTypes(Default::default());
133+
let opaque_types = DefinitionSiteHiddenTypes(Default::default());
131134
Ok(tcx.arena.alloc(opaque_types))
132135
} else {
133136
let mut root_cx = BorrowCheckRootCtxt::new(tcx, def, None);

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_infer::infer::outlives::env::RegionBoundPairs;
88
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, OpaqueTypeStorageEntries};
99
use rustc_infer::traits::ObligationCause;
1010
use rustc_macros::extension;
11-
use rustc_middle::mir::{Body, ConstraintCategory, HiddenTypes};
11+
use rustc_middle::mir::{Body, ConstraintCategory, DefinitionSiteHiddenTypes};
1212
use rustc_middle::ty::{
1313
self, DefiningScopeKind, EarlyBinder, FallibleTypeFolder, GenericArg, GenericArgsRef,
1414
OpaqueHiddenType, OpaqueTypeKey, Region, RegionVid, Ty, TyCtxt, TypeFoldable,
@@ -131,7 +131,7 @@ fn nll_var_to_universal_region<'tcx>(
131131
/// and errors if we end up with distinct hidden types.
132132
fn add_hidden_type<'tcx>(
133133
tcx: TyCtxt<'tcx>,
134-
hidden_types: &mut HiddenTypes<'tcx>,
134+
hidden_types: &mut DefinitionSiteHiddenTypes<'tcx>,
135135
def_id: LocalDefId,
136136
hidden_ty: OpaqueHiddenType<'tcx>,
137137
) {
@@ -156,7 +156,7 @@ fn add_hidden_type<'tcx>(
156156
}
157157

158158
fn get_hidden_type<'tcx>(
159-
hidden_types: &HiddenTypes<'tcx>,
159+
hidden_types: &DefinitionSiteHiddenTypes<'tcx>,
160160
def_id: LocalDefId,
161161
) -> Option<EarlyBinder<'tcx, OpaqueHiddenType<'tcx>>> {
162162
hidden_types.0.get(&def_id).map(|ty| EarlyBinder::bind(*ty))
@@ -183,12 +183,12 @@ struct DefiningUse<'tcx> {
183183
///
184184
/// It also means that this whole function is not really soundness critical as we
185185
/// recheck all uses of the opaques regardless.
186-
pub(crate) fn compute_hidden_types<'tcx>(
186+
pub(crate) fn compute_definition_site_hidden_types<'tcx>(
187187
infcx: &BorrowckInferCtxt<'tcx>,
188188
universal_region_relations: &Frozen<UniversalRegionRelations<'tcx>>,
189189
constraints: &MirTypeckRegionConstraints<'tcx>,
190190
location_map: Rc<DenseLocationMap>,
191-
hidden_types: &mut HiddenTypes<'tcx>,
191+
hidden_types: &mut DefinitionSiteHiddenTypes<'tcx>,
192192
opaque_types: &[(OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>)],
193193
) -> Vec<DeferredOpaqueTypeError<'tcx>> {
194194
let mut errors = Vec::new();
@@ -211,14 +211,19 @@ pub(crate) fn compute_hidden_types<'tcx>(
211211
// After applying member constraints, we now check whether all member regions ended
212212
// up equal to one of their choice regions and compute the actual hidden type of
213213
// the opaque type definition. This is stored in the `root_cx`.
214-
compute_hidden_types_from_defining_uses(&rcx, hidden_types, &defining_uses, &mut errors);
214+
compute_definition_site_hidden_types_from_defining_uses(
215+
&rcx,
216+
hidden_types,
217+
&defining_uses,
218+
&mut errors,
219+
);
215220
errors
216221
}
217222

218223
#[instrument(level = "debug", skip_all, ret)]
219224
fn collect_defining_uses<'tcx>(
220225
rcx: &mut RegionCtxt<'_, 'tcx>,
221-
hidden_types: &mut HiddenTypes<'tcx>,
226+
hidden_types: &mut DefinitionSiteHiddenTypes<'tcx>,
222227
opaque_types: &[(OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>)],
223228
errors: &mut Vec<DeferredOpaqueTypeError<'tcx>>,
224229
) -> Vec<DefiningUse<'tcx>> {
@@ -271,9 +276,9 @@ fn collect_defining_uses<'tcx>(
271276
defining_uses
272277
}
273278

274-
fn compute_hidden_types_from_defining_uses<'tcx>(
279+
fn compute_definition_site_hidden_types_from_defining_uses<'tcx>(
275280
rcx: &RegionCtxt<'_, 'tcx>,
276-
hidden_types: &mut HiddenTypes<'tcx>,
281+
hidden_types: &mut DefinitionSiteHiddenTypes<'tcx>,
277282
defining_uses: &[DefiningUse<'tcx>],
278283
errors: &mut Vec<DeferredOpaqueTypeError<'tcx>>,
279284
) {
@@ -483,14 +488,14 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ToArgRegionsFolder<'_, 'tcx> {
483488
///
484489
/// It does this by equating the hidden type of each use with the instantiated final
485490
/// hidden type of the opaque.
486-
pub(crate) fn apply_hidden_types<'tcx>(
491+
pub(crate) fn apply_definition_site_hidden_types<'tcx>(
487492
infcx: &BorrowckInferCtxt<'tcx>,
488493
body: &Body<'tcx>,
489494
universal_regions: &UniversalRegions<'tcx>,
490495
region_bound_pairs: &RegionBoundPairs<'tcx>,
491496
known_type_outlives_obligations: &[ty::PolyTypeOutlivesPredicate<'tcx>],
492497
constraints: &mut MirTypeckRegionConstraints<'tcx>,
493-
hidden_types: &mut HiddenTypes<'tcx>,
498+
hidden_types: &mut DefinitionSiteHiddenTypes<'tcx>,
494499
opaque_types: &[(OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>)],
495500
) -> Vec<DeferredOpaqueTypeError<'tcx>> {
496501
let tcx = infcx.tcx;
@@ -561,7 +566,7 @@ pub(crate) fn apply_hidden_types<'tcx>(
561566
errors
562567
}
563568

564-
/// In theory `apply_hidden_types` could introduce new uses of opaque types.
569+
/// In theory `apply_definition_site_hidden_types` could introduce new uses of opaque types.
565570
/// We do not check these new uses so this could be unsound.
566571
///
567572
/// We detect any new uses and simply delay a bug if they occur. If this results in

compiler/rustc_borrowck/src/root_cx.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ use smallvec::SmallVec;
1212
use crate::consumers::BorrowckConsumer;
1313
use crate::nll::compute_closure_requirements_modulo_opaques;
1414
use crate::region_infer::opaque_types::{
15-
apply_hidden_types, clone_and_resolve_opaque_types, compute_hidden_types,
16-
detect_opaque_types_added_while_handling_opaque_types,
15+
apply_definition_site_hidden_types, clone_and_resolve_opaque_types,
16+
compute_definition_site_hidden_types, detect_opaque_types_added_while_handling_opaque_types,
1717
};
1818
use crate::type_check::{Locations, constraint_conversion};
1919
use crate::{
20-
ClosureRegionRequirements, CollectRegionConstraintsResult, HiddenTypes,
20+
ClosureRegionRequirements, CollectRegionConstraintsResult, DefinitionSiteHiddenTypes,
2121
PropagatedBorrowCheckResults, borrowck_check_region_constraints,
2222
borrowck_collect_region_constraints,
2323
};
@@ -27,7 +27,7 @@ use crate::{
2727
pub(super) struct BorrowCheckRootCtxt<'tcx> {
2828
pub tcx: TyCtxt<'tcx>,
2929
root_def_id: LocalDefId,
30-
hidden_types: HiddenTypes<'tcx>,
30+
hidden_types: DefinitionSiteHiddenTypes<'tcx>,
3131
/// The region constraints computed by [borrowck_collect_region_constraints]. This uses
3232
/// an [FxIndexMap] to guarantee that iterating over it visits nested bodies before
3333
/// their parents.
@@ -72,7 +72,7 @@ impl<'tcx> BorrowCheckRootCtxt<'tcx> {
7272
&self.propagated_borrowck_results[&nested_body_def_id].used_mut_upvars
7373
}
7474

75-
pub(super) fn finalize(self) -> Result<&'tcx HiddenTypes<'tcx>, ErrorGuaranteed> {
75+
pub(super) fn finalize(self) -> Result<&'tcx DefinitionSiteHiddenTypes<'tcx>, ErrorGuaranteed> {
7676
if let Some(guar) = self.tainted_by_errors {
7777
Err(guar)
7878
} else {
@@ -88,7 +88,7 @@ impl<'tcx> BorrowCheckRootCtxt<'tcx> {
8888
&input.universal_region_relations,
8989
&mut input.constraints,
9090
);
91-
input.deferred_opaque_type_errors = compute_hidden_types(
91+
input.deferred_opaque_type_errors = compute_definition_site_hidden_types(
9292
&input.infcx,
9393
&input.universal_region_relations,
9494
&input.constraints,
@@ -103,7 +103,7 @@ impl<'tcx> BorrowCheckRootCtxt<'tcx> {
103103
self.collect_region_constraints_results.values_mut().zip(per_body_info)
104104
{
105105
if input.deferred_opaque_type_errors.is_empty() {
106-
input.deferred_opaque_type_errors = apply_hidden_types(
106+
input.deferred_opaque_type_errors = apply_definition_site_hidden_types(
107107
&input.infcx,
108108
&input.body_owned,
109109
&input.universal_region_relations.universal_regions,

compiler/rustc_hir_typeck/src/opaque_types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
3535
}
3636
debug!(?opaque_types);
3737

38-
self.compute_hidden_types(&opaque_types);
39-
self.apply_hidden_types(&opaque_types);
38+
self.compute_definition_site_hidden_types(&opaque_types);
39+
self.apply_definition_site_hidden_types(&opaque_types);
4040
}
4141
}
4242

@@ -71,7 +71,7 @@ impl<'tcx> UsageKind<'tcx> {
7171
}
7272

7373
impl<'tcx> FnCtxt<'_, 'tcx> {
74-
fn compute_hidden_types(
74+
fn compute_definition_site_hidden_types(
7575
&mut self,
7676
opaque_types: &[(OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>)],
7777
) {
@@ -203,7 +203,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
203203
UsageKind::HasDefiningUse
204204
}
205205

206-
fn apply_hidden_types(
206+
fn apply_definition_site_hidden_types(
207207
&mut self,
208208
opaque_types: &[(OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>)],
209209
) {

compiler/rustc_middle/src/arena.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ macro_rules! arena_types {
2727
rustc_middle::mir::Body<'tcx>
2828
>,
2929
[decode] typeck_results: rustc_middle::ty::TypeckResults<'tcx>,
30-
[decode] borrowck_result: rustc_middle::mir::HiddenTypes<'tcx>,
30+
[decode] borrowck_result: rustc_middle::mir::DefinitionSiteHiddenTypes<'tcx>,
3131
[] resolver: rustc_data_structures::steal::Steal<(
3232
rustc_middle::ty::ResolverAstLowering,
3333
std::sync::Arc<rustc_ast::Crate>,

compiler/rustc_middle/src/mir/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Debug for CoroutineLayout<'_> {
8787
/// All the opaque types that have had their hidden type fully computed.
8888
/// Unlike the value in `TypeckResults`, this has unerased regions.
8989
#[derive(Default, Debug, TyEncodable, TyDecodable, HashStable)]
90-
pub struct HiddenTypes<'tcx>(pub FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>);
90+
pub struct DefinitionSiteHiddenTypes<'tcx>(pub FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>);
9191

9292
/// The result of the `mir_const_qualif` query.
9393
///

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ rustc_queries! {
12441244

12451245
/// Borrow-checks the given typeck root, e.g. functions, const/static items,
12461246
/// and its children, e.g. closures, inline consts.
1247-
query mir_borrowck(key: LocalDefId) -> Result<&'tcx mir::HiddenTypes<'tcx>, ErrorGuaranteed> {
1247+
query mir_borrowck(key: LocalDefId) -> Result<&'tcx mir::DefinitionSiteHiddenTypes<'tcx>, ErrorGuaranteed> {
12481248
desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key) }
12491249
}
12501250

0 commit comments

Comments
 (0)