Skip to content

Commit f8704be

Browse files
committed
Auto merge of rust-lang#153416 - JonathanBrouwer:rollup-eezxWTV, r=JonathanBrouwer
Rollup of 12 pull requests Successful merges: - rust-lang#153402 (miri subtree update) - rust-lang#152164 (Lint unused features) - rust-lang#152801 (Refactor WriteBackendMethods a bit) - rust-lang#153196 (Update path separators to be available in const context) - rust-lang#153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors) - rust-lang#153317 (Abort after `representability` errors) - rust-lang#153276 (Remove `cycle_fatal` query modifier) - rust-lang#153300 (Tweak some of our internal `#[rustc_*]` TEST attributes) - rust-lang#153396 (use `minicore` in some `run-make` tests) - rust-lang#153401 (Migrationg of `LintDiagnostic` - part 7) - rust-lang#153406 (Remove a ping for myself) - rust-lang#153414 (Rename translation -> formatting)
2 parents b55e20a + 53ef4d2 commit f8704be

File tree

305 files changed

+1817
-1655
lines changed

Some content is hidden

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

305 files changed

+1817
-1655
lines changed

compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use rustc_hir::Target;
21
use rustc_hir::attrs::AttributeKind;
2+
use rustc_hir::{MethodKind, Target};
33
use rustc_span::{Span, Symbol, sym};
44

55
use crate::attributes::prelude::Allow;
@@ -25,6 +25,20 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpDefParentsParser {
2525
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpDefParents;
2626
}
2727

28+
pub(crate) struct RustcDumpInferredOutlivesParser;
29+
30+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpInferredOutlivesParser {
31+
const PATH: &[Symbol] = &[sym::rustc_dump_inferred_outlives];
32+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
33+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
34+
Allow(Target::Struct),
35+
Allow(Target::Enum),
36+
Allow(Target::Union),
37+
Allow(Target::TyAlias),
38+
]);
39+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpInferredOutlives;
40+
}
41+
2842
pub(crate) struct RustcDumpItemBoundsParser;
2943

3044
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpItemBoundsParser {
@@ -34,21 +48,88 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpItemBoundsParser {
3448
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpItemBounds;
3549
}
3650

51+
pub(crate) struct RustcDumpObjectLifetimeDefaultsParser;
52+
53+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpObjectLifetimeDefaultsParser {
54+
const PATH: &[Symbol] = &[sym::rustc_dump_object_lifetime_defaults];
55+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
56+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
57+
Allow(Target::AssocConst),
58+
Allow(Target::AssocTy),
59+
Allow(Target::Const),
60+
Allow(Target::Enum),
61+
Allow(Target::Fn),
62+
Allow(Target::ForeignFn),
63+
Allow(Target::Impl { of_trait: false }),
64+
Allow(Target::Impl { of_trait: true }),
65+
Allow(Target::Method(MethodKind::Inherent)),
66+
Allow(Target::Method(MethodKind::Trait { body: false })),
67+
Allow(Target::Method(MethodKind::Trait { body: true })),
68+
Allow(Target::Method(MethodKind::TraitImpl)),
69+
Allow(Target::Struct),
70+
Allow(Target::Trait),
71+
Allow(Target::TraitAlias),
72+
Allow(Target::TyAlias),
73+
Allow(Target::Union),
74+
]);
75+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpObjectLifetimeDefaults;
76+
}
77+
3778
pub(crate) struct RustcDumpPredicatesParser;
3879

3980
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpPredicatesParser {
4081
const PATH: &[Symbol] = &[sym::rustc_dump_predicates];
4182
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
4283
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
43-
Allow(Target::Struct),
84+
Allow(Target::AssocConst),
85+
Allow(Target::AssocTy),
86+
Allow(Target::Const),
87+
Allow(Target::Delegation { mac: false }),
88+
Allow(Target::Delegation { mac: true }),
4489
Allow(Target::Enum),
45-
Allow(Target::Union),
90+
Allow(Target::Fn),
91+
Allow(Target::Impl { of_trait: false }),
92+
Allow(Target::Impl { of_trait: true }),
93+
Allow(Target::Method(MethodKind::Inherent)),
94+
Allow(Target::Method(MethodKind::Trait { body: false })),
95+
Allow(Target::Method(MethodKind::Trait { body: true })),
96+
Allow(Target::Method(MethodKind::TraitImpl)),
97+
Allow(Target::Struct),
4698
Allow(Target::Trait),
47-
Allow(Target::AssocTy),
99+
Allow(Target::TraitAlias),
100+
Allow(Target::TyAlias),
101+
Allow(Target::Union),
48102
]);
49103
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpPredicates;
50104
}
51105

106+
pub(crate) struct RustcDumpVariancesParser;
107+
108+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpVariancesParser {
109+
const PATH: &[Symbol] = &[sym::rustc_dump_variances];
110+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
111+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
112+
Allow(Target::Enum),
113+
Allow(Target::Fn),
114+
Allow(Target::Method(MethodKind::Inherent)),
115+
Allow(Target::Method(MethodKind::Trait { body: false })),
116+
Allow(Target::Method(MethodKind::Trait { body: true })),
117+
Allow(Target::Method(MethodKind::TraitImpl)),
118+
Allow(Target::Struct),
119+
Allow(Target::Union),
120+
]);
121+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpVariances;
122+
}
123+
124+
pub(crate) struct RustcDumpVariancesOfOpaquesParser;
125+
126+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpVariancesOfOpaquesParser {
127+
const PATH: &[Symbol] = &[sym::rustc_dump_variances_of_opaques];
128+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
129+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
130+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpVariancesOfOpaques;
131+
}
132+
52133
pub(crate) struct RustcDumpVtableParser;
53134

54135
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpVtableParser {

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,15 +588,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcLintUntrackedQueryInformationPa
588588
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintUntrackedQueryInformation;
589589
}
590590

591-
pub(crate) struct RustcObjectLifetimeDefaultParser;
592-
593-
impl<S: Stage> NoArgsAttributeParser<S> for RustcObjectLifetimeDefaultParser {
594-
const PATH: &[Symbol] = &[sym::rustc_object_lifetime_default];
595-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
596-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
597-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcObjectLifetimeDefault;
598-
}
599-
600591
pub(crate) struct RustcSimdMonomorphizeLaneLimitParser;
601592

602593
impl<S: Stage> SingleAttributeParser<S> for RustcSimdMonomorphizeLaneLimitParser {

compiler/rustc_attr_parsing/src/attributes/test_attrs.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,6 @@ impl<S: Stage> SingleAttributeParser<S> for ShouldPanicParser {
9393
}
9494
}
9595

96-
pub(crate) struct RustcVarianceParser;
97-
98-
impl<S: Stage> NoArgsAttributeParser<S> for RustcVarianceParser {
99-
const PATH: &[Symbol] = &[sym::rustc_variance];
100-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
101-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
102-
Allow(Target::Struct),
103-
Allow(Target::Enum),
104-
Allow(Target::Union),
105-
]);
106-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcVariance;
107-
}
108-
109-
pub(crate) struct RustcVarianceOfOpaquesParser;
110-
111-
impl<S: Stage> NoArgsAttributeParser<S> for RustcVarianceOfOpaquesParser {
112-
const PATH: &[Symbol] = &[sym::rustc_variance_of_opaques];
113-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
114-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
115-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcVarianceOfOpaques;
116-
}
117-
11896
pub(crate) struct ReexportTestHarnessMainParser;
11997

12098
impl<S: Stage> SingleAttributeParser<S> for ReexportTestHarnessMainParser {
@@ -215,20 +193,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcEvaluateWhereClausesParser {
215193
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEvaluateWhereClauses;
216194
}
217195

218-
pub(crate) struct RustcOutlivesParser;
219-
220-
impl<S: Stage> NoArgsAttributeParser<S> for RustcOutlivesParser {
221-
const PATH: &[Symbol] = &[sym::rustc_outlives];
222-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
223-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
224-
Allow(Target::Struct),
225-
Allow(Target::Enum),
226-
Allow(Target::Union),
227-
Allow(Target::TyAlias),
228-
]);
229-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcOutlives;
230-
}
231-
232196
pub(crate) struct TestRunnerParser;
233197

234198
impl<S: Stage> SingleAttributeParser<S> for TestRunnerParser {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,13 @@ attribute_parsers!(
281281
Single<WithoutArgs<RustcDenyExplicitImplParser>>,
282282
Single<WithoutArgs<RustcDoNotConstCheckParser>>,
283283
Single<WithoutArgs<RustcDumpDefParentsParser>>,
284+
Single<WithoutArgs<RustcDumpInferredOutlivesParser>>,
284285
Single<WithoutArgs<RustcDumpItemBoundsParser>>,
286+
Single<WithoutArgs<RustcDumpObjectLifetimeDefaultsParser>>,
285287
Single<WithoutArgs<RustcDumpPredicatesParser>>,
286288
Single<WithoutArgs<RustcDumpUserArgsParser>>,
289+
Single<WithoutArgs<RustcDumpVariancesOfOpaquesParser>>,
290+
Single<WithoutArgs<RustcDumpVariancesParser>>,
287291
Single<WithoutArgs<RustcDumpVtableParser>>,
288292
Single<WithoutArgs<RustcDynIncompatibleTraitParser>>,
289293
Single<WithoutArgs<RustcEffectiveVisibilityParser>>,
@@ -306,9 +310,7 @@ attribute_parsers!(
306310
Single<WithoutArgs<RustcNonConstTraitMethodParser>>,
307311
Single<WithoutArgs<RustcNonnullOptimizationGuaranteedParser>>,
308312
Single<WithoutArgs<RustcNounwindParser>>,
309-
Single<WithoutArgs<RustcObjectLifetimeDefaultParser>>,
310313
Single<WithoutArgs<RustcOffloadKernelParser>>,
311-
Single<WithoutArgs<RustcOutlivesParser>>,
312314
Single<WithoutArgs<RustcParenSugarParser>>,
313315
Single<WithoutArgs<RustcPassByValueParser>>,
314316
Single<WithoutArgs<RustcPassIndirectlyInNonRusticAbisParser>>,
@@ -323,8 +325,6 @@ attribute_parsers!(
323325
Single<WithoutArgs<RustcStrictCoherenceParser>>,
324326
Single<WithoutArgs<RustcTrivialFieldReadsParser>>,
325327
Single<WithoutArgs<RustcUnsafeSpecializationMarkerParser>>,
326-
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
327-
Single<WithoutArgs<RustcVarianceParser>>,
328328
Single<WithoutArgs<ThreadLocalParser>>,
329329
Single<WithoutArgs<TrackCallerParser>>,
330330
// tidy-alphabetical-end

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13101310
{
13111311
let mut span: MultiSpan = spans.clone().into();
13121312
err.arg("ty", param_ty.to_string());
1313-
let msg = err.dcx.eagerly_translate_to_string(
1313+
let msg = err.dcx.eagerly_format_to_string(
13141314
msg!("`{$ty}` is made to be an `FnOnce` closure here"),
13151315
err.args.iter(),
13161316
);

compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ pub(crate) struct FormatUnusedArg {
764764
impl Subdiagnostic for FormatUnusedArg {
765765
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
766766
diag.arg("named", self.named);
767-
let msg = diag.eagerly_translate(msg!(
767+
let msg = diag.eagerly_format(msg!(
768768
"{$named ->
769769
[true] named argument
770770
*[false] argument
@@ -947,8 +947,8 @@ pub(crate) struct AsmClobberNoReg {
947947
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AsmClobberNoReg {
948948
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
949949
// eager translation as `span_labels` takes `AsRef<str>`
950-
let lbl1 = dcx.eagerly_translate_to_string(msg!("clobber_abi"), [].into_iter());
951-
let lbl2 = dcx.eagerly_translate_to_string(msg!("generic outputs"), [].into_iter());
950+
let lbl1 = dcx.eagerly_format_to_string(msg!("clobber_abi"), [].into_iter());
951+
let lbl2 = dcx.eagerly_format_to_string(msg!("generic outputs"), [].into_iter());
952952
Diag::new(
953953
dcx,
954954
level,

compiler/rustc_codegen_gcc/src/back/lto.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ use object::read::archive::ArchiveFile;
2626
use rustc_codegen_ssa::back::lto::SerializedModule;
2727
use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, SharedEmitter};
2828
use rustc_codegen_ssa::traits::*;
29-
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
29+
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen, ModuleKind, looks_like_rust_object_file};
3030
use rustc_data_structures::memmap::Mmap;
3131
use rustc_data_structures::profiling::SelfProfilerRef;
3232
use rustc_errors::{DiagCtxt, DiagCtxtHandle};
3333
use rustc_log::tracing::info;
3434
use rustc_session::config::Lto;
3535
use tempfile::{TempDir, tempdir};
3636

37-
use crate::back::write::save_temp_bitcode;
37+
use crate::back::write::{codegen, save_temp_bitcode};
3838
use crate::errors::LtoBitcodeFromRlib;
3939
use crate::{GccCodegenBackend, GccContext, LtoMode, to_gcc_opt_level};
4040

@@ -112,7 +112,7 @@ pub(crate) fn run_fat(
112112
shared_emitter: &SharedEmitter,
113113
each_linked_rlib_for_lto: &[PathBuf],
114114
modules: Vec<FatLtoInput<GccCodegenBackend>>,
115-
) -> ModuleCodegen<GccContext> {
115+
) -> CompiledModule {
116116
let dcx = DiagCtxt::new(Box::new(shared_emitter.clone()));
117117
let dcx = dcx.handle();
118118
let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx);
@@ -132,12 +132,12 @@ pub(crate) fn run_fat(
132132
fn fat_lto(
133133
cgcx: &CodegenContext,
134134
prof: &SelfProfilerRef,
135-
_dcx: DiagCtxtHandle<'_>,
135+
dcx: DiagCtxtHandle<'_>,
136136
modules: Vec<FatLtoInput<GccCodegenBackend>>,
137137
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
138138
tmp_path: TempDir,
139139
//symbols_below_threshold: &[String],
140-
) -> ModuleCodegen<GccContext> {
140+
) -> CompiledModule {
141141
let _timer = prof.generic_activity("GCC_fat_lto_build_monolithic_module");
142142
info!("going for a fat lto");
143143

@@ -260,7 +260,7 @@ fn fat_lto(
260260
// of now.
261261
module.module_llvm.temp_dir = Some(tmp_path);
262262

263-
module
263+
codegen(cgcx, prof, dcx, module, &cgcx.module_config)
264264
}
265265

266266
pub struct ModuleBuffer(PathBuf);

compiler/rustc_codegen_gcc/src/back/write.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ use std::{env, fs};
22

33
use gccjit::{Context, OutputKind};
44
use rustc_codegen_ssa::back::link::ensure_removed;
5-
use rustc_codegen_ssa::back::write::{
6-
BitcodeSection, CodegenContext, EmitObj, ModuleConfig, SharedEmitter,
7-
};
5+
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
86
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
97
use rustc_data_structures::profiling::SelfProfilerRef;
10-
use rustc_errors::DiagCtxt;
8+
use rustc_errors::DiagCtxtHandle;
119
use rustc_fs_util::link_or_copy;
1210
use rustc_log::tracing::debug;
1311
use rustc_session::config::OutputType;
@@ -20,13 +18,10 @@ use crate::{GccContext, LtoMode};
2018
pub(crate) fn codegen(
2119
cgcx: &CodegenContext,
2220
prof: &SelfProfilerRef,
23-
shared_emitter: &SharedEmitter,
21+
dcx: DiagCtxtHandle<'_>,
2422
module: ModuleCodegen<GccContext>,
2523
config: &ModuleConfig,
2624
) -> CompiledModule {
27-
let dcx = DiagCtxt::new(Box::new(shared_emitter.clone()));
28-
let dcx = dcx.handle();
29-
3025
let _timer = prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
3126
{
3227
let context = &module.module_llvm.context;

0 commit comments

Comments
 (0)