Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #138302

Merged
merged 20 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3835dc2
fix doc in library/core/src/sync/atomic.rs
xizheyin Feb 25, 2025
f0dec71
Make some invalid codegen attr errors structured/translatable
estebank Feb 19, 2025
7bf4e99
Add test for garbage collection of encapsulation symbols
Kobzol Mar 3, 2025
bca0ab8
Rework maybe_suggest_add_generic_impl_trait
compiler-errors Mar 8, 2025
ceb0401
Fix suggestion when there are generics, inline some things
compiler-errors Mar 8, 2025
3583554
chore: Fix some comments
StevenMia Mar 9, 2025
eecf17e
triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search (…
aDotInTheVoid Mar 9, 2025
32d0c4e
Update hermit-abi to 0.5.0
thaliaarchi Mar 5, 2025
1abaacd
Support File::seek for Hermit
thaliaarchi Feb 19, 2025
1c7aaf9
Update rand to 0.9.0
ChrisDenton Feb 1, 2025
9b71e86
Allow wit-bindgen-rt as compiler dependency
ChrisDenton Feb 1, 2025
aea9ddd
Support locking versions in permitted rustc deps
ChrisDenton Mar 2, 2025
7c957ce
Rollup merge of #136395 - ChrisDenton:rand-0-9, r=Mark-Simulacrum
matthiaskrgr Mar 10, 2025
c8194f1
Rollup merge of #137279 - estebank:codegen-structured-errors, r=nneth…
matthiaskrgr Mar 10, 2025
2270979
Rollup merge of #137585 - xizheyin:issue-135801, r=workingjubilee
matthiaskrgr Mar 10, 2025
cbde8b9
Rollup merge of #137926 - Kobzol:lld-no-start-stop-test, r=lqd
matthiaskrgr Mar 10, 2025
2f1908d
Rollup merge of #138074 - thaliaarchi:hermit-seek, r=ChrisDenton
matthiaskrgr Mar 10, 2025
1ae083d
Rollup merge of #138238 - compiler-errors:dyn-suggestion-in-struct, r…
matthiaskrgr Mar 10, 2025
86065ac
Rollup merge of #138270 - StevenMia:master, r=compiler-errors
matthiaskrgr Mar 10, 2025
49ca431
Rollup merge of #138286 - aDotInTheVoid:aDotInTheVoid-patch-3, r=comp…
matthiaskrgr Mar 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2881,11 +2881,11 @@ dependencies = [

[[package]]
name = "rand_xoshiro"
version = "0.6.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
checksum = "f703f4665700daf5512dcca5f43afa6af89f09db47fb56be587f80636bda2d41"
dependencies = [
"rand_core 0.6.4",
"rand_core 0.9.0",
]

[[package]]
Expand Down Expand Up @@ -3155,7 +3155,7 @@ name = "rustc_abi"
version = "0.0.0"
dependencies = [
"bitflags",
"rand 0.8.5",
"rand 0.9.0",
"rand_xoshiro",
"rustc_data_structures",
"rustc_hashes",
Expand Down Expand Up @@ -3789,7 +3789,7 @@ dependencies = [
name = "rustc_incremental"
version = "0.0.0"
dependencies = [
"rand 0.8.5",
"rand 0.9.0",
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
Expand Down Expand Up @@ -5176,8 +5176,8 @@ version = "0.1.0"
dependencies = [
"indicatif",
"num",
"rand 0.8.5",
"rand_chacha 0.3.1",
"rand 0.9.0",
"rand_chacha 0.9.0",
"rayon",
]

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ edition = "2024"
[dependencies]
# tidy-alphabetical-start
bitflags = "2.4.1"
rand = { version = "0.8.4", default-features = false, optional = true }
rand_xoshiro = { version = "0.6.0", optional = true }
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
rand = { version = "0.9.0", default-features = false, optional = true }
rand_xoshiro = { version = "0.7.0", optional = true }
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
rustc_hashes = { path = "../rustc_hashes" }
rustc_index = { path = "../rustc_index", default-features = false }
rustc_macros = { path = "../rustc_macros", optional = true }
rustc_serialize = { path = "../rustc_serialize", optional = true }
rustc_serialize = { path = "../rustc_serialize", optional = true }
rustc_span = { path = "../rustc_span", optional = true }
tracing = "0.1"
# tidy-alphabetical-end
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/liveness/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
Err(ErrorGuaranteed { .. }) => {
// We don't run dropck on HIR, and dropck looks inside fields of
// types, so there's no guarantee that it succeeds. We also
// can't rely on the the `ErrorGuaranteed` from `fully_perform` here
// can't rely on the `ErrorGuaranteed` from `fully_perform` here
// because it comes from delay_span_bug.
//
// Do this inside of a probe because we don't particularly care (or want)
Expand Down
28 changes: 28 additions & 0 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ codegen_ssa_atomic_compare_exchange = Atomic compare-exchange intrinsic missing

codegen_ssa_autodiff_without_lto = using the autodiff feature requires using fat-lto

codegen_ssa_bare_instruction_set = `#[instruction_set]` requires an argument

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

codegen_ssa_cgu_not_recorded =
Expand Down Expand Up @@ -52,6 +54,10 @@ codegen_ssa_error_creating_remark_dir = failed to create remark directory: {$err
codegen_ssa_error_writing_def_file =
Error writing .DEF file: {$error}

codegen_ssa_expected_name_value_pair = expected name value pair

codegen_ssa_expected_one_argument = expected one argument

codegen_ssa_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`

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
Expand Down Expand Up @@ -88,9 +94,17 @@ codegen_ssa_incorrect_cgu_reuse_type =

codegen_ssa_insufficient_vs_code_product = VS Code is a different product, and is not sufficient.

codegen_ssa_invalid_argument = invalid argument
.help = valid inline arguments are `always` and `never`

codegen_ssa_invalid_instruction_set = invalid instruction set specified

codegen_ssa_invalid_link_ordinal_nargs = incorrect number of arguments to `#[link_ordinal]`
.note = the attribute requires exactly one argument

codegen_ssa_invalid_literal_value = invalid literal value
.label = value must be an integer between `0` and `255`

codegen_ssa_invalid_monomorphization_basic_float_type = invalid monomorphization of `{$name}` intrinsic: expected basic float type, found `{$ty}`

codegen_ssa_invalid_monomorphization_basic_integer_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`
Expand Down Expand Up @@ -217,6 +231,8 @@ codegen_ssa_msvc_missing_linker = the msvc targets depend on the msvc linker but

codegen_ssa_multiple_external_func_decl = multiple declarations of external function `{$function}` from library `{$library_name}` have different calling conventions

codegen_ssa_multiple_instruction_set = cannot specify more than one instruction set

codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple times
.help = did you use `#[no_mangle]` on `fn main`? Use `#![no_main]` to suppress the usual Rust-generated entry point

Expand All @@ -229,13 +245,20 @@ codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}

codegen_ssa_no_saved_object_file = cached cgu {$cgu_name} should have an object file, but doesn't

codegen_ssa_null_on_export = `export_name` may not contain null characters

codegen_ssa_out_of_range_integer = integer value out of range
.label = value must be between `0` and `255`

codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status}
.note = {$output}

codegen_ssa_read_file = failed to read file: {$message}

codegen_ssa_repair_vs_build_tools = the Visual Studio build tools may need to be repaired using the Visual Studio installer

codegen_ssa_requires_rust_abi = `#[track_caller]` requires Rust ABI

codegen_ssa_rlib_archive_build_failure = failed to build archive from rlib at `{$path}`: {$error}

codegen_ssa_rlib_incompatible_dependency_formats = `{$ty1}` and `{$ty2}` do not have equivalent dependency formats (`{$list1}` vs `{$list2}`)
Expand Down Expand Up @@ -356,6 +379,9 @@ codegen_ssa_unable_to_run_dsymutil = unable to run `dsymutil`: {$error}

codegen_ssa_unable_to_write_debugger_visualizer = Unable to write debugger visualizer file `{$path}`: {$error}

codegen_ssa_unexpected_parameter_name = unexpected parameter name
.label = expected `{$prefix_nops}` or `{$entry_nops}`

codegen_ssa_unknown_archive_kind =
Don't know how to build archive of type: {$kind}

Expand All @@ -367,6 +393,8 @@ codegen_ssa_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified

codegen_ssa_unsupported_arch = unsupported arch `{$arch}` for os `{$os}`

codegen_ssa_unsupported_instruction_set = target does not support `#[instruction_set]`

codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target

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)
Expand Down
112 changes: 28 additions & 84 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use rustc_ast::{MetaItem, MetaItemInner, attr};
use rustc_attr_parsing::ReprAttr::ReprAlign;
use rustc_attr_parsing::{AttributeKind, InlineAttr, InstructionSetAttr, OptimizeAttr};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::codes::*;
use rustc_errors::{DiagMessage, SubdiagMessage, struct_span_code_err};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS;
Expand Down Expand Up @@ -236,13 +234,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
&& let Some(fn_sig) = fn_sig()
&& fn_sig.skip_binder().abi() != ExternAbi::Rust
{
struct_span_code_err!(
tcx.dcx(),
attr.span(),
E0737,
"`#[track_caller]` requires Rust ABI"
)
.emit();
tcx.dcx().emit_err(errors::RequiresRustAbi { span: attr.span() });
}
if is_closure
&& !tcx.features().closure_track_caller()
Expand All @@ -263,13 +255,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
if s.as_str().contains('\0') {
// `#[export_name = ...]` will be converted to a null-terminated string,
// so it may not contain any null characters.
struct_span_code_err!(
tcx.dcx(),
attr.span(),
E0648,
"`export_name` may not contain null characters"
)
.emit();
tcx.dcx().emit_err(errors::NullOnExport { span: attr.span() });
}
codegen_fn_attrs.export_name = Some(s);
mixed_export_name_no_mangle_lint_state.track_export_name(attr.span());
Expand Down Expand Up @@ -394,47 +380,28 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
[sym::arm, sym::a32 | sym::t32]
if !tcx.sess.target.has_thumb_interworking =>
{
struct_span_code_err!(
tcx.dcx(),
attr.span(),
E0779,
"target does not support `#[instruction_set]`"
)
.emit();
tcx.dcx().emit_err(errors::UnsuportedInstructionSet {
span: attr.span(),
});
None
}
[sym::arm, sym::a32] => Some(InstructionSetAttr::ArmA32),
[sym::arm, sym::t32] => Some(InstructionSetAttr::ArmT32),
_ => {
struct_span_code_err!(
tcx.dcx(),
attr.span(),
E0779,
"invalid instruction set specified",
)
.emit();
tcx.dcx().emit_err(errors::InvalidInstructionSet {
span: attr.span(),
});
None
}
}
}
[] => {
struct_span_code_err!(
tcx.dcx(),
attr.span(),
E0778,
"`#[instruction_set]` requires an argument"
)
.emit();
tcx.dcx().emit_err(errors::BareInstructionSet { span: attr.span() });
None
}
_ => {
struct_span_code_err!(
tcx.dcx(),
attr.span(),
E0779,
"cannot specify more than one instruction set"
)
.emit();
tcx.dcx()
.emit_err(errors::MultipleInstructionSet { span: attr.span() });
None
}
})
Expand All @@ -445,58 +412,38 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
let mut entry = None;
for item in l {
let Some(meta_item) = item.meta_item() else {
tcx.dcx().span_err(item.span(), "expected name value pair");
tcx.dcx().emit_err(errors::ExpectedNameValuePair { span: item.span() });
continue;
};

let Some(name_value_lit) = meta_item.name_value_literal() else {
tcx.dcx().span_err(item.span(), "expected name value pair");
tcx.dcx().emit_err(errors::ExpectedNameValuePair { span: item.span() });
continue;
};

fn emit_error_with_label(
tcx: TyCtxt<'_>,
span: Span,
error: impl Into<DiagMessage>,
label: impl Into<SubdiagMessage>,
) {
let mut err: rustc_errors::Diag<'_, _> =
tcx.dcx().struct_span_err(span, error);
err.span_label(span, label);
err.emit();
}

let attrib_to_write = match meta_item.name_or_empty() {
sym::prefix_nops => &mut prefix,
sym::entry_nops => &mut entry,
_ => {
emit_error_with_label(
tcx,
item.span(),
"unexpected parameter name",
format!("expected {} or {}", sym::prefix_nops, sym::entry_nops),
);
tcx.dcx().emit_err(errors::UnexpectedParameterName {
span: item.span(),
prefix_nops: sym::prefix_nops,
entry_nops: sym::entry_nops,
});
continue;
}
};

let rustc_ast::LitKind::Int(val, _) = name_value_lit.kind else {
emit_error_with_label(
tcx,
name_value_lit.span,
"invalid literal value",
"value must be an integer between `0` and `255`",
);
tcx.dcx().emit_err(errors::InvalidLiteralValue {
span: name_value_lit.span,
});
continue;
};

let Ok(val) = val.get().try_into() else {
emit_error_with_label(
tcx,
name_value_lit.span,
"integer value out of range",
"value must be between `0` and `255`",
);
tcx.dcx()
.emit_err(errors::OutOfRangeInteger { span: name_value_lit.span });
continue;
};

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

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

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

InlineAttr::None
}
Expand Down Expand Up @@ -575,9 +520,8 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
if !attr.has_name(sym::optimize) {
return ia;
}
let err = |sp, s| struct_span_code_err!(tcx.dcx(), sp, E0722, "{}", s).emit();
if attr.is_word() {
err(attr.span(), "expected one argument");
tcx.dcx().emit_err(errors::ExpectedOneArgumentOptimize { span: attr.span() });
return ia;
}
let Some(ref items) = attr.meta_item_list() else {
Expand All @@ -586,7 +530,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {

inline_span = Some(attr.span());
let [item] = &items[..] else {
err(attr.span(), "expected one argument");
tcx.dcx().emit_err(errors::ExpectedOneArgumentOptimize { span: attr.span() });
return OptimizeAttr::Default;
};
if item.has_name(sym::size) {
Expand All @@ -596,7 +540,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
} else if item.has_name(sym::none) {
OptimizeAttr::DoNotOptimize
} else {
err(item.span(), "invalid argument");
tcx.dcx().emit_err(errors::InvalidArgumentOptimize { span: item.span() });
OptimizeAttr::Default
}
});
Expand Down
Loading
Loading