Skip to content

Commit bf6bf50

Browse files
committed
Auto merge of #138302 - matthiaskrgr:rollup-an2up80, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #136395 (Update to rand 0.9.0) - #137279 (Make some invalid codegen attr errors structured/translatable) - #137585 (Update documentation to consistently use 'm' in atomic synchronization example) - #137926 (Add a test for `-znostart-stop-gc` usage with LLD) - #138074 (Support `File::seek` for Hermit) - #138238 (Fix dyn -> param suggestion in struct ICEs) - #138270 (chore: Fix some comments) - #138286 (triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search (…) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9fb94b3 + 49ca431 commit bf6bf50

File tree

30 files changed

+436
-178
lines changed

30 files changed

+436
-178
lines changed

Cargo.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -2881,11 +2881,11 @@ dependencies = [
28812881

28822882
[[package]]
28832883
name = "rand_xoshiro"
2884-
version = "0.6.0"
2884+
version = "0.7.0"
28852885
source = "registry+https://github.com/rust-lang/crates.io-index"
2886-
checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
2886+
checksum = "f703f4665700daf5512dcca5f43afa6af89f09db47fb56be587f80636bda2d41"
28872887
dependencies = [
2888-
"rand_core 0.6.4",
2888+
"rand_core 0.9.0",
28892889
]
28902890

28912891
[[package]]
@@ -3155,7 +3155,7 @@ name = "rustc_abi"
31553155
version = "0.0.0"
31563156
dependencies = [
31573157
"bitflags",
3158-
"rand 0.8.5",
3158+
"rand 0.9.0",
31593159
"rand_xoshiro",
31603160
"rustc_data_structures",
31613161
"rustc_hashes",
@@ -3789,7 +3789,7 @@ dependencies = [
37893789
name = "rustc_incremental"
37903790
version = "0.0.0"
37913791
dependencies = [
3792-
"rand 0.8.5",
3792+
"rand 0.9.0",
37933793
"rustc_ast",
37943794
"rustc_data_structures",
37953795
"rustc_errors",
@@ -5176,8 +5176,8 @@ version = "0.1.0"
51765176
dependencies = [
51775177
"indicatif",
51785178
"num",
5179-
"rand 0.8.5",
5180-
"rand_chacha 0.3.1",
5179+
"rand 0.9.0",
5180+
"rand_chacha 0.9.0",
51815181
"rayon",
51825182
]
51835183

compiler/rustc_abi/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
9-
rand = { version = "0.8.4", default-features = false, optional = true }
10-
rand_xoshiro = { version = "0.6.0", optional = true }
11-
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
9+
rand = { version = "0.9.0", default-features = false, optional = true }
10+
rand_xoshiro = { version = "0.7.0", optional = true }
11+
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
1212
rustc_hashes = { path = "../rustc_hashes" }
1313
rustc_index = { path = "../rustc_index", default-features = false }
1414
rustc_macros = { path = "../rustc_macros", optional = true }
15-
rustc_serialize = { path = "../rustc_serialize", optional = true }
15+
rustc_serialize = { path = "../rustc_serialize", optional = true }
1616
rustc_span = { path = "../rustc_span", optional = true }
1717
tracing = "0.1"
1818
# tidy-alphabetical-end

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
610610
Err(ErrorGuaranteed { .. }) => {
611611
// We don't run dropck on HIR, and dropck looks inside fields of
612612
// types, so there's no guarantee that it succeeds. We also
613-
// can't rely on the the `ErrorGuaranteed` from `fully_perform` here
613+
// can't rely on the `ErrorGuaranteed` from `fully_perform` here
614614
// because it comes from delay_span_bug.
615615
//
616616
// Do this inside of a probe because we don't particularly care (or want)

compiler/rustc_codegen_ssa/messages.ftl

+28
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ codegen_ssa_atomic_compare_exchange = Atomic compare-exchange intrinsic missing
1818
1919
codegen_ssa_autodiff_without_lto = using the autodiff feature requires using fat-lto
2020
21+
codegen_ssa_bare_instruction_set = `#[instruction_set]` requires an argument
22+
2123
codegen_ssa_binary_output_to_tty = option `-o` or `--emit` is used to write binary output type `{$shorthand}` to stdout, but stdout is a tty
2224
2325
codegen_ssa_cgu_not_recorded =
@@ -52,6 +54,10 @@ codegen_ssa_error_creating_remark_dir = failed to create remark directory: {$err
5254
codegen_ssa_error_writing_def_file =
5355
Error writing .DEF file: {$error}
5456
57+
codegen_ssa_expected_name_value_pair = expected name value pair
58+
59+
codegen_ssa_expected_one_argument = expected one argument
60+
5561
codegen_ssa_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`
5662
5763
codegen_ssa_extern_funcs_not_found = some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
@@ -88,9 +94,17 @@ codegen_ssa_incorrect_cgu_reuse_type =
8894
8995
codegen_ssa_insufficient_vs_code_product = VS Code is a different product, and is not sufficient.
9096
97+
codegen_ssa_invalid_argument = invalid argument
98+
.help = valid inline arguments are `always` and `never`
99+
100+
codegen_ssa_invalid_instruction_set = invalid instruction set specified
101+
91102
codegen_ssa_invalid_link_ordinal_nargs = incorrect number of arguments to `#[link_ordinal]`
92103
.note = the attribute requires exactly one argument
93104
105+
codegen_ssa_invalid_literal_value = invalid literal value
106+
.label = value must be an integer between `0` and `255`
107+
94108
codegen_ssa_invalid_monomorphization_basic_float_type = invalid monomorphization of `{$name}` intrinsic: expected basic float type, found `{$ty}`
95109
96110
codegen_ssa_invalid_monomorphization_basic_integer_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`
@@ -217,6 +231,8 @@ codegen_ssa_msvc_missing_linker = the msvc targets depend on the msvc linker but
217231
218232
codegen_ssa_multiple_external_func_decl = multiple declarations of external function `{$function}` from library `{$library_name}` have different calling conventions
219233
234+
codegen_ssa_multiple_instruction_set = cannot specify more than one instruction set
235+
220236
codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple times
221237
.help = did you use `#[no_mangle]` on `fn main`? Use `#![no_main]` to suppress the usual Rust-generated entry point
222238
@@ -229,13 +245,20 @@ codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}
229245
230246
codegen_ssa_no_saved_object_file = cached cgu {$cgu_name} should have an object file, but doesn't
231247
248+
codegen_ssa_null_on_export = `export_name` may not contain null characters
249+
250+
codegen_ssa_out_of_range_integer = integer value out of range
251+
.label = value must be between `0` and `255`
252+
232253
codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status}
233254
.note = {$output}
234255
235256
codegen_ssa_read_file = failed to read file: {$message}
236257
237258
codegen_ssa_repair_vs_build_tools = the Visual Studio build tools may need to be repaired using the Visual Studio installer
238259
260+
codegen_ssa_requires_rust_abi = `#[track_caller]` requires Rust ABI
261+
239262
codegen_ssa_rlib_archive_build_failure = failed to build archive from rlib at `{$path}`: {$error}
240263
241264
codegen_ssa_rlib_incompatible_dependency_formats = `{$ty1}` and `{$ty2}` do not have equivalent dependency formats (`{$list1}` vs `{$list2}`)
@@ -356,6 +379,9 @@ codegen_ssa_unable_to_run_dsymutil = unable to run `dsymutil`: {$error}
356379
357380
codegen_ssa_unable_to_write_debugger_visualizer = Unable to write debugger visualizer file `{$path}`: {$error}
358381
382+
codegen_ssa_unexpected_parameter_name = unexpected parameter name
383+
.label = expected `{$prefix_nops}` or `{$entry_nops}`
384+
359385
codegen_ssa_unknown_archive_kind =
360386
Don't know how to build archive of type: {$kind}
361387
@@ -367,6 +393,8 @@ codegen_ssa_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
367393
368394
codegen_ssa_unsupported_arch = unsupported arch `{$arch}` for os `{$os}`
369395
396+
codegen_ssa_unsupported_instruction_set = target does not support `#[instruction_set]`
397+
370398
codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target
371399
372400
codegen_ssa_use_cargo_directive = use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+28-84
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use rustc_ast::{MetaItem, MetaItemInner, attr};
88
use rustc_attr_parsing::ReprAttr::ReprAlign;
99
use rustc_attr_parsing::{AttributeKind, InlineAttr, InstructionSetAttr, OptimizeAttr};
1010
use rustc_data_structures::fx::FxHashMap;
11-
use rustc_errors::codes::*;
12-
use rustc_errors::{DiagMessage, SubdiagMessage, struct_span_code_err};
1311
use rustc_hir::def::DefKind;
1412
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
1513
use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS;
@@ -236,13 +234,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
236234
&& let Some(fn_sig) = fn_sig()
237235
&& fn_sig.skip_binder().abi() != ExternAbi::Rust
238236
{
239-
struct_span_code_err!(
240-
tcx.dcx(),
241-
attr.span(),
242-
E0737,
243-
"`#[track_caller]` requires Rust ABI"
244-
)
245-
.emit();
237+
tcx.dcx().emit_err(errors::RequiresRustAbi { span: attr.span() });
246238
}
247239
if is_closure
248240
&& !tcx.features().closure_track_caller()
@@ -263,13 +255,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
263255
if s.as_str().contains('\0') {
264256
// `#[export_name = ...]` will be converted to a null-terminated string,
265257
// so it may not contain any null characters.
266-
struct_span_code_err!(
267-
tcx.dcx(),
268-
attr.span(),
269-
E0648,
270-
"`export_name` may not contain null characters"
271-
)
272-
.emit();
258+
tcx.dcx().emit_err(errors::NullOnExport { span: attr.span() });
273259
}
274260
codegen_fn_attrs.export_name = Some(s);
275261
mixed_export_name_no_mangle_lint_state.track_export_name(attr.span());
@@ -394,47 +380,28 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
394380
[sym::arm, sym::a32 | sym::t32]
395381
if !tcx.sess.target.has_thumb_interworking =>
396382
{
397-
struct_span_code_err!(
398-
tcx.dcx(),
399-
attr.span(),
400-
E0779,
401-
"target does not support `#[instruction_set]`"
402-
)
403-
.emit();
383+
tcx.dcx().emit_err(errors::UnsuportedInstructionSet {
384+
span: attr.span(),
385+
});
404386
None
405387
}
406388
[sym::arm, sym::a32] => Some(InstructionSetAttr::ArmA32),
407389
[sym::arm, sym::t32] => Some(InstructionSetAttr::ArmT32),
408390
_ => {
409-
struct_span_code_err!(
410-
tcx.dcx(),
411-
attr.span(),
412-
E0779,
413-
"invalid instruction set specified",
414-
)
415-
.emit();
391+
tcx.dcx().emit_err(errors::InvalidInstructionSet {
392+
span: attr.span(),
393+
});
416394
None
417395
}
418396
}
419397
}
420398
[] => {
421-
struct_span_code_err!(
422-
tcx.dcx(),
423-
attr.span(),
424-
E0778,
425-
"`#[instruction_set]` requires an argument"
426-
)
427-
.emit();
399+
tcx.dcx().emit_err(errors::BareInstructionSet { span: attr.span() });
428400
None
429401
}
430402
_ => {
431-
struct_span_code_err!(
432-
tcx.dcx(),
433-
attr.span(),
434-
E0779,
435-
"cannot specify more than one instruction set"
436-
)
437-
.emit();
403+
tcx.dcx()
404+
.emit_err(errors::MultipleInstructionSet { span: attr.span() });
438405
None
439406
}
440407
})
@@ -445,58 +412,38 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
445412
let mut entry = None;
446413
for item in l {
447414
let Some(meta_item) = item.meta_item() else {
448-
tcx.dcx().span_err(item.span(), "expected name value pair");
415+
tcx.dcx().emit_err(errors::ExpectedNameValuePair { span: item.span() });
449416
continue;
450417
};
451418

452419
let Some(name_value_lit) = meta_item.name_value_literal() else {
453-
tcx.dcx().span_err(item.span(), "expected name value pair");
420+
tcx.dcx().emit_err(errors::ExpectedNameValuePair { span: item.span() });
454421
continue;
455422
};
456423

457-
fn emit_error_with_label(
458-
tcx: TyCtxt<'_>,
459-
span: Span,
460-
error: impl Into<DiagMessage>,
461-
label: impl Into<SubdiagMessage>,
462-
) {
463-
let mut err: rustc_errors::Diag<'_, _> =
464-
tcx.dcx().struct_span_err(span, error);
465-
err.span_label(span, label);
466-
err.emit();
467-
}
468-
469424
let attrib_to_write = match meta_item.name_or_empty() {
470425
sym::prefix_nops => &mut prefix,
471426
sym::entry_nops => &mut entry,
472427
_ => {
473-
emit_error_with_label(
474-
tcx,
475-
item.span(),
476-
"unexpected parameter name",
477-
format!("expected {} or {}", sym::prefix_nops, sym::entry_nops),
478-
);
428+
tcx.dcx().emit_err(errors::UnexpectedParameterName {
429+
span: item.span(),
430+
prefix_nops: sym::prefix_nops,
431+
entry_nops: sym::entry_nops,
432+
});
479433
continue;
480434
}
481435
};
482436

483437
let rustc_ast::LitKind::Int(val, _) = name_value_lit.kind else {
484-
emit_error_with_label(
485-
tcx,
486-
name_value_lit.span,
487-
"invalid literal value",
488-
"value must be an integer between `0` and `255`",
489-
);
438+
tcx.dcx().emit_err(errors::InvalidLiteralValue {
439+
span: name_value_lit.span,
440+
});
490441
continue;
491442
};
492443

493444
let Ok(val) = val.get().try_into() else {
494-
emit_error_with_label(
495-
tcx,
496-
name_value_lit.span,
497-
"integer value out of range",
498-
"value must be between `0` and `255`",
499-
);
445+
tcx.dcx()
446+
.emit_err(errors::OutOfRangeInteger { span: name_value_lit.span });
500447
continue;
501448
};
502449

@@ -533,7 +480,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
533480
inline_span = Some(attr.span());
534481

535482
let [item] = &items[..] else {
536-
struct_span_code_err!(tcx.dcx(), attr.span(), E0534, "expected one argument").emit();
483+
tcx.dcx().emit_err(errors::ExpectedOneArgument { span: attr.span() });
537484
return InlineAttr::None;
538485
};
539486

@@ -542,9 +489,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
542489
} else if item.has_name(sym::never) {
543490
InlineAttr::Never
544491
} else {
545-
struct_span_code_err!(tcx.dcx(), items[0].span(), E0535, "invalid argument")
546-
.with_help("valid inline arguments are `always` and `never`")
547-
.emit();
492+
tcx.dcx().emit_err(errors::InvalidArgument { span: items[0].span() });
548493

549494
InlineAttr::None
550495
}
@@ -575,9 +520,8 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
575520
if !attr.has_name(sym::optimize) {
576521
return ia;
577522
}
578-
let err = |sp, s| struct_span_code_err!(tcx.dcx(), sp, E0722, "{}", s).emit();
579523
if attr.is_word() {
580-
err(attr.span(), "expected one argument");
524+
tcx.dcx().emit_err(errors::ExpectedOneArgumentOptimize { span: attr.span() });
581525
return ia;
582526
}
583527
let Some(ref items) = attr.meta_item_list() else {
@@ -586,7 +530,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
586530

587531
inline_span = Some(attr.span());
588532
let [item] = &items[..] else {
589-
err(attr.span(), "expected one argument");
533+
tcx.dcx().emit_err(errors::ExpectedOneArgumentOptimize { span: attr.span() });
590534
return OptimizeAttr::Default;
591535
};
592536
if item.has_name(sym::size) {
@@ -596,7 +540,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
596540
} else if item.has_name(sym::none) {
597541
OptimizeAttr::DoNotOptimize
598542
} else {
599-
err(item.span(), "invalid argument");
543+
tcx.dcx().emit_err(errors::InvalidArgumentOptimize { span: item.span() });
600544
OptimizeAttr::Default
601545
}
602546
});

0 commit comments

Comments
 (0)