Skip to content

Commit 6acc1a7

Browse files
Same for types
1 parent 42c9bfd commit 6acc1a7

File tree

11 files changed

+29
-36
lines changed

11 files changed

+29
-36
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,7 @@ fn param_env_with_gat_bounds<'tcx>(
24682468
let normalize_impl_ty_args = ty::GenericArgs::identity_for_item(tcx, container_id)
24692469
.extend_to(tcx, impl_ty.def_id, |param, _| match param.kind {
24702470
GenericParamDefKind::Type { .. } => {
2471-
let kind = ty::BoundTyKind::Param(param.def_id, param.name);
2471+
let kind = ty::BoundTyKind::Param(param.def_id);
24722472
let bound_var = ty::BoundVariableKind::Ty(kind);
24732473
bound_vars.push(bound_var);
24742474
Ty::new_bound(

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,13 @@ fn resolve_bound_vars(tcx: TyCtxt<'_>, local_def_id: hir::OwnerId) -> ResolveBou
279279
rbv
280280
}
281281

282-
fn late_arg_as_bound_arg<'tcx>(
283-
tcx: TyCtxt<'tcx>,
284-
param: &GenericParam<'tcx>,
285-
) -> ty::BoundVariableKind {
282+
fn late_arg_as_bound_arg<'tcx>(param: &GenericParam<'tcx>) -> ty::BoundVariableKind {
286283
let def_id = param.def_id.to_def_id();
287-
let name = tcx.item_name(def_id);
288284
match param.kind {
289285
GenericParamKind::Lifetime { .. } => {
290286
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id))
291287
}
292-
GenericParamKind::Type { .. } => {
293-
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, name))
294-
}
288+
GenericParamKind::Type { .. } => ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id)),
295289
GenericParamKind::Const { .. } => ty::BoundVariableKind::Const,
296290
}
297291
}
@@ -305,7 +299,7 @@ fn generic_param_def_as_bound_arg(param: &ty::GenericParamDef) -> ty::BoundVaria
305299
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(param.def_id))
306300
}
307301
ty::GenericParamDefKind::Type { .. } => {
308-
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(param.def_id, param.name))
302+
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(param.def_id))
309303
}
310304
ty::GenericParamDefKind::Const { .. } => ty::BoundVariableKind::Const,
311305
}
@@ -386,7 +380,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
386380
trait_ref.bound_generic_params.iter().enumerate().map(|(late_bound_idx, param)| {
387381
let arg = ResolvedArg::late(initial_bound_vars + late_bound_idx as u32, param);
388382
bound_vars.insert(param.def_id, arg);
389-
late_arg_as_bound_arg(self.tcx, param)
383+
late_arg_as_bound_arg(param)
390384
});
391385
binders.extend(binders_iter);
392386

@@ -485,7 +479,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
485479
.map(|(late_bound_idx, param)| {
486480
(
487481
(param.def_id, ResolvedArg::late(late_bound_idx as u32, param)),
488-
late_arg_as_bound_arg(self.tcx, param),
482+
late_arg_as_bound_arg(param),
489483
)
490484
})
491485
.unzip();
@@ -718,7 +712,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
718712
.map(|(late_bound_idx, param)| {
719713
(
720714
(param.def_id, ResolvedArg::late(late_bound_idx as u32, param)),
721-
late_arg_as_bound_arg(self.tcx, param),
715+
late_arg_as_bound_arg(param),
722716
)
723717
})
724718
.unzip();
@@ -748,7 +742,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
748742
.map(|(late_bound_idx, param)| {
749743
(
750744
(param.def_id, ResolvedArg::late(late_bound_idx as u32, param)),
751-
late_arg_as_bound_arg(self.tcx, param),
745+
late_arg_as_bound_arg(param),
752746
)
753747
})
754748
.unzip();
@@ -957,7 +951,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
957951
.map(|(late_bound_idx, param)| {
958952
(
959953
(param.def_id, ResolvedArg::late(late_bound_idx as u32, param)),
960-
late_arg_as_bound_arg(self.tcx, param),
954+
late_arg_as_bound_arg(param),
961955
)
962956
})
963957
.unzip();
@@ -1171,7 +1165,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
11711165
matches!(param.kind, GenericParamKind::Lifetime { .. })
11721166
&& self.tcx.is_late_bound(param.hir_id)
11731167
})
1174-
.map(|param| late_arg_as_bound_arg(self.tcx, param))
1168+
.map(|param| late_arg_as_bound_arg(param))
11751169
.collect();
11761170
self.record_late_bound_vars(hir_id, binders);
11771171
let scope = Scope::Binder {

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GenericParamAndBoundVarCollector<'_, 't
10501050
}
10511051
ty::Bound(db, bt) if *db >= self.depth => {
10521052
self.vars.insert(match bt.kind {
1053-
ty::BoundTyKind::Param(def_id, _) => def_id,
1053+
ty::BoundTyKind::Param(def_id) => def_id,
10541054
ty::BoundTyKind::Anon => {
10551055
let reported = self
10561056
.cx

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,10 +2067,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20672067
let tcx = self.tcx();
20682068
match tcx.named_bound_var(hir_id) {
20692069
Some(rbv::ResolvedArg::LateBound(debruijn, index, def_id)) => {
2070-
let name = tcx.item_name(def_id.to_def_id());
20712070
let br = ty::BoundTy {
20722071
var: ty::BoundVar::from_u32(index),
2073-
kind: ty::BoundTyKind::Param(def_id.to_def_id(), name),
2072+
kind: ty::BoundTyKind::Param(def_id.to_def_id()),
20742073
};
20752074
Ty::new_bound(tcx, debruijn, br)
20762075
}

compiler/rustc_lint/src/impl_trait_overcaptures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ where
215215
let arg: ty::BoundVariableKind = arg;
216216
match arg {
217217
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id))
218-
| ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, _)) => {
218+
| ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id)) => {
219219
added.push(def_id);
220220
let unique = self.in_scope_parameters.insert(def_id, ParamKind::Late);
221221
assert_eq!(unique, None);

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,9 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
795795
ty::BoundTyKind::Anon => {
796796
rustc_type_ir::debug_bound_var(self, debruijn, bound_ty.var)?
797797
}
798-
ty::BoundTyKind::Param(_, s) => match self.should_print_verbose() {
798+
ty::BoundTyKind::Param(def_id) => match self.should_print_verbose() {
799799
true => p!(write("{:?}", ty.kind())),
800-
false => p!(write("{s}")),
800+
false => p!(write("{}", self.tcx().item_name(def_id))),
801801
},
802802
},
803803
ty::Adt(def, args) => {
@@ -824,9 +824,9 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
824824
}
825825
ty::Placeholder(placeholder) => match placeholder.bound.kind {
826826
ty::BoundTyKind::Anon => p!(write("{placeholder:?}")),
827-
ty::BoundTyKind::Param(_, name) => match self.should_print_verbose() {
827+
ty::BoundTyKind::Param(def_id) => match self.should_print_verbose() {
828828
true => p!(write("{:?}", ty.kind())),
829-
false => p!(write("{name}")),
829+
false => p!(write("{}", self.tcx().item_name(def_id))),
830830
},
831831
},
832832
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {

compiler/rustc_middle/src/ty/structural_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl fmt::Debug for ty::BoundTy {
183183
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
184184
match self.kind {
185185
ty::BoundTyKind::Anon => write!(f, "{:?}", self.var),
186-
ty::BoundTyKind::Param(_, sym) => write!(f, "{sym:?}"),
186+
ty::BoundTyKind::Param(def_id) => write!(f, "{def_id:?}"),
187187
}
188188
}
189189
}

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl<'tcx> rustc_type_ir::inherent::BoundVarLike<TyCtxt<'tcx>> for BoundTy {
400400
#[derive(HashStable)]
401401
pub enum BoundTyKind {
402402
Anon,
403-
Param(DefId, Symbol),
403+
Param(DefId),
404404
}
405405

406406
impl From<BoundVar> for BoundTy {

compiler/rustc_smir/src/stable_mir/unstable/convert/internal.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
// Prefer importing stable_mir over internal rustc constructs to make this file more readable.
77

8-
use rustc_middle::ty::{self as rustc_ty, Const as InternalConst, Ty as InternalTy};
8+
use rustc_middle::ty::{self as rustc_ty, Const as InternalConst, Ty as InternalTy, TyCtxt};
99
use rustc_smir::Tables;
1010
use rustc_span::Symbol;
1111
use stable_mir::abi::Layout;
@@ -446,10 +446,9 @@ impl RustcInternal for BoundVariableKind {
446446
match self {
447447
BoundVariableKind::Ty(kind) => rustc_ty::BoundVariableKind::Ty(match kind {
448448
BoundTyKind::Anon => rustc_ty::BoundTyKind::Anon,
449-
BoundTyKind::Param(def, symbol) => rustc_ty::BoundTyKind::Param(
450-
def.0.internal(tables, tcx),
451-
Symbol::intern(symbol),
452-
),
449+
BoundTyKind::Param(def, _symbol) => {
450+
rustc_ty::BoundTyKind::Param(def.0.internal(tables, tcx))
451+
}
453452
}),
454453
BoundVariableKind::Region(kind) => rustc_ty::BoundVariableKind::Region(match kind {
455454
BoundRegionKind::BrAnon => rustc_ty::BoundRegionKind::Anon,

compiler/rustc_smir/src/stable_mir/unstable/convert/stable/ty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ impl<'tcx> Stable<'tcx> for ty::BoundTyKind {
291291
fn stable<'cx>(
292292
&self,
293293
tables: &mut Tables<'cx, BridgeTys>,
294-
_: &SmirCtxt<'cx, BridgeTys>,
294+
cx: &SmirCtxt<'cx, BridgeTys>,
295295
) -> Self::T {
296296
use stable_mir::ty::BoundTyKind;
297297

298298
match self {
299299
ty::BoundTyKind::Anon => BoundTyKind::Anon,
300-
ty::BoundTyKind::Param(def_id, symbol) => {
301-
BoundTyKind::Param(tables.param_def(*def_id), symbol.to_string())
300+
ty::BoundTyKind::Param(def_id) => {
301+
BoundTyKind::Param(tables.param_def(*def_id), cx.tcx.item_name(*def_id).to_string())
302302
}
303303
}
304304
}

src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,7 +2221,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
22212221
}
22222222

22232223
ty::Bound(_, ref ty) => match ty.kind {
2224-
ty::BoundTyKind::Param(_, name) => Generic(name),
2224+
ty::BoundTyKind::Param(def_id) => Generic(cx.tcx.item_name(def_id)),
22252225
ty::BoundTyKind::Anon => panic!("unexpected anonymous bound type variable"),
22262226
},
22272227

@@ -3192,7 +3192,8 @@ fn clean_bound_vars<'tcx>(
31923192
None
31933193
}
31943194
}
3195-
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, name)) => {
3195+
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id)) => {
3196+
let name = cx.tcx.item_name(def_id);
31963197
Some(GenericParamDef {
31973198
name,
31983199
def_id,

0 commit comments

Comments
 (0)