Auto merge of #139949 - matthiaskrgr:rollup-pxc5tsx, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #138632 (Stabilize `cfg_boolean_literals`)
 - #139416 (unstable book; document `macro_metavar_expr_concat`)
 - #139782 (Consistent with treating Ctor Call as Struct in liveness analysis)
 - #139885 (document RUSTC_BOOTSTRAP, RUSTC_OVERRIDE_VERSION_STRING, and -Z allow-features in the unstable book)
 - #139904 (Explicitly annotate edition for `unpretty=expanded` and `unpretty=hir` tests)
 - #139932 (transmutability: Refactor tests for simplicity)
 - #139944 (Move eager translation to a method on Diag)
 - #139948 (git: ignore `60600a6fa4` for blame purposes)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-04-17 11:21:54 +00:00
commit 883f9f72e8
240 changed files with 1038 additions and 978 deletions

View file

@ -4,7 +4,7 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic,
EmissionGuarantee, IntoDiagArg, Level, MultiSpan, SubdiagMessageOp, Subdiagnostic,
EmissionGuarantee, IntoDiagArg, Level, MultiSpan, Subdiagnostic,
};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
@ -107,11 +107,7 @@ pub enum AdjustSignatureBorrow {
}
impl Subdiagnostic for AdjustSignatureBorrow {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
match self {
AdjustSignatureBorrow::Borrow { to_borrow } => {
diag.arg("len", to_borrow.len());
@ -381,11 +377,7 @@ pub enum RegionOriginNote<'a> {
}
impl Subdiagnostic for RegionOriginNote<'_> {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
let mut label_or_note = |span, msg: DiagMessage| {
let sub_count = diag.children.iter().filter(|d| d.span.is_dummy()).count();
let expanded_sub_count = diag.children.iter().filter(|d| !d.span.is_dummy()).count();
@ -446,11 +438,7 @@ pub enum LifetimeMismatchLabels {
}
impl Subdiagnostic for LifetimeMismatchLabels {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
match self {
LifetimeMismatchLabels::InRet { param_span, ret_span, span, label_var1 } => {
diag.span_label(param_span, fluent::trait_selection_declared_different);
@ -495,11 +483,7 @@ pub struct AddLifetimeParamsSuggestion<'a> {
}
impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
let mut mk_suggestion = || {
let Some(anon_reg) = self.tcx.is_suitable_region(self.generic_param_scope, self.sub)
else {
@ -689,11 +673,7 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
}
impl Subdiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
mut self,
diag: &mut Diag<'_, G>,
_f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(mut self, diag: &mut Diag<'_, G>) {
self.unmet_requirements
.push_span_label(self.binding_span, fluent::trait_selection_msl_introduces_static);
diag.span_note(self.unmet_requirements, fluent::trait_selection_msl_unmet_req);
@ -1008,17 +988,13 @@ pub struct ConsiderBorrowingParamHelp {
}
impl Subdiagnostic for ConsiderBorrowingParamHelp {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
let mut type_param_span: MultiSpan = self.spans.clone().into();
for &span in &self.spans {
// Seems like we can't call f() here as Into<DiagMessage> is required
type_param_span.push_span_label(span, fluent::trait_selection_tid_consider_borrowing);
}
let msg = f(diag, fluent::trait_selection_tid_param_help.into());
let msg = diag.eagerly_translate(fluent::trait_selection_tid_param_help);
diag.span_help(type_param_span, msg);
}
}
@ -1053,18 +1029,14 @@ pub struct DynTraitConstraintSuggestion {
}
impl Subdiagnostic for DynTraitConstraintSuggestion {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
let mut multi_span: MultiSpan = vec![self.span].into();
multi_span.push_span_label(self.span, fluent::trait_selection_dtcs_has_lifetime_req_label);
multi_span
.push_span_label(self.ident.span, fluent::trait_selection_dtcs_introduces_requirement);
let msg = f(diag, fluent::trait_selection_dtcs_has_req_note.into());
let msg = diag.eagerly_translate(fluent::trait_selection_dtcs_has_req_note);
diag.span_note(multi_span, msg);
let msg = f(diag, fluent::trait_selection_dtcs_suggestion.into());
let msg = diag.eagerly_translate(fluent::trait_selection_dtcs_suggestion);
diag.span_suggestion_verbose(
self.span.shrink_to_hi(),
msg,
@ -1101,11 +1073,7 @@ pub struct ReqIntroducedLocations {
}
impl Subdiagnostic for ReqIntroducedLocations {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
mut self,
diag: &mut Diag<'_, G>,
f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(mut self, diag: &mut Diag<'_, G>) {
for sp in self.spans {
self.span.push_span_label(sp, fluent::trait_selection_ril_introduced_here);
}
@ -1114,7 +1082,7 @@ impl Subdiagnostic for ReqIntroducedLocations {
self.span.push_span_label(self.fn_decl_span, fluent::trait_selection_ril_introduced_by);
}
self.span.push_span_label(self.cause_span, fluent::trait_selection_ril_because_of);
let msg = f(diag, fluent::trait_selection_ril_static_introduced_by.into());
let msg = diag.eagerly_translate(fluent::trait_selection_ril_static_introduced_by);
diag.span_note(self.span, msg);
}
}
@ -1513,13 +1481,9 @@ pub struct SuggestTuplePatternMany {
}
impl Subdiagnostic for SuggestTuplePatternMany {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
diag.arg("path", self.path);
let message = f(diag, crate::fluent_generated::trait_selection_stp_wrap_many.into());
let message = diag.eagerly_translate(fluent::trait_selection_stp_wrap_many);
diag.multipart_suggestions(
message,
self.compatible_variants.into_iter().map(|variant| {
@ -1752,11 +1716,7 @@ pub struct AddPreciseCapturingAndParams {
}
impl Subdiagnostic for AddPreciseCapturingAndParams {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
diag.arg("new_lifetime", self.new_lifetime);
diag.multipart_suggestion_verbose(
fluent::trait_selection_precise_capturing_new_but_apit,
@ -1896,11 +1856,7 @@ pub struct AddPreciseCapturingForOvercapture {
}
impl Subdiagnostic for AddPreciseCapturingForOvercapture {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
let applicability = if self.apit_spans.is_empty() {
Applicability::MachineApplicable
} else {

View file

@ -1,4 +1,4 @@
use rustc_errors::{Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp, Subdiagnostic};
use rustc_errors::{Diag, EmissionGuarantee, IntoDiagArg, Subdiagnostic};
use rustc_hir::def_id::LocalDefId;
use rustc_middle::bug;
use rustc_middle::ty::{self, TyCtxt};
@ -162,17 +162,13 @@ impl RegionExplanation<'_> {
}
impl Subdiagnostic for RegionExplanation<'_> {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
f: &F,
) {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
diag.arg("pref_kind", self.prefix);
diag.arg("suff_kind", self.suffix);
diag.arg("desc_kind", self.desc.kind);
diag.arg("desc_arg", self.desc.arg);
let msg = f(diag, fluent::trait_selection_region_explanation.into());
let msg = diag.eagerly_translate(fluent::trait_selection_region_explanation);
if let Some(span) = self.desc.span {
diag.span_note(span, msg);
} else {