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

+2-2
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

+1-1
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

+3-3
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

+4-4
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

+2-2
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

+1-1
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

+4-4
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

+2-2
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

+2-1
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

+1-1
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 {

compiler/rustc_error_messages/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(let_chains)]
22
#![feature(once_cell)]
33
#![feature(path_try_exists)]
4+
#![feature(rustc_attrs)]
45
#![feature(type_alias_impl_trait)]
56

67
use fluent_bundle::FluentResource;
@@ -241,6 +242,7 @@ type FluentId = Cow<'static, str>;
241242
/// message so messages of this type must be combined with a `DiagnosticMessage` (using
242243
/// `DiagnosticMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
243244
/// the `SessionSubdiagnostic` derive refer to Fluent identifiers directly.
245+
#[rustc_diagnostic_item = "SubdiagnosticMessage"]
244246
pub enum SubdiagnosticMessage {
245247
/// Non-translatable diagnostic message.
246248
// FIXME(davidtwco): can a `Cow<'static, str>` be used here?
@@ -281,6 +283,7 @@ impl<S: Into<String>> From<S> for SubdiagnosticMessage {
281283
///
282284
/// Intended to be removed once diagnostics are entirely translatable.
283285
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
286+
#[rustc_diagnostic_item = "DiagnosticMessage"]
284287
pub enum DiagnosticMessage {
285288
/// Non-translatable diagnostic message.
286289
// FIXME(davidtwco): can a `Cow<'static, str>` be used here?

compiler/rustc_errors/src/diagnostic.rs

+8
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl<'source> Into<FluentValue<'source>> for DiagnosticArgValue<'source> {
8080

8181
/// Trait implemented by error types. This should not be implemented manually. Instead, use
8282
/// `#[derive(SessionSubdiagnostic)]` -- see [rustc_macros::SessionSubdiagnostic].
83+
#[rustc_diagnostic_item = "AddSubdiagnostic"]
8384
pub trait AddSubdiagnostic {
8485
/// Add a subdiagnostic to an existing diagnostic.
8586
fn add_to_diagnostic(self, diag: &mut Diagnostic);
@@ -283,6 +284,7 @@ impl Diagnostic {
283284
///
284285
/// This span is *not* considered a ["primary span"][`MultiSpan`]; only
285286
/// the `Span` supplied when creating the diagnostic is primary.
287+
#[cfg_attr(not(bootstrap), rustc_lint_diagnostics)]
286288
pub fn span_label(&mut self, span: Span, label: impl Into<SubdiagnosticMessage>) -> &mut Self {
287289
self.span.push_span_label(span, self.subdiagnostic_message_to_diagnostic_message(label));
288290
self
@@ -401,6 +403,7 @@ impl Diagnostic {
401403
}
402404

403405
/// Add a note attached to this diagnostic.
406+
#[cfg_attr(not(bootstrap), rustc_lint_diagnostics)]
404407
pub fn note(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self {
405408
self.sub(Level::Note, msg, MultiSpan::new(), None);
406409
self
@@ -423,6 +426,7 @@ impl Diagnostic {
423426

424427
/// Prints the span with a note above it.
425428
/// This is like [`Diagnostic::note()`], but it gets its own span.
429+
#[cfg_attr(not(bootstrap), rustc_lint_diagnostics)]
426430
pub fn span_note<S: Into<MultiSpan>>(
427431
&mut self,
428432
sp: S,
@@ -444,13 +448,15 @@ impl Diagnostic {
444448
}
445449

446450
/// Add a warning attached to this diagnostic.
451+
#[cfg_attr(not(bootstrap), rustc_lint_diagnostics)]
447452
pub fn warn(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self {
448453
self.sub(Level::Warning, msg, MultiSpan::new(), None);
449454
self
450455
}
451456

452457
/// Prints the span with a warning above it.
453458
/// This is like [`Diagnostic::warn()`], but it gets its own span.
459+
#[cfg_attr(not(bootstrap), rustc_lint_diagnostics)]
454460
pub fn span_warn<S: Into<MultiSpan>>(
455461
&mut self,
456462
sp: S,
@@ -461,6 +467,7 @@ impl Diagnostic {
461467
}
462468

463469
/// Add a help message attached to this diagnostic.
470+
#[cfg_attr(not(bootstrap), rustc_lint_diagnostics)]
464471
pub fn help(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self {
465472
self.sub(Level::Help, msg, MultiSpan::new(), None);
466473
self
@@ -474,6 +481,7 @@ impl Diagnostic {
474481

475482
/// Prints the span with some help above it.
476483
/// This is like [`Diagnostic::help()`], but it gets its own span.
484+
#[cfg_attr(not(bootstrap), rustc_lint_diagnostics)]
477485
pub fn span_help<S: Into<MultiSpan>>(
478486
&mut self,
479487
sp: S,

0 commit comments

Comments
 (0)