Skip to content

Commit 8bccf12

Browse files
committed
Auto merge of #152104 - JonathanBrouwer:rollup-N93TdHm, r=JonathanBrouwer
Rollup of 12 pull requests Successful merges: - #150992 (link modifier `export-symbols`: export all global symbols from selected uptream c static libraries) - #151534 (target: fix destabilising target-spec-json) - #152088 (rustbook/README.md: add missing `)`) - #151526 (Fix autodiff codegen tests) - #151810 (citool: report debuginfo test statistics) - #151952 (Revert doc attribute parsing errors to future warnings) - #152065 (Convert to inline diagnostics in `rustc_ty_utils`) - #152066 (Convert to inline diagnostics in `rustc_session`) - #152069 (Convert to inline diagnostics in `rustc_privacy`) - #152072 (Convert to inline diagnostics in `rustc_monomorphize`) - #152083 (Fix set_times_nofollow for directory on windows) - #152102 (Convert to inline diagnostics in all codegen backends) Failed merges: - #152068 (Convert to inline diagnostics in `rustc_resolve`) - #152070 (Convert to inline diagnostics in `rustc_pattern_analysis`)
2 parents 930ecbc + cf0e19b commit 8bccf12

File tree

119 files changed

+1373
-1171
lines changed

Some content is hidden

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

119 files changed

+1373
-1171
lines changed

Cargo.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,7 +3635,6 @@ dependencies = [
36353635
"rustc_codegen_ssa",
36363636
"rustc_data_structures",
36373637
"rustc_errors",
3638-
"rustc_fluent_macro",
36393638
"rustc_fs_util",
36403639
"rustc_hashes",
36413640
"rustc_hir",
@@ -3799,18 +3798,15 @@ dependencies = [
37993798
"rustc_middle",
38003799
"rustc_mir_build",
38013800
"rustc_mir_transform",
3802-
"rustc_monomorphize",
38033801
"rustc_parse",
38043802
"rustc_passes",
38053803
"rustc_pattern_analysis",
3806-
"rustc_privacy",
38073804
"rustc_public",
38083805
"rustc_resolve",
38093806
"rustc_session",
38103807
"rustc_span",
38113808
"rustc_target",
38123809
"rustc_trait_selection",
3813-
"rustc_ty_utils",
38143810
"serde_json",
38153811
"shlex",
38163812
"tracing",
@@ -4373,7 +4369,6 @@ dependencies = [
43734369
"rustc_abi",
43744370
"rustc_data_structures",
43754371
"rustc_errors",
4376-
"rustc_fluent_macro",
43774372
"rustc_hir",
43784373
"rustc_index",
43794374
"rustc_macros",
@@ -4486,7 +4481,6 @@ dependencies = [
44864481
"rustc_ast",
44874482
"rustc_data_structures",
44884483
"rustc_errors",
4489-
"rustc_fluent_macro",
44904484
"rustc_hir",
44914485
"rustc_macros",
44924486
"rustc_middle",
@@ -4641,7 +4635,6 @@ dependencies = [
46414635
"rustc_data_structures",
46424636
"rustc_errors",
46434637
"rustc_feature",
4644-
"rustc_fluent_macro",
46454638
"rustc_fs_util",
46464639
"rustc_hashes",
46474640
"rustc_hir",
@@ -4797,7 +4790,6 @@ dependencies = [
47974790
"rustc_abi",
47984791
"rustc_data_structures",
47994792
"rustc_errors",
4800-
"rustc_fluent_macro",
48014793
"rustc_hashes",
48024794
"rustc_hir",
48034795
"rustc_index",

compiler/rustc_attr_parsing/src/attributes/doc.rs

Lines changed: 83 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,42 @@ fn check_attr_crate_level<S: Stage>(cx: &mut AcceptContext<'_, '_, S>, span: Spa
7070
true
7171
}
7272

73+
// FIXME: To be removed once merged and replace with `cx.expected_name_value(span, _name)`.
74+
fn expected_name_value<S: Stage>(
75+
cx: &mut AcceptContext<'_, '_, S>,
76+
span: Span,
77+
_name: Option<Symbol>,
78+
) {
79+
cx.emit_lint(
80+
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
81+
AttributeLintKind::ExpectedNameValue,
82+
span,
83+
);
84+
}
85+
86+
// FIXME: remove this method once merged and use `cx.expected_no_args(span)` instead.
87+
fn expected_no_args<S: Stage>(cx: &mut AcceptContext<'_, '_, S>, span: Span) {
88+
cx.emit_lint(
89+
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
90+
AttributeLintKind::ExpectedNoArgs,
91+
span,
92+
);
93+
}
94+
95+
// FIXME: remove this method once merged and use `cx.expected_no_args(span)` instead.
96+
// cx.expected_string_literal(span, _actual_literal);
97+
fn expected_string_literal<S: Stage>(
98+
cx: &mut AcceptContext<'_, '_, S>,
99+
span: Span,
100+
_actual_literal: Option<&MetaItemLit>,
101+
) {
102+
cx.emit_lint(
103+
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
104+
AttributeLintKind::MalformedDoc,
105+
span,
106+
);
107+
}
108+
73109
fn parse_keyword_and_attribute<S: Stage>(
74110
cx: &mut AcceptContext<'_, '_, S>,
75111
path: &OwnedPathParser,
@@ -78,12 +114,12 @@ fn parse_keyword_and_attribute<S: Stage>(
78114
attr_name: Symbol,
79115
) {
80116
let Some(nv) = args.name_value() else {
81-
cx.expected_name_value(args.span().unwrap_or(path.span()), path.word_sym());
117+
expected_name_value(cx, args.span().unwrap_or(path.span()), path.word_sym());
82118
return;
83119
};
84120

85121
let Some(value) = nv.value_as_str() else {
86-
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
122+
expected_string_literal(cx, nv.value_span, Some(nv.value_as_lit()));
87123
return;
88124
};
89125

@@ -127,12 +163,21 @@ impl DocParser {
127163
match path.word_sym() {
128164
Some(sym::no_crate_inject) => {
129165
if let Err(span) = args.no_args() {
130-
cx.expected_no_args(span);
166+
expected_no_args(cx, span);
131167
return;
132168
}
133169

134-
if self.attribute.no_crate_inject.is_some() {
135-
cx.duplicate_key(path.span(), sym::no_crate_inject);
170+
if let Some(used_span) = self.attribute.no_crate_inject {
171+
let unused_span = path.span();
172+
cx.emit_lint(
173+
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
174+
AttributeLintKind::UnusedDuplicate {
175+
this: unused_span,
176+
other: used_span,
177+
warning: true,
178+
},
179+
unused_span,
180+
);
136181
return;
137182
}
138183

@@ -144,7 +189,14 @@ impl DocParser {
144189
}
145190
Some(sym::attr) => {
146191
let Some(list) = args.list() else {
147-
cx.expected_list(cx.attr_span, args);
192+
// FIXME: remove this method once merged and uncomment the line below instead.
193+
// cx.expected_list(cx.attr_span, args);
194+
let span = cx.attr_span;
195+
cx.emit_lint(
196+
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
197+
AttributeLintKind::MalformedDoc,
198+
span,
199+
);
148200
return;
149201
};
150202

@@ -246,7 +298,7 @@ impl DocParser {
246298
inline: DocInline,
247299
) {
248300
if let Err(span) = args.no_args() {
249-
cx.expected_no_args(span);
301+
expected_no_args(cx, span);
250302
return;
251303
}
252304

@@ -328,7 +380,14 @@ impl DocParser {
328380
match sub_item.args() {
329381
a @ (ArgParser::NoArgs | ArgParser::NameValue(_)) => {
330382
let Some(name) = sub_item.path().word_sym() else {
331-
cx.expected_identifier(sub_item.path().span());
383+
// FIXME: remove this method once merged and uncomment the line
384+
// below instead.
385+
// cx.expected_identifier(sub_item.path().span());
386+
cx.emit_lint(
387+
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
388+
AttributeLintKind::MalformedDoc,
389+
sub_item.path().span(),
390+
);
332391
continue;
333392
};
334393
if let Ok(CfgEntry::NameValue { name, value, .. }) =
@@ -391,7 +450,7 @@ impl DocParser {
391450
macro_rules! no_args {
392451
($ident: ident) => {{
393452
if let Err(span) = args.no_args() {
394-
cx.expected_no_args(span);
453+
expected_no_args(cx, span);
395454
return;
396455
}
397456

@@ -410,7 +469,7 @@ impl DocParser {
410469
macro_rules! no_args_and_not_crate_level {
411470
($ident: ident) => {{
412471
if let Err(span) = args.no_args() {
413-
cx.expected_no_args(span);
472+
expected_no_args(cx, span);
414473
return;
415474
}
416475
let span = path.span();
@@ -423,7 +482,7 @@ impl DocParser {
423482
macro_rules! no_args_and_crate_level {
424483
($ident: ident) => {{
425484
if let Err(span) = args.no_args() {
426-
cx.expected_no_args(span);
485+
expected_no_args(cx, span);
427486
return;
428487
}
429488
let span = path.span();
@@ -436,12 +495,12 @@ impl DocParser {
436495
macro_rules! string_arg_and_crate_level {
437496
($ident: ident) => {{
438497
let Some(nv) = args.name_value() else {
439-
cx.expected_name_value(args.span().unwrap_or(path.span()), path.word_sym());
498+
expected_name_value(cx, args.span().unwrap_or(path.span()), path.word_sym());
440499
return;
441500
};
442501

443502
let Some(s) = nv.value_as_str() else {
444-
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
503+
expected_string_literal(cx, nv.value_span, Some(nv.value_as_lit()));
445504
return;
446505
};
447506

@@ -512,7 +571,14 @@ impl DocParser {
512571
self.parse_single_test_doc_attr_item(cx, mip);
513572
}
514573
MetaItemOrLitParser::Lit(lit) => {
515-
cx.unexpected_literal(lit.span);
574+
// FIXME: remove this method once merged and uncomment the line
575+
// below instead.
576+
// cx.unexpected_literal(lit.span);
577+
cx.emit_lint(
578+
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
579+
AttributeLintKind::MalformedDoc,
580+
lit.span,
581+
);
516582
}
517583
}
518584
}
@@ -582,7 +648,7 @@ impl DocParser {
582648
let suggestions = cx.suggestions();
583649
let span = cx.attr_span;
584650
cx.emit_lint(
585-
rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT,
651+
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
586652
AttributeLintKind::IllFormedAttributeInput { suggestions, docs: None },
587653
span,
588654
);
@@ -595,14 +661,14 @@ impl DocParser {
595661
self.parse_single_doc_attr_item(cx, mip);
596662
}
597663
MetaItemOrLitParser::Lit(lit) => {
598-
cx.expected_name_value(lit.span, None);
664+
expected_name_value(cx, lit.span, None);
599665
}
600666
}
601667
}
602668
}
603669
ArgParser::NameValue(nv) => {
604670
if nv.value_as_str().is_none() {
605-
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
671+
expected_string_literal(cx, nv.value_span, Some(nv.value_as_lit()));
606672
} else {
607673
unreachable!(
608674
"Should have been handled at the same time as sugar-syntaxed doc comments"

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use super::prelude::*;
1212
use super::util::parse_single_integer;
1313
use crate::attributes::cfg::parse_cfg_entry;
1414
use crate::session_diagnostics::{
15-
AsNeededCompatibility, BundleNeedsStatic, EmptyLinkName, ImportNameTypeRaw, ImportNameTypeX86,
16-
IncompatibleWasmLink, InvalidLinkModifier, LinkFrameworkApple, LinkOrdinalOutOfRange,
17-
LinkRequiresName, MultipleModifiers, NullOnLinkSection, RawDylibNoNul, RawDylibOnlyWindows,
18-
WholeArchiveNeedsStatic,
15+
AsNeededCompatibility, BundleNeedsStatic, EmptyLinkName, ExportSymbolsNeedsStatic,
16+
ImportNameTypeRaw, ImportNameTypeX86, IncompatibleWasmLink, InvalidLinkModifier,
17+
LinkFrameworkApple, LinkOrdinalOutOfRange, LinkRequiresName, MultipleModifiers,
18+
NullOnLinkSection, RawDylibNoNul, RawDylibOnlyWindows, WholeArchiveNeedsStatic,
1919
};
2020

2121
pub(crate) struct LinkNameParser;
@@ -165,6 +165,14 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
165165
cx.emit_err(BundleNeedsStatic { span });
166166
}
167167

168+
(sym::export_symbols, Some(NativeLibKind::Static { export_symbols, .. })) => {
169+
assign_modifier(export_symbols)
170+
}
171+
172+
(sym::export_symbols, _) => {
173+
cx.emit_err(ExportSymbolsNeedsStatic { span });
174+
}
175+
168176
(sym::verbatim, _) => assign_modifier(&mut verbatim),
169177

170178
(
@@ -190,6 +198,7 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
190198
span,
191199
&[
192200
sym::bundle,
201+
sym::export_symbols,
193202
sym::verbatim,
194203
sym::whole_dash_archive,
195204
sym::as_dash_needed,
@@ -285,7 +294,9 @@ impl LinkParser {
285294
};
286295

287296
let link_kind = match link_kind {
288-
kw::Static => NativeLibKind::Static { bundle: None, whole_archive: None },
297+
kw::Static => {
298+
NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None }
299+
}
289300
sym::dylib => NativeLibKind::Dylib { as_needed: None },
290301
sym::framework => {
291302
if !sess.target.is_like_darwin {

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ pub(crate) struct RawDylibOnlyWindows {
909909

910910
#[derive(Diagnostic)]
911911
#[diag(
912-
"invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed"
912+
"invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed, export-symbols"
913913
)]
914914
pub(crate) struct InvalidLinkModifier {
915915
#[primary_span]
@@ -938,6 +938,13 @@ pub(crate) struct BundleNeedsStatic {
938938
pub span: Span,
939939
}
940940

941+
#[derive(Diagnostic)]
942+
#[diag("linking modifier `export-symbols` is only compatible with `static` linking kind")]
943+
pub(crate) struct ExportSymbolsNeedsStatic {
944+
#[primary_span]
945+
pub span: Span,
946+
}
947+
941948
#[derive(Diagnostic)]
942949
#[diag("linking modifier `whole-archive` is only compatible with `static` linking kind")]
943950
pub(crate) struct WholeArchiveNeedsStatic {

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ pub struct CraneliftCodegenBackend {
125125
}
126126

127127
impl CodegenBackend for CraneliftCodegenBackend {
128-
fn locale_resource(&self) -> &'static str {
129-
// FIXME(rust-lang/rust#100717) - cranelift codegen backend is not yet translated
130-
""
131-
}
132-
133128
fn name(&self) -> &'static str {
134129
"cranelift"
135130
}

compiler/rustc_codegen_gcc/messages.ftl

Lines changed: 0 additions & 8 deletions
This file was deleted.

compiler/rustc_codegen_gcc/src/errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ use rustc_macros::Diagnostic;
22
use rustc_span::Span;
33

44
#[derive(Diagnostic)]
5-
#[diag(codegen_gcc_unwinding_inline_asm)]
5+
#[diag("GCC backend does not support unwinding from inline asm")]
66
pub(crate) struct UnwindingInlineAsm {
77
#[primary_span]
88
pub span: Span,
99
}
1010

1111
#[derive(Diagnostic)]
12-
#[diag(codegen_gcc_copy_bitcode)]
12+
#[diag("failed to copy bitcode to object file: {$err}")]
1313
pub(crate) struct CopyBitcode {
1414
pub err: std::io::Error,
1515
}
1616

1717
#[derive(Diagnostic)]
18-
#[diag(codegen_gcc_lto_bitcode_from_rlib)]
18+
#[diag("failed to get bitcode from object file for LTO ({$gcc_err})")]
1919
pub(crate) struct LtoBitcodeFromRlib {
2020
pub gcc_err: String,
2121
}
2222

2323
#[derive(Diagnostic)]
24-
#[diag(codegen_gcc_explicit_tail_calls_unsupported)]
24+
#[diag("explicit tail calls with the 'become' keyword are not implemented in the GCC backend")]
2525
pub(crate) struct ExplicitTailCallsUnsupported;

0 commit comments

Comments
 (0)