Skip to content

Commit dadfa04

Browse files
committed
Remove Const::ty method in favor of field access via the Deref impl
1 parent 9421f74 commit dadfa04

File tree

41 files changed

+74
-81
lines changed

Some content is hidden

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

41 files changed

+74
-81
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
7474
ConstantKind::Ty(const_) => match const_.kind() {
7575
ty::ConstKind::Unevaluated(uv) => uv.expand(),
7676
ty::ConstKind::Value(val) => {
77-
return Some((fx.tcx.valtree_to_const_val((const_.ty(), val)), const_.ty()));
77+
return Some((fx.tcx.valtree_to_const_val((const_.ty, val)), const_.ty));
7878
}
7979
err => span_bug!(
8080
constant.span,

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,14 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
639639
ty::ConstKind::Param(param) => {
640640
write!(output, "{}", param.name)
641641
}
642-
_ => match ct.ty().kind() {
642+
_ => match ct.ty.kind() {
643643
ty::Int(ity) => {
644-
let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty());
644+
let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty);
645645
let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128;
646646
write!(output, "{}", val)
647647
}
648648
ty::Uint(_) => {
649-
let val = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty());
649+
let val = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty);
650650
write!(output, "{}", val)
651651
}
652652
ty::Bool => {

compiler/rustc_codegen_ssa/src/mir/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
2929
mir::ConstantKind::Ty(ct) => match ct.kind() {
3030
ty::ConstKind::Unevaluated(uv) => uv.expand(),
3131
ty::ConstKind::Value(val) => {
32-
return Ok(self.cx.tcx().valtree_to_const_val((ct.ty(), val)));
32+
return Ok(self.cx.tcx().valtree_to_const_val((ct.ty, val)));
3333
}
3434
err => span_bug!(
3535
constant.span,

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
592592
let val = self.tcx.normalize_erasing_regions(self.param_env, *val);
593593
match val {
594594
mir::ConstantKind::Ty(ct) => {
595-
let ty = ct.ty();
595+
let ty = ct.ty;
596596
let valtree = self.eval_ty_constant(ct, span)?;
597597
let const_val = self.tcx.valtree_to_const_val((ty, valtree));
598598
self.const_val_to_op(const_val, ty, layout)

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13941394
let references_self = match pred.skip_binder().term.unpack() {
13951395
ty::TermKind::Ty(ty) => ty.walk().any(|arg| arg == dummy_self.into()),
13961396
ty::TermKind::Const(c) => {
1397-
c.ty().walk().any(|arg| arg == dummy_self.into())
1397+
c.ty.walk().any(|arg| arg == dummy_self.into())
13981398
}
13991399
};
14001400

compiler/rustc_hir_analysis/src/constrained_generic_params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
8383
match c.kind() {
8484
ty::ConstKind::Unevaluated(..) if !self.include_nonconstraining => {
8585
// Constant expressions are not injective
86-
return c.ty().visit_with(self);
86+
return c.ty.visit_with(self);
8787
}
8888
ty::ConstKind::Param(data) => {
8989
self.parameters.push(Parameter::from(data));

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11211121
.into(),
11221122
GenericArgKind::Const(arg) => self
11231123
.next_const_var(
1124-
arg.ty(),
1124+
arg.ty,
11251125
ConstVariableOrigin {
11261126
span: rustc_span::DUMMY_SP,
11271127
kind: ConstVariableOriginKind::MiscVariable,

compiler/rustc_hir_typeck/src/writeback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> {
793793
debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct);
794794
let e = self.report_error(ct);
795795
self.replaced_with_error = Some(e);
796-
self.tcx().const_error_with_guaranteed(ct.ty(), e)
796+
self.tcx().const_error_with_guaranteed(ct.ty, e)
797797
}
798798
}
799799
}

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
484484
ui = ty::UniverseIndex::ROOT;
485485
}
486486
return self.canonicalize_const_var(
487-
CanonicalVarInfo { kind: CanonicalVarKind::Const(ui, ct.ty()) },
487+
CanonicalVarInfo { kind: CanonicalVarKind::Const(ui, ct.ty) },
488488
ct,
489489
);
490490
}
@@ -503,7 +503,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
503503
ty::ConstKind::Placeholder(placeholder) => {
504504
return self.canonicalize_const_var(
505505
CanonicalVarInfo {
506-
kind: CanonicalVarKind::PlaceholderConst(placeholder, ct.ty()),
506+
kind: CanonicalVarKind::PlaceholderConst(placeholder, ct.ty),
507507
},
508508
ct,
509509
);
@@ -773,10 +773,8 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
773773
self.fold_const(bound_to)
774774
} else {
775775
let var = self.canonical_var(info, const_var.into());
776-
self.tcx().mk_const(
777-
ty::ConstKind::Bound(self.binder_index, var),
778-
self.fold_ty(const_var.ty()),
779-
)
776+
self.tcx()
777+
.mk_const(ty::ConstKind::Bound(self.binder_index, var), self.fold_ty(const_var.ty))
780778
}
781779
}
782780
}

compiler/rustc_infer/src/infer/combine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
753753
origin: var_value.origin,
754754
val: ConstVariableValue::Unknown { universe: self.for_universe },
755755
});
756-
Ok(self.tcx().mk_const_var(new_var_id, c.ty()))
756+
Ok(self.tcx().mk_const_var(new_var_id, c.ty))
757757
}
758758
}
759759
}
@@ -767,7 +767,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
767767
)?;
768768
Ok(self.tcx().mk_const(
769769
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
770-
c.ty(),
770+
c.ty,
771771
))
772772
}
773773
_ => relate::super_relate_consts(self, c, c),
@@ -975,7 +975,7 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
975975
},
976976
},
977977
);
978-
Ok(self.tcx().mk_const_var(new_var_id, c.ty()))
978+
Ok(self.tcx().mk_const_var(new_var_id, c.ty))
979979
}
980980
}
981981
}
@@ -990,7 +990,7 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
990990

991991
Ok(self.tcx().mk_const(
992992
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
993-
c.ty(),
993+
c.ty,
994994
))
995995
}
996996
_ => relate::super_relate_consts(self, c, c),

0 commit comments

Comments
 (0)