Skip to content

Commit ddf4386

Browse files
committed
Auto merge of #64515 - varkor:kindedterm, r=oli-obk
Rename `subst::Kind` to `subst::GenericArg` And `subst::UnpackedKind` to `subst::GenericArgKind`. Individual variable names (e.g. `kind`) are not renamed, which would be an infeasible mission. Fixes #64352. r? @eddyb
2 parents 134004f + e3fb05d commit ddf4386

File tree

51 files changed

+357
-337
lines changed

Some content is hidden

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

51 files changed

+357
-337
lines changed

src/librustc/ich/impls_ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ where
5656
}
5757
}
5858

59-
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::Kind<'tcx> {
59+
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::GenericArg<'tcx> {
6060
fn hash_stable<W: StableHasherResult>(&self,
6161
hcx: &mut StableHashingContext<'a>,
6262
hasher: &mut StableHasher<W>) {

src/librustc/infer/canonical/canonicalizer.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::infer::InferCtxt;
1313
use crate::mir::interpret::ConstValue;
1414
use std::sync::atomic::Ordering;
1515
use crate::ty::fold::{TypeFoldable, TypeFolder};
16-
use crate::ty::subst::Kind;
16+
use crate::ty::subst::GenericArg;
1717
use crate::ty::{self, BoundVar, InferConst, List, Ty, TyCtxt, TypeFlags};
1818
use crate::ty::flags::FlagComputation;
1919

@@ -282,7 +282,7 @@ struct Canonicalizer<'cx, 'tcx> {
282282
query_state: &'cx mut OriginalQueryValues<'tcx>,
283283
// Note that indices is only used once `var_values` is big enough to be
284284
// heap-allocated.
285-
indices: FxHashMap<Kind<'tcx>, BoundVar>,
285+
indices: FxHashMap<GenericArg<'tcx>, BoundVar>,
286286
canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode,
287287
needs_canonical_flags: TypeFlags,
288288

@@ -566,7 +566,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
566566
/// or returns an existing variable if `kind` has already been
567567
/// seen. `kind` is expected to be an unbound variable (or
568568
/// potentially a free region).
569-
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundVar {
569+
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: GenericArg<'tcx>) -> BoundVar {
570570
let Canonicalizer {
571571
variables,
572572
query_state,

src/librustc/infer/canonical/mod.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use smallvec::SmallVec;
3232
use std::ops::Index;
3333
use syntax::source_map::Span;
3434
use crate::ty::fold::TypeFoldable;
35-
use crate::ty::subst::Kind;
35+
use crate::ty::subst::GenericArg;
3636
use crate::ty::{self, BoundVar, InferConst, Lift, List, Region, TyCtxt};
3737

3838
mod canonicalizer;
@@ -66,7 +66,7 @@ impl<'tcx> UseSpecializedDecodable for CanonicalVarInfos<'tcx> {}
6666
/// canonicalized query response.
6767
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable, HashStable)]
6868
pub struct CanonicalVarValues<'tcx> {
69-
pub var_values: IndexVec<BoundVar, Kind<'tcx>>,
69+
pub var_values: IndexVec<BoundVar, GenericArg<'tcx>>,
7070
}
7171

7272
/// When we canonicalize a value to form a query, we wind up replacing
@@ -83,7 +83,7 @@ pub struct OriginalQueryValues<'tcx> {
8383

8484
/// This is equivalent to `CanonicalVarValues`, but using a
8585
/// `SmallVec` yields a significant performance win.
86-
pub var_values: SmallVec<[Kind<'tcx>; 8]>,
86+
pub var_values: SmallVec<[GenericArg<'tcx>; 8]>,
8787
}
8888

8989
impl Default for OriginalQueryValues<'tcx> {
@@ -308,7 +308,7 @@ impl<'tcx, V> Canonical<'tcx, V> {
308308
}
309309

310310
pub type QueryOutlivesConstraint<'tcx> =
311-
ty::Binder<ty::OutlivesPredicate<Kind<'tcx>, Region<'tcx>>>;
311+
ty::Binder<ty::OutlivesPredicate<GenericArg<'tcx>, Region<'tcx>>>;
312312

313313
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
314314
/// Creates a substitution S for the canonical value with fresh
@@ -359,7 +359,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
359359
variables: &List<CanonicalVarInfo>,
360360
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
361361
) -> CanonicalVarValues<'tcx> {
362-
let var_values: IndexVec<BoundVar, Kind<'tcx>> = variables
362+
let var_values: IndexVec<BoundVar, GenericArg<'tcx>> = variables
363363
.iter()
364364
.map(|info| self.instantiate_canonical_var(span, *info, &universe_map))
365365
.collect();
@@ -376,7 +376,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
376376
span: Span,
377377
cv_info: CanonicalVarInfo,
378378
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
379-
) -> Kind<'tcx> {
379+
) -> GenericArg<'tcx> {
380380
match cv_info.kind {
381381
CanonicalVarKind::Ty(ty_kind) => {
382382
let ty = match ty_kind {
@@ -495,19 +495,19 @@ impl<'tcx> CanonicalVarValues<'tcx> {
495495
/// we'll return a substitution `subst` with:
496496
/// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`.
497497
pub fn make_identity(&self, tcx: TyCtxt<'tcx>) -> Self {
498-
use crate::ty::subst::UnpackedKind;
498+
use crate::ty::subst::GenericArgKind;
499499

500500
CanonicalVarValues {
501501
var_values: self.var_values.iter()
502502
.zip(0..)
503503
.map(|(kind, i)| match kind.unpack() {
504-
UnpackedKind::Type(..) => tcx.mk_ty(
504+
GenericArgKind::Type(..) => tcx.mk_ty(
505505
ty::Bound(ty::INNERMOST, ty::BoundVar::from_u32(i).into())
506506
).into(),
507-
UnpackedKind::Lifetime(..) => tcx.mk_region(
507+
GenericArgKind::Lifetime(..) => tcx.mk_region(
508508
ty::ReLateBound(ty::INNERMOST, ty::BoundRegion::BrAnon(i))
509509
).into(),
510-
UnpackedKind::Const(ct) => {
510+
GenericArgKind::Const(ct) => {
511511
tcx.mk_const(ty::Const {
512512
ty: ct.ty,
513513
val: ConstValue::Infer(
@@ -522,8 +522,8 @@ impl<'tcx> CanonicalVarValues<'tcx> {
522522
}
523523

524524
impl<'a, 'tcx> IntoIterator for &'a CanonicalVarValues<'tcx> {
525-
type Item = Kind<'tcx>;
526-
type IntoIter = ::std::iter::Cloned<::std::slice::Iter<'a, Kind<'tcx>>>;
525+
type Item = GenericArg<'tcx>;
526+
type IntoIter = ::std::iter::Cloned<::std::slice::Iter<'a, GenericArg<'tcx>>>;
527527

528528
fn into_iter(self) -> Self::IntoIter {
529529
self.var_values.iter().cloned()
@@ -570,9 +570,9 @@ BraceStructLiftImpl! {
570570
}
571571

572572
impl<'tcx> Index<BoundVar> for CanonicalVarValues<'tcx> {
573-
type Output = Kind<'tcx>;
573+
type Output = GenericArg<'tcx>;
574574

575-
fn index(&self, value: BoundVar) -> &Kind<'tcx> {
575+
fn index(&self, value: BoundVar) -> &GenericArg<'tcx> {
576576
&self.var_values[value]
577577
}
578578
}

src/librustc/infer/canonical/query_response.rs

+23-20
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::traits::query::{Fallible, NoSolution};
2525
use crate::traits::TraitEngine;
2626
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
2727
use crate::ty::fold::TypeFoldable;
28-
use crate::ty::subst::{Kind, UnpackedKind};
28+
use crate::ty::subst::{GenericArg, GenericArgKind};
2929
use crate::ty::{self, BoundVar, InferConst, Ty, TyCtxt};
3030
use crate::util::captures::Captures;
3131

@@ -298,11 +298,14 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
298298
&v.var_values[BoundVar::new(index)]
299299
});
300300
match (original_value.unpack(), result_value.unpack()) {
301-
(UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => {
302-
// no action needed
301+
(
302+
GenericArgKind::Lifetime(ty::ReErased),
303+
GenericArgKind::Lifetime(ty::ReErased),
304+
) => {
305+
// No action needed.
303306
}
304307

305-
(UnpackedKind::Lifetime(v_o), UnpackedKind::Lifetime(v_r)) => {
308+
(GenericArgKind::Lifetime(v_o), GenericArgKind::Lifetime(v_r)) => {
306309
// To make `v_o = v_r`, we emit `v_o: v_r` and `v_r: v_o`.
307310
if v_o != v_r {
308311
output_query_region_constraints
@@ -314,12 +317,12 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
314317
}
315318
}
316319

317-
(UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => {
320+
(GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
318321
let ok = self.at(cause, param_env).eq(v1, v2)?;
319322
obligations.extend(ok.into_obligations());
320323
}
321324

322-
(UnpackedKind::Const(v1), UnpackedKind::Const(v2)) => {
325+
(GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
323326
let ok = self.at(cause, param_env).eq(v1, v2)?;
324327
obligations.extend(ok.into_obligations());
325328
}
@@ -462,14 +465,14 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
462465
// is directly equal to one of the canonical variables in the
463466
// result, then we can type the corresponding value from the
464467
// input. See the example above.
465-
let mut opt_values: IndexVec<BoundVar, Option<Kind<'tcx>>> =
468+
let mut opt_values: IndexVec<BoundVar, Option<GenericArg<'tcx>>> =
466469
IndexVec::from_elem_n(None, query_response.variables.len());
467470

468471
// In terms of our example above, we are iterating over pairs like:
469472
// [(?A, Vec<?0>), ('static, '?1), (?B, ?0)]
470473
for (original_value, result_value) in original_values.var_values.iter().zip(result_values) {
471474
match result_value.unpack() {
472-
UnpackedKind::Type(result_value) => {
475+
GenericArgKind::Type(result_value) => {
473476
// e.g., here `result_value` might be `?0` in the example above...
474477
if let ty::Bound(debruijn, b) = result_value.kind {
475478
// ...in which case we would set `canonical_vars[0]` to `Some(?U)`.
@@ -479,7 +482,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
479482
opt_values[b.var] = Some(*original_value);
480483
}
481484
}
482-
UnpackedKind::Lifetime(result_value) => {
485+
GenericArgKind::Lifetime(result_value) => {
483486
// e.g., here `result_value` might be `'?1` in the example above...
484487
if let &ty::RegionKind::ReLateBound(debruijn, br) = result_value {
485488
// ... in which case we would set `canonical_vars[0]` to `Some('static)`.
@@ -489,7 +492,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
489492
opt_values[br.assert_bound_var()] = Some(*original_value);
490493
}
491494
}
492-
UnpackedKind::Const(result_value) => {
495+
GenericArgKind::Const(result_value) => {
493496
if let ty::Const {
494497
val: ConstValue::Infer(InferConst::Canonical(debrujin, b)),
495498
..
@@ -553,7 +556,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
553556
// canonical variable; this is taken from
554557
// `query_response.var_values` after applying the substitution
555558
// `result_subst`.
556-
let substituted_query_response = |index: BoundVar| -> Kind<'tcx> {
559+
let substituted_query_response = |index: BoundVar| -> GenericArg<'tcx> {
557560
query_response.substitute_projected(self.tcx, &result_subst, |v| &v.var_values[index])
558561
};
559562

@@ -586,17 +589,17 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
586589
cause.clone(),
587590
param_env,
588591
match k1.unpack() {
589-
UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives(
592+
GenericArgKind::Lifetime(r1) => ty::Predicate::RegionOutlives(
590593
ty::Binder::bind(
591594
ty::OutlivesPredicate(r1, r2)
592595
)
593596
),
594-
UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives(
597+
GenericArgKind::Type(t1) => ty::Predicate::TypeOutlives(
595598
ty::Binder::bind(
596599
ty::OutlivesPredicate(t1, r2)
597600
)
598601
),
599-
UnpackedKind::Const(..) => {
602+
GenericArgKind::Const(..) => {
600603
// Consts cannot outlive one another, so we don't expect to
601604
// ecounter this branch.
602605
span_bug!(cause.span, "unexpected const outlives {:?}", constraint);
@@ -613,29 +616,29 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
613616
cause: &ObligationCause<'tcx>,
614617
param_env: ty::ParamEnv<'tcx>,
615618
variables1: &OriginalQueryValues<'tcx>,
616-
variables2: impl Fn(BoundVar) -> Kind<'tcx>,
619+
variables2: impl Fn(BoundVar) -> GenericArg<'tcx>,
617620
) -> InferResult<'tcx, ()> {
618621
self.commit_if_ok(|_| {
619622
let mut obligations = vec![];
620623
for (index, value1) in variables1.var_values.iter().enumerate() {
621624
let value2 = variables2(BoundVar::new(index));
622625

623626
match (value1.unpack(), value2.unpack()) {
624-
(UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => {
627+
(GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
625628
obligations
626629
.extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
627630
}
628631
(
629-
UnpackedKind::Lifetime(ty::ReErased),
630-
UnpackedKind::Lifetime(ty::ReErased),
632+
GenericArgKind::Lifetime(ty::ReErased),
633+
GenericArgKind::Lifetime(ty::ReErased),
631634
) => {
632635
// no action needed
633636
}
634-
(UnpackedKind::Lifetime(v1), UnpackedKind::Lifetime(v2)) => {
637+
(GenericArgKind::Lifetime(v1), GenericArgKind::Lifetime(v2)) => {
635638
obligations
636639
.extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
637640
}
638-
(UnpackedKind::Const(v1), UnpackedKind::Const(v2)) => {
641+
(GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
639642
let ok = self.at(cause, param_env).eq(v1, v2)?;
640643
obligations.extend(ok.into_obligations());
641644
}

src/librustc/infer/canonical/substitute.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
use crate::infer::canonical::{Canonical, CanonicalVarValues};
1010
use crate::ty::fold::TypeFoldable;
11-
use crate::ty::subst::UnpackedKind;
11+
use crate::ty::subst::GenericArgKind;
1212
use crate::ty::{self, TyCtxt};
1313

1414
impl<'tcx, V> Canonical<'tcx, V> {
@@ -58,21 +58,21 @@ where
5858
} else {
5959
let fld_r = |br: ty::BoundRegion| {
6060
match var_values.var_values[br.assert_bound_var()].unpack() {
61-
UnpackedKind::Lifetime(l) => l,
61+
GenericArgKind::Lifetime(l) => l,
6262
r => bug!("{:?} is a region but value is {:?}", br, r),
6363
}
6464
};
6565

6666
let fld_t = |bound_ty: ty::BoundTy| {
6767
match var_values.var_values[bound_ty.var].unpack() {
68-
UnpackedKind::Type(ty) => ty,
68+
GenericArgKind::Type(ty) => ty,
6969
r => bug!("{:?} is a type but value is {:?}", bound_ty, r),
7070
}
7171
};
7272

7373
let fld_c = |bound_ct: ty::BoundVar, _| {
7474
match var_values.var_values[bound_ct].unpack() {
75-
UnpackedKind::Const(ct) => ct,
75+
GenericArgKind::Const(ct) => ct,
7676
c => bug!("{:?} is a const but value is {:?}", bound_ct, c),
7777
}
7878
};

src/librustc/infer/error_reporting/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
464464
use hir::def_id::CrateNum;
465465
use hir::map::DisambiguatedDefPathData;
466466
use ty::print::Printer;
467-
use ty::subst::Kind;
467+
use ty::subst::GenericArg;
468468

469469
struct AbsolutePathPrinter<'tcx> {
470470
tcx: TyCtxt<'tcx>,
@@ -548,7 +548,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
548548
fn path_generic_args(
549549
self,
550550
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
551-
_args: &[Kind<'tcx>],
551+
_args: &[GenericArg<'tcx>],
552552
) -> Result<Self::Path, Self::Error> {
553553
print_prefix(self)
554554
}

src/librustc/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine};
2020
use crate::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
2121
use crate::ty::fold::{TypeFolder, TypeFoldable};
2222
use crate::ty::relate::RelateResult;
23-
use crate::ty::subst::{Kind, InternalSubsts, SubstsRef};
23+
use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef};
2424
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, InferConst};
2525
use crate::ty::{FloatVid, IntVid, TyVid, ConstVid};
2626
use crate::util::nodemap::FxHashMap;
@@ -1110,7 +1110,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11101110
self.next_region_var_in_universe(RegionVariableOrigin::NLL(origin), universe)
11111111
}
11121112

1113-
pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> Kind<'tcx> {
1113+
pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> GenericArg<'tcx> {
11141114
match param.kind {
11151115
GenericParamDefKind::Lifetime => {
11161116
// Create a region inference variable for the given

src/librustc/infer/nll_relate/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::traits::DomainGoal;
2626
use crate::ty::error::TypeError;
2727
use crate::ty::fold::{TypeFoldable, TypeVisitor};
2828
use crate::ty::relate::{self, Relate, RelateResult, TypeRelation};
29-
use crate::ty::subst::Kind;
29+
use crate::ty::subst::GenericArg;
3030
use crate::ty::{self, Ty, TyCtxt, InferConst};
3131
use crate::mir::interpret::ConstValue;
3232
use rustc_data_structures::fx::FxHashMap;
@@ -124,7 +124,7 @@ pub trait TypeRelatingDelegate<'tcx> {
124124
#[derive(Clone, Debug)]
125125
struct ScopesAndKind<'tcx> {
126126
scopes: Vec<BoundRegionScope<'tcx>>,
127-
kind: Kind<'tcx>,
127+
kind: GenericArg<'tcx>,
128128
}
129129

130130
#[derive(Clone, Debug, Default)]

0 commit comments

Comments
 (0)