Skip to content

Commit edab34a

Browse files
committed
Auto merge of rust-lang#98091 - Dylan-DPC:rollup-ueb6b5x, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#97869 (BTree: tweak internal comments) - rust-lang#97935 (Rename the `ConstS::val` field as `kind`.) - rust-lang#97948 (lint: add diagnostic translation migration lints) - rust-lang#98042 (Fix compat_fn option method on miri) - rust-lang#98069 (rustdoc: remove link on slice brackets) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents da895e7 + 27f7805 commit edab34a

File tree

96 files changed

+522
-250
lines changed

Some content is hidden

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

96 files changed

+522
-250
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
378378
} else {
379379
let tcx = self.tcx();
380380
let maybe_uneval = match constant.literal {
381-
ConstantKind::Ty(ct) => match ct.val() {
381+
ConstantKind::Ty(ct) => match ct.kind() {
382382
ty::ConstKind::Unevaluated(uv) => Some(uv),
383383
_ => None,
384384
},
@@ -1841,7 +1841,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18411841
fn check_operand(&mut self, op: &Operand<'tcx>, location: Location) {
18421842
if let Operand::Constant(constant) = op {
18431843
let maybe_uneval = match constant.literal {
1844-
ConstantKind::Ty(ct) => match ct.val() {
1844+
ConstantKind::Ty(ct) => match ct.kind() {
18451845
ty::ConstKind::Unevaluated(uv) => Some(uv),
18461846
_ => None,
18471847
},

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ fn codegen_stmt<'tcx>(
710710
let times = fx
711711
.monomorphize(times)
712712
.eval(fx.tcx, ParamEnv::reveal_all())
713-
.val()
713+
.kind()
714714
.try_to_bits(fx.tcx.data_layout.pointer_size)
715715
.unwrap();
716716
if operand.layout().size.bytes() == 0 {

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
4545
ConstantKind::Ty(ct) => ct,
4646
ConstantKind::Val(..) => continue,
4747
};
48-
match const_.val() {
48+
match const_.kind() {
4949
ConstKind::Value(_) => {}
5050
ConstKind::Unevaluated(unevaluated) => {
5151
if let Err(err) =
@@ -126,7 +126,7 @@ pub(crate) fn codegen_constant<'tcx>(
126126
ConstantKind::Ty(ct) => ct,
127127
ConstantKind::Val(val, ty) => return codegen_const_value(fx, val, ty),
128128
};
129-
let const_val = match const_.val() {
129+
let const_val = match const_.kind() {
130130
ConstKind::Value(const_val) => const_val,
131131
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
132132
if fx.tcx.is_static(def.did) =>
@@ -469,7 +469,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
469469
match operand {
470470
Operand::Constant(const_) => match const_.literal {
471471
ConstantKind::Ty(const_) => {
472-
fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).val().try_to_value()
472+
fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).kind().try_to_value()
473473
}
474474
ConstantKind::Val(val, _) => Some(val),
475475
},

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ fn push_debuginfo_type_name<'tcx>(
180180
if cpp_like_debuginfo {
181181
output.push_str("array$<");
182182
push_debuginfo_type_name(tcx, inner_type, true, output, visited);
183-
match len.val() {
183+
match len.kind() {
184184
ty::ConstKind::Param(param) => write!(output, ",{}>", param.name).unwrap(),
185185
_ => write!(output, ",{}>", len.eval_usize(tcx, ty::ParamEnv::reveal_all()))
186186
.unwrap(),
187187
}
188188
} else {
189189
output.push('[');
190190
push_debuginfo_type_name(tcx, inner_type, true, output, visited);
191-
match len.val() {
191+
match len.kind() {
192192
ty::ConstKind::Param(param) => write!(output, "; {}]", param.name).unwrap(),
193193
_ => write!(output, "; {}]", len.eval_usize(tcx, ty::ParamEnv::reveal_all()))
194194
.unwrap(),
@@ -679,7 +679,7 @@ fn push_generic_params_internal<'tcx>(
679679
}
680680

681681
fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut String) {
682-
match ct.val() {
682+
match ct.kind() {
683683
ty::ConstKind::Param(param) => {
684684
write!(output, "{}", param.name)
685685
}
@@ -703,7 +703,7 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
703703
// but we get a deterministic, virtually unique value for the constant.
704704
let hcx = &mut tcx.create_stable_hashing_context();
705705
let mut hasher = StableHasher::new();
706-
hcx.while_hashing_spans(false, |hcx| ct.val().hash_stable(hcx, &mut hasher));
706+
hcx.while_hashing_spans(false, |hcx| ct.kind().hash_stable(hcx, &mut hasher));
707707
// Let's only emit 64 bits of the hash value. That should be plenty for
708708
// avoiding collisions and will make the emitted type names shorter.
709709
let hash: u64 = hasher.finish();

compiler/rustc_codegen_ssa/src/mir/constant.rs

Lines changed: 2 additions & 2 deletions
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) => ct,
3030
mir::ConstantKind::Val(val, _) => return Ok(val),
3131
};
32-
match ct.val() {
32+
match ct.kind() {
3333
ty::ConstKind::Unevaluated(ct) => self
3434
.cx
3535
.tcx()
@@ -65,7 +65,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
6565
.fields
6666
.iter()
6767
.map(|field| {
68-
if let Some(prim) = field.val().try_to_scalar() {
68+
if let Some(prim) = field.kind().try_to_scalar() {
6969
let layout = bx.layout_of(field_ty);
7070
let Abi::Scalar(scalar) = layout.abi else {
7171
bug!("from_const: invalid ByVal layout: {:#?}", layout);

compiler/rustc_const_eval/src/const_eval/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub(crate) fn deref_const<'tcx>(
197197
},
198198
};
199199

200-
tcx.mk_const(ty::ConstS { val: ty::ConstKind::Value(op_to_const(&ecx, &mplace.into())), ty })
200+
tcx.mk_const(ty::ConstS { kind: ty::ConstKind::Value(op_to_const(&ecx, &mplace.into())), ty })
201201
}
202202

203203
#[instrument(skip(tcx), level = "debug")]

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
622622
/// "universe" (param_env).
623623
pub fn const_to_op(
624624
&self,
625-
val: ty::Const<'tcx>,
625+
c: ty::Const<'tcx>,
626626
layout: Option<TyAndLayout<'tcx>>,
627627
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
628-
match val.val() {
628+
match c.kind() {
629629
ty::ConstKind::Param(_) | ty::ConstKind::Bound(..) => throw_inval!(TooGeneric),
630630
ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => {
631631
throw_inval!(AlreadyReported(reported))
@@ -635,9 +635,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
635635
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())
636636
}
637637
ty::ConstKind::Infer(..) | ty::ConstKind::Placeholder(..) => {
638-
span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", val)
638+
span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", c)
639639
}
640-
ty::ConstKind::Value(val_val) => self.const_val_to_op(val_val, val.ty(), layout),
640+
ty::ConstKind::Value(val) => self.const_val_to_op(val, c.ty(), layout),
641641
}
642642
}
643643

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ where
5555
assert!(matches!(ty.kind(), ty::Param(_)))
5656
}
5757
ty::subst::GenericArgKind::Const(ct) => {
58-
assert!(matches!(ct.val(), ty::ConstKind::Param(_)))
58+
assert!(matches!(ct.kind(), ty::ConstKind::Param(_)))
5959
}
6060
ty::subst::GenericArgKind::Lifetime(..) => (),
6161
},
@@ -69,7 +69,7 @@ where
6969
}
7070

7171
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
72-
match c.val() {
72+
match c.kind() {
7373
ty::ConstKind::Param(..) => ControlFlow::Break(FoundParam),
7474
_ => c.super_visit_with(self),
7575
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ where
353353

354354
// Check the qualifs of the value of `const` items.
355355
if let Some(ct) = constant.literal.const_for_ty() {
356-
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted }) = ct.val() {
356+
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted }) = ct.kind()
357+
{
357358
// Use qualifs of the type for the promoted. Promoteds in MIR body should be possible
358359
// only for `NeedsNonConstDrop` with precise drop checking. This is the only const
359360
// check performed after the promotion. Verify that with an assertion.

compiler/rustc_const_eval/src/transform/promote_consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
842842
literal: tcx
843843
.mk_const(ty::ConstS {
844844
ty,
845-
val: ty::ConstKind::Unevaluated(ty::Unevaluated {
845+
kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
846846
def,
847847
substs: InternalSubsts::for_item(tcx, def.did, |param, _| {
848848
if let ty::GenericParamDefKind::Lifetime = param.kind {

0 commit comments

Comments
 (0)