Skip to content

Commit a909eb6

Browse files
committed
improve naming
1 parent 805c44d commit a909eb6

Some content is hidden

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

44 files changed

+184
-160
lines changed

src/librustc_infer/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15361536
pub fn const_eval_resolve(
15371537
&self,
15381538
param_env: ty::ParamEnv<'tcx>,
1539-
def: ty::WithOptParam<DefId>,
1539+
def: ty::WithOptConstParam<DefId>,
15401540
substs: SubstsRef<'tcx>,
15411541
promoted: Option<mir::Promoted>,
15421542
span: Option<Span>,

src/librustc_interface/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
892892

893893
if tcx.hir().body_const_context(def_id).is_some() {
894894
tcx.ensure()
895-
.mir_drops_elaborated_and_const_checked(ty::WithOptParam::dummy(def_id));
895+
.mir_drops_elaborated_and_const_checked(ty::WithOptConstParam::dummy(def_id));
896896
}
897897
}
898898
});

src/librustc_middle/mir/interpret/queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<'tcx> TyCtxt<'tcx> {
3434
pub fn const_eval_resolve(
3535
self,
3636
param_env: ty::ParamEnv<'tcx>,
37-
def: ty::WithOptParam<DefId>,
37+
def: ty::WithOptConstParam<DefId>,
3838
substs: SubstsRef<'tcx>,
3939
promoted: Option<mir::Promoted>,
4040
span: Option<Span>,

src/librustc_middle/mir/query.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,20 @@ pub struct CoverageInfo {
328328
impl<'tcx> TyCtxt<'tcx> {
329329
pub fn mir_borrowck_opt_const_arg(
330330
self,
331-
def: ty::WithOptParam<LocalDefId>,
331+
def: ty::WithOptConstParam<LocalDefId>,
332332
) -> &'tcx BorrowCheckResult<'tcx> {
333-
if let Some(param_did) = def.param_did {
333+
if let Some(param_did) = def.const_param_did {
334334
self.mir_borrowck_const_arg((def.did, param_did))
335335
} else {
336336
self.mir_borrowck(def.did)
337337
}
338338
}
339339

340-
pub fn mir_const_qualif_opt_const_arg(self, def: ty::WithOptParam<LocalDefId>) -> ConstQualifs {
341-
if let Some(param_did) = def.param_did {
340+
pub fn mir_const_qualif_opt_const_arg(
341+
self,
342+
def: ty::WithOptConstParam<LocalDefId>,
343+
) -> ConstQualifs {
344+
if let Some(param_did) = def.const_param_did {
342345
self.mir_const_qualif_const_arg((def.did, param_did))
343346
} else {
344347
self.mir_const_qualif(def.did)
@@ -347,7 +350,7 @@ impl<'tcx> TyCtxt<'tcx> {
347350

348351
pub fn promoted_mir_of_opt_const_arg(
349352
self,
350-
def: ty::WithOptParam<DefId>,
353+
def: ty::WithOptConstParam<DefId>,
351354
) -> &'tcx IndexVec<Promoted, Body<'tcx>> {
352355
if let Some((did, param_did)) = def.as_const_arg() {
353356
self.promoted_mir_of_const_arg((did, param_did))

src/librustc_middle/query/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ rustc_queries! {
105105
/// ```
106106
query opt_const_param_of(key: LocalDefId) -> Option<DefId> {
107107
desc { |tcx| "computing the optional const parameter of `{}`", tcx.def_path_str(key.to_def_id()) }
108-
// FIXME: consider storing this query on disk.
108+
// FIXME(#74113): consider storing this query on disk.
109109
}
110110

111111
/// Records the type of every item.
@@ -219,39 +219,39 @@ rustc_queries! {
219219

220220
/// Fetch the MIR for a given `DefId` right after it's built - this includes
221221
/// unreachable code.
222-
query mir_built(key: ty::WithOptParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
222+
query mir_built(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
223223
desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
224224
}
225225

226226
/// Fetch the MIR for a given `DefId` up till the point where it is
227227
/// ready for const qualification.
228228
///
229229
/// See the README for the `mir` module for details.
230-
query mir_const(key: ty::WithOptParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
230+
query mir_const(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
231231
desc {
232232
|tcx| "processing MIR for {}`{}`",
233-
if key.param_did.is_some() { "the const argument " } else { "" },
233+
if key.const_param_did.is_some() { "the const argument " } else { "" },
234234
tcx.def_path_str(key.did.to_def_id()),
235235
}
236236
no_hash
237237
}
238238

239239
query mir_drops_elaborated_and_const_checked(
240-
key: ty::WithOptParam<LocalDefId>
240+
key: ty::WithOptConstParam<LocalDefId>
241241
) -> &'tcx Steal<mir::Body<'tcx>> {
242242
no_hash
243243
desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.did.to_def_id()) }
244244
}
245245

246-
query mir_validated(key: ty::WithOptParam<LocalDefId>) ->
246+
query mir_validated(key: ty::WithOptConstParam<LocalDefId>) ->
247247
(
248248
&'tcx Steal<mir::Body<'tcx>>,
249249
&'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
250250
) {
251251
no_hash
252252
desc {
253253
|tcx| "processing {}`{}`",
254-
if key.param_did.is_some() { "the const argument " } else { "" },
254+
if key.const_param_did.is_some() { "the const argument " } else { "" },
255255
tcx.def_path_str(key.did.to_def_id()),
256256
}
257257
}

src/librustc_middle/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -982,9 +982,9 @@ pub struct GlobalCtxt<'tcx> {
982982
impl<'tcx> TyCtxt<'tcx> {
983983
pub fn typeck_tables_of_opt_const_arg(
984984
self,
985-
def: ty::WithOptParam<LocalDefId>,
985+
def: ty::WithOptConstParam<LocalDefId>,
986986
) -> &'tcx TypeckTables<'tcx> {
987-
if let Some(param_did) = def.param_did {
987+
if let Some(param_did) = def.const_param_did {
988988
self.typeck_tables_of_const_arg((def.did, param_did))
989989
} else {
990990
self.typeck_tables_of(def.did)

src/librustc_middle/ty/instance.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub enum InstanceDef<'tcx> {
2929
/// - `fn` items
3030
/// - closures
3131
/// - generators
32-
Item(ty::WithOptParam<DefId>),
32+
Item(ty::WithOptConstParam<DefId>),
3333

3434
/// An intrinsic `fn` item (with `"rust-intrinsic"` or `"platform-intrinsic"` ABI).
3535
///
@@ -186,7 +186,7 @@ impl<'tcx> InstanceDef<'tcx> {
186186
}
187187

188188
#[inline]
189-
pub fn with_opt_param(self) -> ty::WithOptParam<DefId> {
189+
pub fn with_opt_param(self) -> ty::WithOptConstParam<DefId> {
190190
match self {
191191
InstanceDef::Item(def) => def,
192192
InstanceDef::VtableShim(def_id)
@@ -196,7 +196,7 @@ impl<'tcx> InstanceDef<'tcx> {
196196
| InstanceDef::Intrinsic(def_id)
197197
| InstanceDef::ClosureOnceShim { call_once: def_id }
198198
| InstanceDef::DropGlue(def_id, _)
199-
| InstanceDef::CloneShim(def_id, _) => ty::WithOptParam::dummy(def_id),
199+
| InstanceDef::CloneShim(def_id, _) => ty::WithOptConstParam::dummy(def_id),
200200
}
201201
}
202202

@@ -298,7 +298,7 @@ impl<'tcx> Instance<'tcx> {
298298
def_id,
299299
substs
300300
);
301-
Instance { def: InstanceDef::Item(ty::WithOptParam::dummy(def_id)), substs }
301+
Instance { def: InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)), substs }
302302
}
303303

304304
pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> {
@@ -355,7 +355,7 @@ impl<'tcx> Instance<'tcx> {
355355
pub fn resolve_const_arg(
356356
tcx: TyCtxt<'tcx>,
357357
param_env: ty::ParamEnv<'tcx>,
358-
def: ty::WithOptParam<DefId>,
358+
def: ty::WithOptConstParam<DefId>,
359359
substs: SubstsRef<'tcx>,
360360
) -> Result<Option<Instance<'tcx>>, ErrorReported> {
361361
let substs = tcx.erase_regions(&substs);

src/librustc_middle/ty/mod.rs

+19-17
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ pub enum PredicateKind<'tcx> {
10991099
Subtype(PolySubtypePredicate<'tcx>),
11001100

11011101
/// Constant initializer must evaluate successfully.
1102-
ConstEvaluatable(ty::WithOptParam<DefId>, SubstsRef<'tcx>),
1102+
ConstEvaluatable(ty::WithOptConstParam<DefId>, SubstsRef<'tcx>),
11031103

11041104
/// Constants must be equal. The first component is the const that is expected.
11051105
ConstEquate(&'tcx Const<'tcx>, &'tcx Const<'tcx>),
@@ -1601,40 +1601,42 @@ pub type PlaceholderConst = Placeholder<BoundVar>;
16011601
#[derive(Copy, Clone, Debug, TypeFoldable, Lift, RustcEncodable, RustcDecodable)]
16021602
#[derive(PartialEq, Eq, PartialOrd, Ord)]
16031603
#[derive(Hash, HashStable)]
1604-
pub struct WithOptParam<T> {
1604+
pub struct WithOptConstParam<T> {
16051605
pub did: T,
16061606
/// The `DefId` of the corresponding generic paramter in case `did` is
16071607
/// a const argument.
16081608
///
16091609
/// Note that even if `did` is a const argument, this may still be `None`.
1610-
/// All queries taking `WithOptParam` start by calling `tcx.opt_const_param_of(def.did)`
1610+
/// All queries taking `WithOptConstParam` start by calling `tcx.opt_const_param_of(def.did)`
16111611
/// to potentially update `param_did` in case it `None`.
1612-
pub param_did: Option<DefId>,
1612+
pub const_param_did: Option<DefId>,
16131613
}
16141614

1615-
impl<T> WithOptParam<T> {
1616-
pub fn dummy(did: T) -> WithOptParam<T> {
1617-
WithOptParam { did, param_did: None }
1615+
impl<T> WithOptConstParam<T> {
1616+
pub fn dummy(did: T) -> WithOptConstParam<T> {
1617+
WithOptConstParam { did, const_param_did: None }
16181618
}
16191619
}
16201620

1621-
impl WithOptParam<LocalDefId> {
1622-
pub fn to_global(self) -> WithOptParam<DefId> {
1623-
WithOptParam { did: self.did.to_def_id(), param_did: self.param_did }
1621+
impl WithOptConstParam<LocalDefId> {
1622+
pub fn to_global(self) -> WithOptConstParam<DefId> {
1623+
WithOptConstParam { did: self.did.to_def_id(), const_param_did: self.const_param_did }
16241624
}
16251625

16261626
pub fn ty_def_id(self) -> DefId {
1627-
if let Some(did) = self.param_did { did } else { self.did.to_def_id() }
1627+
if let Some(did) = self.const_param_did { did } else { self.did.to_def_id() }
16281628
}
16291629
}
16301630

1631-
impl WithOptParam<DefId> {
1632-
pub fn as_local(self) -> Option<WithOptParam<LocalDefId>> {
1633-
self.did.as_local().map(|did| WithOptParam { did, param_did: self.param_did })
1631+
impl WithOptConstParam<DefId> {
1632+
pub fn as_local(self) -> Option<WithOptConstParam<LocalDefId>> {
1633+
self.did
1634+
.as_local()
1635+
.map(|did| WithOptConstParam { did, const_param_did: self.const_param_did })
16341636
}
16351637

16361638
pub fn as_const_arg(self) -> Option<(LocalDefId, DefId)> {
1637-
if let Some(param_did) = self.param_did {
1639+
if let Some(param_did) = self.const_param_did {
16381640
if let Some(did) = self.did.as_local() {
16391641
return Some((did, param_did));
16401642
}
@@ -1643,7 +1645,7 @@ impl WithOptParam<DefId> {
16431645
None
16441646
}
16451647

1646-
pub fn expect_local(self) -> WithOptParam<LocalDefId> {
1648+
pub fn expect_local(self) -> WithOptConstParam<LocalDefId> {
16471649
self.as_local().unwrap()
16481650
}
16491651

@@ -1652,7 +1654,7 @@ impl WithOptParam<DefId> {
16521654
}
16531655

16541656
pub fn ty_def_id(self) -> DefId {
1655-
self.param_did.unwrap_or(self.did)
1657+
self.const_param_did.unwrap_or(self.did)
16561658
}
16571659
}
16581660

src/librustc_middle/ty/query/keys.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl Key for DefId {
105105
}
106106
}
107107

108-
impl Key for ty::WithOptParam<LocalDefId> {
108+
impl Key for ty::WithOptConstParam<LocalDefId> {
109109
type CacheSelector = DefaultCacheSelector;
110110

111111
fn query_crate(&self) -> CrateNum {

src/librustc_middle/ty/sty.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2210,12 +2210,12 @@ impl<'tcx> Const<'tcx> {
22102210
/// Literals and const generic parameters are eagerly converted to a constant, everything else
22112211
/// becomes `Unevaluated`.
22122212
pub fn from_anon_const(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx Self {
2213-
Self::const_arg_from_anon_const(tcx, ty::WithOptParam::dummy(def_id))
2213+
Self::from_opt_const_arg_anon_const(tcx, ty::WithOptConstParam::dummy(def_id))
22142214
}
22152215

2216-
pub fn const_arg_from_anon_const(
2216+
pub fn from_opt_const_arg_anon_const(
22172217
tcx: TyCtxt<'tcx>,
2218-
def: ty::WithOptParam<LocalDefId>,
2218+
def: ty::WithOptConstParam<LocalDefId>,
22192219
) -> &'tcx Self {
22202220
debug!("Const::from_anon_const(def={:?})", def);
22212221

@@ -2433,7 +2433,7 @@ pub enum ConstKind<'tcx> {
24332433

24342434
/// Used in the HIR by using `Unevaluated` everywhere and later normalizing to one of the other
24352435
/// variants when the code is monomorphic enough for that.
2436-
Unevaluated(ty::WithOptParam<DefId>, SubstsRef<'tcx>, Option<Promoted>),
2436+
Unevaluated(ty::WithOptConstParam<DefId>, SubstsRef<'tcx>, Option<Promoted>),
24372437

24382438
/// Used to hold computed value.
24392439
Value(ConstValue<'tcx>),

src/librustc_mir/borrow_check/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref];
8888

8989
pub fn provide(providers: &mut Providers) {
9090
*providers = Providers {
91-
mir_borrowck: |tcx, did| mir_borrowck(tcx, ty::WithOptParam::dummy(did)),
91+
mir_borrowck: |tcx, did| mir_borrowck(tcx, ty::WithOptConstParam::dummy(did)),
9292
mir_borrowck_const_arg: |tcx, (did, param_did)| {
93-
mir_borrowck(tcx, ty::WithOptParam { did, param_did: Some(param_did) })
93+
mir_borrowck(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
9494
},
9595
..*providers
9696
};
9797
}
9898

9999
fn mir_borrowck<'tcx>(
100100
tcx: TyCtxt<'tcx>,
101-
def: ty::WithOptParam<LocalDefId>,
101+
def: ty::WithOptConstParam<LocalDefId>,
102102
) -> &'tcx BorrowCheckResult<'tcx> {
103-
if def.param_did.is_none() {
103+
if def.const_param_did.is_none() {
104104
if let Some(param_did) = tcx.opt_const_param_of(def.did) {
105105
return tcx.mir_borrowck_const_arg((def.did, param_did));
106106
}
@@ -123,7 +123,7 @@ fn do_mir_borrowck<'a, 'tcx>(
123123
infcx: &InferCtxt<'a, 'tcx>,
124124
input_body: &Body<'tcx>,
125125
input_promoted: &IndexVec<Promoted, Body<'tcx>>,
126-
def: ty::WithOptParam<LocalDefId>,
126+
def: ty::WithOptConstParam<LocalDefId>,
127127
) -> BorrowCheckResult<'tcx> {
128128
debug!("do_mir_borrowck(def = {:?})", def);
129129

src/librustc_mir/borrow_check/nll.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ crate struct NllOutput<'tcx> {
5959
/// `compute_regions`.
6060
pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'tcx>(
6161
infcx: &InferCtxt<'cx, 'tcx>,
62-
def: ty::WithOptParam<LocalDefId>,
62+
def: ty::WithOptConstParam<LocalDefId>,
6363
param_env: ty::ParamEnv<'tcx>,
6464
body: &mut Body<'tcx>,
6565
promoted: &mut IndexVec<Promoted, Body<'tcx>>,

src/librustc_mir/borrow_check/universal_regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl<'tcx> UniversalRegions<'tcx> {
227227
/// known between those regions.
228228
pub fn new(
229229
infcx: &InferCtxt<'_, 'tcx>,
230-
mir_def: ty::WithOptParam<LocalDefId>,
230+
mir_def: ty::WithOptConstParam<LocalDefId>,
231231
param_env: ty::ParamEnv<'tcx>,
232232
) -> Self {
233233
let tcx = infcx.tcx;
@@ -388,7 +388,7 @@ impl<'tcx> UniversalRegions<'tcx> {
388388

389389
struct UniversalRegionsBuilder<'cx, 'tcx> {
390390
infcx: &'cx InferCtxt<'cx, 'tcx>,
391-
mir_def: ty::WithOptParam<LocalDefId>,
391+
mir_def: ty::WithOptConstParam<LocalDefId>,
392392
mir_hir_id: HirId,
393393
param_env: ty::ParamEnv<'tcx>,
394394
}

src/librustc_mir/transform/check_unsafety.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,13 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
491491
pub(crate) fn provide(providers: &mut Providers) {
492492
*providers = Providers {
493493
unsafety_check_result: |tcx, def_id| {
494-
unsafety_check_result(tcx, ty::WithOptParam::dummy(def_id))
494+
unsafety_check_result(tcx, ty::WithOptConstParam::dummy(def_id))
495495
},
496496
unsafety_check_result_const_arg: |tcx, (did, param_did)| {
497-
unsafety_check_result(tcx, ty::WithOptParam { did, param_did: Some(param_did) })
497+
unsafety_check_result(
498+
tcx,
499+
ty::WithOptConstParam { did, const_param_did: Some(param_did) },
500+
)
498501
},
499502
unsafe_derive_on_repr_packed,
500503
..*providers
@@ -546,9 +549,9 @@ fn check_unused_unsafe(
546549

547550
fn unsafety_check_result<'tcx>(
548551
tcx: TyCtxt<'tcx>,
549-
def: ty::WithOptParam<LocalDefId>,
552+
def: ty::WithOptConstParam<LocalDefId>,
550553
) -> &'tcx UnsafetyCheckResult {
551-
if def.param_did.is_none() {
554+
if def.const_param_did.is_none() {
552555
if let Some(param_did) = tcx.opt_const_param_of(def.did) {
553556
return tcx.unsafety_check_result_const_arg((def.did, param_did));
554557
}

0 commit comments

Comments
 (0)