Skip to content

Commit 08f38c4

Browse files
committed
Remove Const::kind method in favor of field access via the Deref impl
1 parent dadfa04 commit 08f38c4

File tree

71 files changed

+117
-122
lines changed

Some content is hidden

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

71 files changed

+117
-122
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ fn check_opaque_type_parameter_valid(
381381
GenericArgKind::Lifetime(lt) => {
382382
matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_))
383383
}
384-
GenericArgKind::Const(ct) => matches!(ct.kind(), ty::ConstKind::Param(_)),
384+
GenericArgKind::Const(ct) => matches!(ct.kind, ty::ConstKind::Param(_)),
385385
};
386386

387387
if arg_is_param {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
353353
} else {
354354
let tcx = self.tcx();
355355
let maybe_uneval = match constant.literal {
356-
ConstantKind::Ty(ct) => match ct.kind() {
356+
ConstantKind::Ty(ct) => match ct.kind {
357357
ty::ConstKind::Unevaluated(_) => {
358358
bug!("should not encounter unevaluated ConstantKind::Ty here, got {:?}", ct)
359359
}

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ fn codegen_stmt<'tcx>(
722722
let times = fx
723723
.monomorphize(times)
724724
.eval(fx.tcx, ParamEnv::reveal_all())
725-
.kind()
725+
.kind
726726
.try_to_bits(fx.tcx.data_layout.pointer_size)
727727
.unwrap();
728728
if operand.layout().size.bytes() == 0 {

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
7171
) -> Option<(ConstValue<'tcx>, Ty<'tcx>)> {
7272
let constant_kind = fx.monomorphize(constant.literal);
7373
let uv = match constant_kind {
74-
ConstantKind::Ty(const_) => match const_.kind() {
74+
ConstantKind::Ty(const_) => match const_.kind {
7575
ty::ConstKind::Unevaluated(uv) => uv.expand(),
7676
ty::ConstKind::Value(val) => {
7777
return Some((fx.tcx.valtree_to_const_val((const_.ty, val)), const_.ty));

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ fn push_debuginfo_type_name<'tcx>(
178178
if cpp_like_debuginfo {
179179
output.push_str("array$<");
180180
push_debuginfo_type_name(tcx, inner_type, true, output, visited);
181-
match len.kind() {
181+
match len.kind {
182182
ty::ConstKind::Param(param) => write!(output, ",{}>", param.name).unwrap(),
183183
_ => write!(output, ",{}>", len.eval_usize(tcx, ty::ParamEnv::reveal_all()))
184184
.unwrap(),
185185
}
186186
} else {
187187
output.push('[');
188188
push_debuginfo_type_name(tcx, inner_type, true, output, visited);
189-
match len.kind() {
189+
match len.kind {
190190
ty::ConstKind::Param(param) => write!(output, "; {}]", param.name).unwrap(),
191191
_ => write!(output, "; {}]", len.eval_usize(tcx, ty::ParamEnv::reveal_all()))
192192
.unwrap(),
@@ -635,7 +635,7 @@ fn push_generic_params_internal<'tcx>(
635635
}
636636

637637
fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut String) {
638-
match ct.kind() {
638+
match ct.kind {
639639
ty::ConstKind::Param(param) => {
640640
write!(output, "{}", param.name)
641641
}

compiler/rustc_codegen_ssa/src/mir/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
2626
) -> Result<ConstValue<'tcx>, ErrorHandled> {
2727
let ct = self.monomorphize(constant.literal);
2828
let uv = match ct {
29-
mir::ConstantKind::Ty(ct) => match ct.kind() {
29+
mir::ConstantKind::Ty(ct) => match ct.kind {
3030
ty::ConstKind::Unevaluated(uv) => uv.expand(),
3131
ty::ConstKind::Value(val) => {
3232
return Ok(self.cx.tcx().valtree_to_const_val((ct.ty, val)));

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
557557
val: ty::Const<'tcx>,
558558
span: Option<Span>,
559559
) -> InterpResult<'tcx, ValTree<'tcx>> {
560-
Ok(match val.kind() {
560+
Ok(match val.kind {
561561
ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(..) => {
562562
throw_inval!(TooGeneric)
563563
}

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ where
5757
}
5858

5959
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
60-
match c.kind() {
60+
match c.kind {
6161
ty::ConstKind::Param(..) => ControlFlow::Break(FoundParam),
6262
_ => c.super_visit_with(self),
6363
}

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ where
348348
// way for type and mir constants.
349349
let uneval = match constant.literal {
350350
ConstantKind::Ty(ct)
351-
if matches!(ct.kind(), ty::ConstKind::Param(_) | ty::ConstKind::Error(_)) =>
351+
if matches!(ct.kind, ty::ConstKind::Param(_) | ty::ConstKind::Error(_)) =>
352352
{
353353
None
354354
}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14171417
}
14181418

14191419
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
1420-
if let ty::ConstKind::Param(param) = c.kind() {
1420+
if let ty::ConstKind::Param(param) = c.kind {
14211421
self.params.insert(param.index);
14221422
}
14231423
c.super_visit_with(self)

0 commit comments

Comments
 (0)