Merge ref '9f4b56a5ae' from rust-lang/rust

Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 9f4b56a5ae
Filtered ref: 4370958f4e8d5ec5d34e22d989f45c7784038f42
Upstream diff: 1d05e3c131...9f4b56a5ae

This merge was created using https://github.com/rust-lang/josh-sync.
This commit is contained in:
Ralf Jung 2026-02-05 08:52:51 +01:00
commit edc1ad4675
180 changed files with 4774 additions and 4603 deletions

View file

@ -165,9 +165,6 @@ jobs:
- name: install sccache
run: src/ci/scripts/install-sccache.sh
- name: select Xcode
run: src/ci/scripts/select-xcode.sh
- name: install clang
run: src/ci/scripts/install-clang.sh

View file

@ -3635,7 +3635,6 @@ dependencies = [
"rustc_codegen_ssa",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_fs_util",
"rustc_hashes",
"rustc_hir",
@ -3789,7 +3788,6 @@ dependencies = [
"rustc_hir_analysis",
"rustc_hir_pretty",
"rustc_hir_typeck",
"rustc_incremental",
"rustc_index",
"rustc_interface",
"rustc_lexer",
@ -3799,20 +3797,16 @@ dependencies = [
"rustc_metadata",
"rustc_middle",
"rustc_mir_build",
"rustc_mir_dataflow",
"rustc_mir_transform",
"rustc_monomorphize",
"rustc_parse",
"rustc_passes",
"rustc_pattern_analysis",
"rustc_privacy",
"rustc_public",
"rustc_resolve",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"rustc_ty_utils",
"serde_json",
"shlex",
"tracing",
@ -4048,7 +4042,6 @@ dependencies = [
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_fs_util",
"rustc_graphviz",
"rustc_hashes",
@ -4117,7 +4110,6 @@ dependencies = [
"rustc_errors",
"rustc_expand",
"rustc_feature",
"rustc_fluent_macro",
"rustc_fs_util",
"rustc_hir",
"rustc_hir_analysis",
@ -4333,7 +4325,6 @@ dependencies = [
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_graphviz",
"rustc_hir",
"rustc_index",
@ -4378,7 +4369,6 @@ dependencies = [
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_hir",
"rustc_index",
"rustc_macros",
@ -4491,7 +4481,6 @@ dependencies = [
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_hir",
"rustc_macros",
"rustc_middle",
@ -4646,7 +4635,6 @@ dependencies = [
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
"rustc_fluent_macro",
"rustc_fs_util",
"rustc_hashes",
"rustc_hir",
@ -4802,7 +4790,6 @@ dependencies = [
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_hashes",
"rustc_hir",
"rustc_index",

View file

@ -70,6 +70,42 @@ fn check_attr_crate_level<S: Stage>(cx: &mut AcceptContext<'_, '_, S>, span: Spa
true
}
// FIXME: To be removed once merged and replace with `cx.expected_name_value(span, _name)`.
fn expected_name_value<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
span: Span,
_name: Option<Symbol>,
) {
cx.emit_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::ExpectedNameValue,
span,
);
}
// FIXME: remove this method once merged and use `cx.expected_no_args(span)` instead.
fn expected_no_args<S: Stage>(cx: &mut AcceptContext<'_, '_, S>, span: Span) {
cx.emit_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::ExpectedNoArgs,
span,
);
}
// FIXME: remove this method once merged and use `cx.expected_no_args(span)` instead.
// cx.expected_string_literal(span, _actual_literal);
fn expected_string_literal<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
span: Span,
_actual_literal: Option<&MetaItemLit>,
) {
cx.emit_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::MalformedDoc,
span,
);
}
fn parse_keyword_and_attribute<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
path: &OwnedPathParser,
@ -78,12 +114,12 @@ fn parse_keyword_and_attribute<S: Stage>(
attr_name: Symbol,
) {
let Some(nv) = args.name_value() else {
cx.expected_name_value(args.span().unwrap_or(path.span()), path.word_sym());
expected_name_value(cx, args.span().unwrap_or(path.span()), path.word_sym());
return;
};
let Some(value) = nv.value_as_str() else {
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
expected_string_literal(cx, nv.value_span, Some(nv.value_as_lit()));
return;
};
@ -127,12 +163,21 @@ impl DocParser {
match path.word_sym() {
Some(sym::no_crate_inject) => {
if let Err(span) = args.no_args() {
cx.expected_no_args(span);
expected_no_args(cx, span);
return;
}
if self.attribute.no_crate_inject.is_some() {
cx.duplicate_key(path.span(), sym::no_crate_inject);
if let Some(used_span) = self.attribute.no_crate_inject {
let unused_span = path.span();
cx.emit_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::UnusedDuplicate {
this: unused_span,
other: used_span,
warning: true,
},
unused_span,
);
return;
}
@ -144,7 +189,14 @@ impl DocParser {
}
Some(sym::attr) => {
let Some(list) = args.list() else {
cx.expected_list(cx.attr_span, args);
// FIXME: remove this method once merged and uncomment the line below instead.
// cx.expected_list(cx.attr_span, args);
let span = cx.attr_span;
cx.emit_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::MalformedDoc,
span,
);
return;
};
@ -246,7 +298,7 @@ impl DocParser {
inline: DocInline,
) {
if let Err(span) = args.no_args() {
cx.expected_no_args(span);
expected_no_args(cx, span);
return;
}
@ -328,7 +380,14 @@ impl DocParser {
match sub_item.args() {
a @ (ArgParser::NoArgs | ArgParser::NameValue(_)) => {
let Some(name) = sub_item.path().word_sym() else {
cx.expected_identifier(sub_item.path().span());
// FIXME: remove this method once merged and uncomment the line
// below instead.
// cx.expected_identifier(sub_item.path().span());
cx.emit_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::MalformedDoc,
sub_item.path().span(),
);
continue;
};
if let Ok(CfgEntry::NameValue { name, value, .. }) =
@ -391,7 +450,7 @@ impl DocParser {
macro_rules! no_args {
($ident: ident) => {{
if let Err(span) = args.no_args() {
cx.expected_no_args(span);
expected_no_args(cx, span);
return;
}
@ -410,7 +469,7 @@ impl DocParser {
macro_rules! no_args_and_not_crate_level {
($ident: ident) => {{
if let Err(span) = args.no_args() {
cx.expected_no_args(span);
expected_no_args(cx, span);
return;
}
let span = path.span();
@ -423,7 +482,7 @@ impl DocParser {
macro_rules! no_args_and_crate_level {
($ident: ident) => {{
if let Err(span) = args.no_args() {
cx.expected_no_args(span);
expected_no_args(cx, span);
return;
}
let span = path.span();
@ -436,12 +495,12 @@ impl DocParser {
macro_rules! string_arg_and_crate_level {
($ident: ident) => {{
let Some(nv) = args.name_value() else {
cx.expected_name_value(args.span().unwrap_or(path.span()), path.word_sym());
expected_name_value(cx, args.span().unwrap_or(path.span()), path.word_sym());
return;
};
let Some(s) = nv.value_as_str() else {
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
expected_string_literal(cx, nv.value_span, Some(nv.value_as_lit()));
return;
};
@ -512,7 +571,14 @@ impl DocParser {
self.parse_single_test_doc_attr_item(cx, mip);
}
MetaItemOrLitParser::Lit(lit) => {
cx.unexpected_literal(lit.span);
// FIXME: remove this method once merged and uncomment the line
// below instead.
// cx.unexpected_literal(lit.span);
cx.emit_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::MalformedDoc,
lit.span,
);
}
}
}
@ -582,7 +648,7 @@ impl DocParser {
let suggestions = cx.suggestions();
let span = cx.attr_span;
cx.emit_lint(
rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT,
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::IllFormedAttributeInput { suggestions, docs: None },
span,
);
@ -595,14 +661,14 @@ impl DocParser {
self.parse_single_doc_attr_item(cx, mip);
}
MetaItemOrLitParser::Lit(lit) => {
cx.expected_name_value(lit.span, None);
expected_name_value(cx, lit.span, None);
}
}
}
}
ArgParser::NameValue(nv) => {
if nv.value_as_str().is_none() {
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
expected_string_literal(cx, nv.value_span, Some(nv.value_as_lit()));
} else {
unreachable!(
"Should have been handled at the same time as sugar-syntaxed doc comments"

View file

@ -12,10 +12,10 @@ use super::prelude::*;
use super::util::parse_single_integer;
use crate::attributes::cfg::parse_cfg_entry;
use crate::session_diagnostics::{
AsNeededCompatibility, BundleNeedsStatic, EmptyLinkName, ImportNameTypeRaw, ImportNameTypeX86,
IncompatibleWasmLink, InvalidLinkModifier, LinkFrameworkApple, LinkOrdinalOutOfRange,
LinkRequiresName, MultipleModifiers, NullOnLinkSection, RawDylibNoNul, RawDylibOnlyWindows,
WholeArchiveNeedsStatic,
AsNeededCompatibility, BundleNeedsStatic, EmptyLinkName, ExportSymbolsNeedsStatic,
ImportNameTypeRaw, ImportNameTypeX86, IncompatibleWasmLink, InvalidLinkModifier,
LinkFrameworkApple, LinkOrdinalOutOfRange, LinkRequiresName, MultipleModifiers,
NullOnLinkSection, RawDylibNoNul, RawDylibOnlyWindows, WholeArchiveNeedsStatic,
};
pub(crate) struct LinkNameParser;
@ -165,6 +165,14 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
cx.emit_err(BundleNeedsStatic { span });
}
(sym::export_symbols, Some(NativeLibKind::Static { export_symbols, .. })) => {
assign_modifier(export_symbols)
}
(sym::export_symbols, _) => {
cx.emit_err(ExportSymbolsNeedsStatic { span });
}
(sym::verbatim, _) => assign_modifier(&mut verbatim),
(
@ -190,6 +198,7 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
span,
&[
sym::bundle,
sym::export_symbols,
sym::verbatim,
sym::whole_dash_archive,
sym::as_dash_needed,
@ -285,7 +294,9 @@ impl LinkParser {
};
let link_kind = match link_kind {
kw::Static => NativeLibKind::Static { bundle: None, whole_archive: None },
kw::Static => {
NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None }
}
sym::dylib => NativeLibKind::Dylib { as_needed: None },
sym::framework => {
if !sess.target.is_like_darwin {

View file

@ -16,90 +16,42 @@ use rustc_session::lint::{Lint, LintId};
use rustc_span::{ErrorGuaranteed, Span, Symbol};
use crate::AttributeParser;
use crate::attributes::allow_unstable::{
AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser,
};
use crate::attributes::body::CoroutineParser;
use crate::attributes::cfi_encoding::CfiEncodingParser;
use crate::attributes::codegen_attrs::{
ColdParser, CoverageParser, EiiForeignItemParser, ExportNameParser, ForceTargetFeatureParser,
NakedParser, NoMangleParser, ObjcClassParser, ObjcSelectorParser, OptimizeParser,
PatchableFunctionEntryParser, RustcPassIndirectlyInNonRusticAbisParser, SanitizeParser,
TargetFeatureParser, ThreadLocalParser, TrackCallerParser, UsedParser,
};
use crate::attributes::confusables::ConfusablesParser;
use crate::attributes::crate_level::{
CrateNameParser, CrateTypeParser, MoveSizeLimitParser, NeedsPanicRuntimeParser,
NoBuiltinsParser, NoCoreParser, NoMainParser, NoStdParser, PanicRuntimeParser,
PatternComplexityLimitParser, ProfilerRuntimeParser, RecursionLimitParser,
RustcCoherenceIsCoreParser, RustcPreserveUbChecksParser, TypeLengthLimitParser,
WindowsSubsystemParser,
};
use crate::attributes::debugger::DebuggerViualizerParser;
use crate::attributes::deprecation::DeprecationParser;
use crate::attributes::do_not_recommend::DoNotRecommendParser;
use crate::attributes::doc::DocParser;
use crate::attributes::dummy::DummyParser;
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
use crate::attributes::instruction_set::InstructionSetParser;
use crate::attributes::link_attrs::{
CompilerBuiltinsParser, ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser,
LinkOrdinalParser, LinkParser, LinkSectionParser, LinkageParser, NeedsAllocatorParser,
StdInternalSymbolParser,
};
use crate::attributes::lint_helpers::{
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
RustcShouldNotBeCalledOnConstItems,
};
use crate::attributes::loop_match::{ConstContinueParser, LoopMatchParser};
use crate::attributes::macro_attrs::{
AllowInternalUnsafeParser, CollapseDebugInfoParser, MacroEscapeParser, MacroExportParser,
MacroUseParser,
};
use crate::attributes::must_not_suspend::MustNotSuspendParser;
use crate::attributes::must_use::MustUseParser;
use crate::attributes::no_implicit_prelude::NoImplicitPreludeParser;
use crate::attributes::no_link::NoLinkParser;
use crate::attributes::non_exhaustive::NonExhaustiveParser;
// Glob imports to avoid big, bitrotty import lists
use crate::attributes::allow_unstable::*;
use crate::attributes::body::*;
use crate::attributes::cfi_encoding::*;
use crate::attributes::codegen_attrs::*;
use crate::attributes::confusables::*;
use crate::attributes::crate_level::*;
use crate::attributes::debugger::*;
use crate::attributes::deprecation::*;
use crate::attributes::do_not_recommend::*;
use crate::attributes::doc::*;
use crate::attributes::dummy::*;
use crate::attributes::inline::*;
use crate::attributes::instruction_set::*;
use crate::attributes::link_attrs::*;
use crate::attributes::lint_helpers::*;
use crate::attributes::loop_match::*;
use crate::attributes::macro_attrs::*;
use crate::attributes::must_not_suspend::*;
use crate::attributes::must_use::*;
use crate::attributes::no_implicit_prelude::*;
use crate::attributes::no_link::*;
use crate::attributes::non_exhaustive::*;
use crate::attributes::path::PathParser as PathAttributeParser;
use crate::attributes::pin_v2::PinV2Parser;
use crate::attributes::proc_macro_attrs::{
ProcMacroAttributeParser, ProcMacroDeriveParser, ProcMacroParser, RustcBuiltinMacroParser,
};
use crate::attributes::prototype::CustomMirParser;
use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser};
use crate::attributes::rustc_allocator::{
RustcAllocatorParser, RustcAllocatorZeroedParser, RustcAllocatorZeroedVariantParser,
RustcDeallocatorParser, RustcReallocatorParser,
};
use crate::attributes::rustc_dump::{
RustcDumpDefParentsParser, RustcDumpItemBoundsParser, RustcDumpPredicatesParser,
RustcDumpUserArgsParser, RustcDumpVtableParser,
};
use crate::attributes::rustc_internal::{
RustcHasIncoherentInherentImplsParser, RustcHiddenTypeOfOpaquesParser, RustcLayoutParser,
RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser,
RustcLegacyConstGenericsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser,
RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser,
RustcMirParser, RustcMustImplementOneOfParser, RustcNeverReturnsNullPointerParser,
RustcNoImplicitAutorefsParser, RustcNonConstTraitMethodParser, RustcNounwindParser,
RustcObjectLifetimeDefaultParser, RustcOffloadKernelParser, RustcScalableVectorParser,
RustcSimdMonomorphizeLaneLimitParser,
};
use crate::attributes::semantics::MayDangleParser;
use crate::attributes::stability::{
BodyStabilityParser, ConstStabilityIndirectParser, ConstStabilityParser, StabilityParser,
};
use crate::attributes::test_attrs::{
IgnoreParser, RustcVarianceOfOpaquesParser, RustcVarianceParser, ShouldPanicParser,
};
use crate::attributes::traits::{
AllowIncoherentImplParser, CoinductiveParser, DenyExplicitImplParser,
DynIncompatibleTraitParser, FundamentalParser, MarkerParser, ParenSugarParser, PointeeParser,
SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser,
UnsafeSpecializationMarkerParser,
};
use crate::attributes::transparency::TransparencyParser;
use crate::attributes::pin_v2::*;
use crate::attributes::proc_macro_attrs::*;
use crate::attributes::prototype::*;
use crate::attributes::repr::*;
use crate::attributes::rustc_allocator::*;
use crate::attributes::rustc_dump::*;
use crate::attributes::rustc_internal::*;
use crate::attributes::semantics::*;
use crate::attributes::stability::*;
use crate::attributes::test_attrs::*;
use crate::attributes::traits::*;
use crate::attributes::transparency::*;
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
use crate::parser::{ArgParser, RefPathParser};
use crate::session_diagnostics::{

View file

@ -909,7 +909,7 @@ pub(crate) struct RawDylibOnlyWindows {
#[derive(Diagnostic)]
#[diag(
"invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed"
"invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed, export-symbols"
)]
pub(crate) struct InvalidLinkModifier {
#[primary_span]
@ -938,6 +938,13 @@ pub(crate) struct BundleNeedsStatic {
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("linking modifier `export-symbols` is only compatible with `static` linking kind")]
pub(crate) struct ExportSymbolsNeedsStatic {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("linking modifier `whole-archive` is only compatible with `static` linking kind")]
pub(crate) struct WholeArchiveNeedsStatic {

View file

@ -125,11 +125,6 @@ pub struct CraneliftCodegenBackend {
}
impl CodegenBackend for CraneliftCodegenBackend {
fn locale_resource(&self) -> &'static str {
// FIXME(rust-lang/rust#100717) - cranelift codegen backend is not yet translated
""
}
fn name(&self) -> &'static str {
"cranelift"
}

View file

@ -1,8 +0,0 @@
codegen_gcc_unwinding_inline_asm =
GCC backend does not support unwinding from inline asm
codegen_gcc_copy_bitcode = failed to copy bitcode to object file: {$err}
codegen_gcc_lto_bitcode_from_rlib = failed to get bitcode from object file for LTO ({$gcc_err})
codegen_gcc_explicit_tail_calls_unsupported = explicit tail calls with the 'become' keyword are not implemented in the GCC backend

View file

@ -2,24 +2,24 @@ use rustc_macros::Diagnostic;
use rustc_span::Span;
#[derive(Diagnostic)]
#[diag(codegen_gcc_unwinding_inline_asm)]
#[diag("GCC backend does not support unwinding from inline asm")]
pub(crate) struct UnwindingInlineAsm {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_gcc_copy_bitcode)]
#[diag("failed to copy bitcode to object file: {$err}")]
pub(crate) struct CopyBitcode {
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(codegen_gcc_lto_bitcode_from_rlib)]
#[diag("failed to get bitcode from object file for LTO ({$gcc_err})")]
pub(crate) struct LtoBitcodeFromRlib {
pub gcc_err: String,
}
#[derive(Diagnostic)]
#[diag(codegen_gcc_explicit_tail_calls_unsupported)]
#[diag("explicit tail calls with the 'become' keyword are not implemented in the GCC backend")]
pub(crate) struct ExplicitTailCallsUnsupported;

View file

@ -27,7 +27,6 @@ extern crate rustc_ast;
extern crate rustc_codegen_ssa;
extern crate rustc_data_structures;
extern crate rustc_errors;
extern crate rustc_fluent_macro;
extern crate rustc_fs_util;
extern crate rustc_hir;
extern crate rustc_index;
@ -105,8 +104,6 @@ use tempfile::TempDir;
use crate::back::lto::ModuleBuffer;
use crate::gcc_util::{target_cpu, to_gcc_features};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub struct PrintOnPanic<F: Fn() -> String>(pub F);
impl<F: Fn() -> String> Drop for PrintOnPanic<F> {
@ -197,10 +194,6 @@ fn load_libgccjit_if_needed(libgccjit_target_lib_file: &Path) {
}
impl CodegenBackend for GccCodegenBackend {
fn locale_resource(&self) -> &'static str {
crate::DEFAULT_LOCALE_RESOURCE
}
fn name(&self) -> &'static str {
"gcc"
}

View file

@ -23,7 +23,6 @@ rustc_ast = { path = "../rustc_ast" }
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_fs_util = { path = "../rustc_fs_util" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" }

View file

@ -1,75 +0,0 @@
codegen_llvm_autodiff_component_missing = autodiff backend not found in the sysroot: {$err}
.note = it will be distributed via rustup in the future
codegen_llvm_autodiff_component_unavailable = failed to load our autodiff backend: {$err}
codegen_llvm_autodiff_without_enable = using the autodiff feature requires -Z autodiff=Enable
codegen_llvm_autodiff_without_lto = using the autodiff feature requires setting `lto="fat"` in your Cargo.toml
codegen_llvm_copy_bitcode = failed to copy bitcode to object file: {$err}
codegen_llvm_fixed_x18_invalid_arch = the `-Zfixed-x18` flag is not supported on the `{$arch}` architecture
codegen_llvm_from_llvm_diag = {$message}
codegen_llvm_from_llvm_optimization_diag = {$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}
codegen_llvm_load_bitcode = failed to load bitcode of module "{$name}"
codegen_llvm_load_bitcode_with_llvm_err = failed to load bitcode of module "{$name}": {$llvm_err}
codegen_llvm_lto_bitcode_from_rlib = failed to get bitcode from object file for LTO ({$err})
codegen_llvm_mismatch_data_layout =
data-layout for target `{$rustc_target}`, `{$rustc_layout}`, differs from LLVM target's `{$llvm_target}` default layout, `{$llvm_layout}`
codegen_llvm_offload_bundleimages_failed = call to BundleImages failed, `host.out` was not created
codegen_llvm_offload_embed_failed = call to EmbedBufferInModule failed, `host.o` was not created
codegen_llvm_offload_no_abs_path = using the `-Z offload=Host=/absolute/path/to/host.out` flag requires an absolute path
codegen_llvm_offload_no_host_out = using the `-Z offload=Host=/absolute/path/to/host.out` flag must point to a `host.out` file
codegen_llvm_offload_nonexisting = the given path/file to `host.out` does not exist. Did you forget to run the device compilation first?
codegen_llvm_offload_without_enable = using the offload feature requires -Z offload=<Device or Host=/absolute/path/to/host.out>
codegen_llvm_offload_without_fat_lto = using the offload feature requires -C lto=fat
codegen_llvm_parse_bitcode = failed to parse bitcode for LTO module
codegen_llvm_parse_bitcode_with_llvm_err = failed to parse bitcode for LTO module: {$llvm_err}
codegen_llvm_parse_target_machine_config =
failed to parse target machine config to target machine: {$error}
codegen_llvm_prepare_autodiff = failed to prepare autodiff: src: {$src}, target: {$target}, {$error}
codegen_llvm_prepare_autodiff_with_llvm_err = failed to prepare autodiff: {$llvm_err}, src: {$src}, target: {$target}, {$error}
codegen_llvm_prepare_thin_lto_context = failed to prepare thin LTO context
codegen_llvm_prepare_thin_lto_context_with_llvm_err = failed to prepare thin LTO context: {$llvm_err}
codegen_llvm_prepare_thin_lto_module = failed to prepare thin LTO module
codegen_llvm_prepare_thin_lto_module_with_llvm_err = failed to prepare thin LTO module: {$llvm_err}
codegen_llvm_run_passes = failed to run LLVM passes
codegen_llvm_run_passes_with_llvm_err = failed to run LLVM passes: {$llvm_err}
codegen_llvm_sanitizer_kcfi_arity_requires_llvm_21_0_0 = `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later.
codegen_llvm_sanitizer_memtag_requires_mte =
`-Zsanitizer=memtag` requires `-Ctarget-feature=+mte`
codegen_llvm_serialize_module = failed to serialize module {$name}
codegen_llvm_serialize_module_with_llvm_err = failed to serialize module {$name}: {$llvm_err}
codegen_llvm_symbol_already_defined =
symbol `{$symbol_name}` is already defined
codegen_llvm_target_machine = could not create LLVM TargetMachine for triple: {$triple}
codegen_llvm_target_machine_with_llvm_err = could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}
codegen_llvm_unknown_debuginfo_compression = unknown debuginfo compression algorithm {$algorithm} - will fall back to uncompressed debuginfo
codegen_llvm_write_bytecode = failed to write bytecode to {$path}: {$err}
codegen_llvm_write_ir = failed to write LLVM IR to {$path}
codegen_llvm_write_ir_with_llvm_err = failed to write LLVM IR to {$path}: {$llvm_err}
codegen_llvm_write_output = could not write output to {$path}
codegen_llvm_write_output_with_llvm_err = could not write output to {$path}: {$llvm_err}
codegen_llvm_write_thinlto_key = error while writing ThinLTO key data: {$err}
codegen_llvm_write_thinlto_key_with_llvm_err = error while writing ThinLTO key data: {$err}: {$llvm_err}

View file

@ -2,14 +2,12 @@ use std::ffi::CString;
use std::path::Path;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, inline_fluent};
use rustc_macros::Diagnostic;
use rustc_span::Span;
use crate::fluent_generated as fluent;
#[derive(Diagnostic)]
#[diag(codegen_llvm_symbol_already_defined)]
#[diag("symbol `{$symbol_name}` is already defined")]
pub(crate) struct SymbolAlreadyDefined<'a> {
#[primary_span]
pub span: Span,
@ -17,7 +15,7 @@ pub(crate) struct SymbolAlreadyDefined<'a> {
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_sanitizer_memtag_requires_mte)]
#[diag("`-Zsanitizer=memtag` requires `-Ctarget-feature=+mte`")]
pub(crate) struct SanitizerMemtagRequiresMte;
pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>);
@ -27,89 +25,97 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for ParseTargetMachineConfig<'_> {
let diag: Diag<'_, G> = self.0.into_diag(dcx, level);
let (message, _) = diag.messages.first().expect("`LlvmError` with no message");
let message = dcx.eagerly_translate_to_string(message.clone(), diag.args.iter());
Diag::new(dcx, level, fluent::codegen_llvm_parse_target_machine_config)
.with_arg("error", message)
Diag::new(
dcx,
level,
inline_fluent!("failed to parse target machine config to target machine: {$error}"),
)
.with_arg("error", message)
}
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_autodiff_component_unavailable)]
#[diag("failed to load our autodiff backend: {$err}")]
pub(crate) struct AutoDiffComponentUnavailable {
pub err: String,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_autodiff_component_missing)]
#[note]
#[diag("autodiff backend not found in the sysroot: {$err}")]
#[note("it will be distributed via rustup in the future")]
pub(crate) struct AutoDiffComponentMissing {
pub err: String,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_autodiff_without_lto)]
#[diag("using the autodiff feature requires setting `lto=\"fat\"` in your Cargo.toml")]
pub(crate) struct AutoDiffWithoutLto;
#[derive(Diagnostic)]
#[diag(codegen_llvm_autodiff_without_enable)]
#[diag("using the autodiff feature requires -Z autodiff=Enable")]
pub(crate) struct AutoDiffWithoutEnable;
#[derive(Diagnostic)]
#[diag(codegen_llvm_offload_without_enable)]
#[diag("using the offload feature requires -Z offload=<Device or Host=/absolute/path/to/host.out>")]
pub(crate) struct OffloadWithoutEnable;
#[derive(Diagnostic)]
#[diag(codegen_llvm_offload_without_fat_lto)]
#[diag("using the offload feature requires -C lto=fat")]
pub(crate) struct OffloadWithoutFatLTO;
#[derive(Diagnostic)]
#[diag(codegen_llvm_offload_no_abs_path)]
#[diag("using the `-Z offload=Host=/absolute/path/to/host.out` flag requires an absolute path")]
pub(crate) struct OffloadWithoutAbsPath;
#[derive(Diagnostic)]
#[diag(codegen_llvm_offload_no_host_out)]
#[diag(
"using the `-Z offload=Host=/absolute/path/to/host.out` flag must point to a `host.out` file"
)]
pub(crate) struct OffloadWrongFileName;
#[derive(Diagnostic)]
#[diag(codegen_llvm_offload_nonexisting)]
#[diag(
"the given path/file to `host.out` does not exist. Did you forget to run the device compilation first?"
)]
pub(crate) struct OffloadNonexistingPath;
#[derive(Diagnostic)]
#[diag(codegen_llvm_offload_bundleimages_failed)]
#[diag("call to BundleImages failed, `host.out` was not created")]
pub(crate) struct OffloadBundleImagesFailed;
#[derive(Diagnostic)]
#[diag(codegen_llvm_offload_embed_failed)]
#[diag("call to EmbedBufferInModule failed, `host.o` was not created")]
pub(crate) struct OffloadEmbedFailed;
#[derive(Diagnostic)]
#[diag(codegen_llvm_lto_bitcode_from_rlib)]
#[diag("failed to get bitcode from object file for LTO ({$err})")]
pub(crate) struct LtoBitcodeFromRlib {
pub err: String,
}
#[derive(Diagnostic)]
pub enum LlvmError<'a> {
#[diag(codegen_llvm_write_output)]
#[diag("could not write output to {$path}")]
WriteOutput { path: &'a Path },
#[diag(codegen_llvm_target_machine)]
#[diag("could not create LLVM TargetMachine for triple: {$triple}")]
CreateTargetMachine { triple: SmallCStr },
#[diag(codegen_llvm_run_passes)]
#[diag("failed to run LLVM passes")]
RunLlvmPasses,
#[diag(codegen_llvm_serialize_module)]
#[diag("failed to serialize module {$name}")]
SerializeModule { name: &'a str },
#[diag(codegen_llvm_write_ir)]
#[diag("failed to write LLVM IR to {$path}")]
WriteIr { path: &'a Path },
#[diag(codegen_llvm_prepare_thin_lto_context)]
#[diag("failed to prepare thin LTO context")]
PrepareThinLtoContext,
#[diag(codegen_llvm_load_bitcode)]
#[diag("failed to load bitcode of module \"{$name}\"")]
LoadBitcode { name: CString },
#[diag(codegen_llvm_write_thinlto_key)]
#[diag("error while writing ThinLTO key data: {$err}")]
WriteThinLtoKey { err: std::io::Error },
#[diag(codegen_llvm_prepare_thin_lto_module)]
#[diag("failed to prepare thin LTO module")]
PrepareThinLtoModule,
#[diag(codegen_llvm_parse_bitcode)]
#[diag("failed to parse bitcode for LTO module")]
ParseBitcode,
#[diag(codegen_llvm_prepare_autodiff)]
#[diag("failed to prepare autodiff: src: {$src}, target: {$target}, {$error}")]
PrepareAutoDiff { src: String, target: String, error: String },
}
@ -119,17 +125,31 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for WithLlvmError<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
use LlvmError::*;
let msg_with_llvm_err = match &self.0 {
WriteOutput { .. } => fluent::codegen_llvm_write_output_with_llvm_err,
CreateTargetMachine { .. } => fluent::codegen_llvm_target_machine_with_llvm_err,
RunLlvmPasses => fluent::codegen_llvm_run_passes_with_llvm_err,
SerializeModule { .. } => fluent::codegen_llvm_serialize_module_with_llvm_err,
WriteIr { .. } => fluent::codegen_llvm_write_ir_with_llvm_err,
PrepareThinLtoContext => fluent::codegen_llvm_prepare_thin_lto_context_with_llvm_err,
LoadBitcode { .. } => fluent::codegen_llvm_load_bitcode_with_llvm_err,
WriteThinLtoKey { .. } => fluent::codegen_llvm_write_thinlto_key_with_llvm_err,
PrepareThinLtoModule => fluent::codegen_llvm_prepare_thin_lto_module_with_llvm_err,
ParseBitcode => fluent::codegen_llvm_parse_bitcode_with_llvm_err,
PrepareAutoDiff { .. } => fluent::codegen_llvm_prepare_autodiff_with_llvm_err,
WriteOutput { .. } => inline_fluent!("could not write output to {$path}: {$llvm_err}"),
CreateTargetMachine { .. } => inline_fluent!(
"could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}"
),
RunLlvmPasses => inline_fluent!("failed to run LLVM passes: {$llvm_err}"),
SerializeModule { .. } => {
inline_fluent!("failed to serialize module {$name}: {$llvm_err}")
}
WriteIr { .. } => inline_fluent!("failed to write LLVM IR to {$path}: {$llvm_err}"),
PrepareThinLtoContext => {
inline_fluent!("failed to prepare thin LTO context: {$llvm_err}")
}
LoadBitcode { .. } => {
inline_fluent!("failed to load bitcode of module \"{$name}\": {$llvm_err}")
}
WriteThinLtoKey { .. } => {
inline_fluent!("error while writing ThinLTO key data: {$err}: {$llvm_err}")
}
PrepareThinLtoModule => {
inline_fluent!("failed to prepare thin LTO module: {$llvm_err}")
}
ParseBitcode => inline_fluent!("failed to parse bitcode for LTO module: {$llvm_err}"),
PrepareAutoDiff { .. } => inline_fluent!(
"failed to prepare autodiff: {$llvm_err}, src: {$src}, target: {$target}, {$error}"
),
};
self.0
.into_diag(dcx, level)
@ -139,7 +159,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for WithLlvmError<'_> {
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_from_llvm_optimization_diag)]
#[diag("{$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}")]
pub(crate) struct FromLlvmOptimizationDiag<'a> {
pub filename: &'a str,
pub line: std::ffi::c_uint,
@ -150,32 +170,36 @@ pub(crate) struct FromLlvmOptimizationDiag<'a> {
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_from_llvm_diag)]
#[diag("{$message}")]
pub(crate) struct FromLlvmDiag {
pub message: String,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_write_bytecode)]
#[diag("failed to write bytecode to {$path}: {$err}")]
pub(crate) struct WriteBytecode<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_copy_bitcode)]
#[diag("failed to copy bitcode to object file: {$err}")]
pub(crate) struct CopyBitcode {
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_unknown_debuginfo_compression)]
#[diag(
"unknown debuginfo compression algorithm {$algorithm} - will fall back to uncompressed debuginfo"
)]
pub(crate) struct UnknownCompression {
pub algorithm: &'static str,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_mismatch_data_layout)]
#[diag(
"data-layout for target `{$rustc_target}`, `{$rustc_layout}`, differs from LLVM target's `{$llvm_target}` default layout, `{$llvm_layout}`"
)]
pub(crate) struct MismatchedDataLayout<'a> {
pub rustc_target: &'a str,
pub rustc_layout: &'a str,
@ -184,11 +208,11 @@ pub(crate) struct MismatchedDataLayout<'a> {
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_fixed_x18_invalid_arch)]
#[diag("the `-Zfixed-x18` flag is not supported on the `{$arch}` architecture")]
pub(crate) struct FixedX18InvalidArch<'a> {
pub arch: &'a str,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_sanitizer_kcfi_arity_requires_llvm_21_0_0)]
#[diag("`-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later.")]
pub(crate) struct SanitizerKcfiArityRequiresLLVM2100;

View file

@ -43,7 +43,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_middle::util::Providers;
use rustc_session::Session;
use rustc_session::config::{OptLevel, OutputFilenames, PrintKind, PrintRequest};
use rustc_span::Symbol;
use rustc_span::{Symbol, sym};
use rustc_target::spec::{RelocModel, TlsModel};
use crate::llvm::ToLlvmBool;
@ -74,8 +74,6 @@ mod typetree;
mod va_arg;
mod value;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub(crate) use macros::TryFromU32;
#[derive(Clone)]
@ -241,10 +239,6 @@ impl LlvmCodegenBackend {
}
impl CodegenBackend for LlvmCodegenBackend {
fn locale_resource(&self) -> &'static str {
crate::DEFAULT_LOCALE_RESOURCE
}
fn name(&self) -> &'static str {
"llvm"
}
@ -350,6 +344,10 @@ impl CodegenBackend for LlvmCodegenBackend {
target_config(sess)
}
fn replaced_intrinsics(&self) -> Vec<Symbol> {
vec![sym::unchecked_funnel_shl, sym::unchecked_funnel_shr, sym::carrying_mul_add]
}
fn codegen_crate<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Box<dyn Any> {
Box::new(rustc_codegen_ssa::base::codegen_crate(
LlvmCodegenBackend(()),

View file

@ -11,10 +11,11 @@ use std::{env, fmt, fs, io, mem, str};
use find_msvc_tools;
use itertools::Itertools;
use object::{Object, ObjectSection, ObjectSymbol};
use regex::Regex;
use rustc_arena::TypedArena;
use rustc_attr_parsing::eval_config_entry;
use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{DiagCtxtHandle, LintDiagnostic};
@ -2185,6 +2186,71 @@ fn add_rpath_args(
}
}
fn add_c_staticlib_symbols(
sess: &Session,
lib: &NativeLib,
out: &mut Vec<(String, SymbolExportKind)>,
) -> io::Result<()> {
let file_path = find_native_static_library(lib.name.as_str(), lib.verbatim, sess);
let archive_map = unsafe { Mmap::map(File::open(&file_path)?)? };
let archive = object::read::archive::ArchiveFile::parse(&*archive_map)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
for member in archive.members() {
let member = member.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
let data = member
.data(&*archive_map)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
// clang LTO: raw LLVM bitcode
if data.starts_with(b"BC\xc0\xde") {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"LLVM bitcode object in C static library (LTO not supported)",
));
}
let object = object::File::parse(&*data)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
// gcc / clang ELF / Mach-O LTO
if object.sections().any(|s| {
s.name().map(|n| n.starts_with(".gnu.lto_") || n == ".llvm.lto").unwrap_or(false)
}) {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"LTO object in C static library is not supported",
));
}
for symbol in object.symbols() {
if symbol.scope() != object::SymbolScope::Dynamic {
continue;
}
let name = match symbol.name() {
Ok(n) => n,
Err(_) => continue,
};
let export_kind = match symbol.kind() {
object::SymbolKind::Text => SymbolExportKind::Text,
object::SymbolKind::Data => SymbolExportKind::Data,
_ => continue,
};
// FIXME:The symbol mangle rules are slightly different in Windows(32-bit) and Apple.
// Need to be resolved.
out.push((name.to_string(), export_kind));
}
}
Ok(())
}
/// Produce the linker command line containing linker path and arguments.
///
/// When comments in the function say "order-(in)dependent" they mean order-dependence between
@ -2217,6 +2283,25 @@ fn linker_with_args(
);
let link_output_kind = link_output_kind(sess, crate_type);
let mut export_symbols = codegen_results.crate_info.exported_symbols[&crate_type].clone();
if crate_type == CrateType::Cdylib {
let mut seen = FxHashSet::default();
for lib in &codegen_results.crate_info.used_libraries {
if let NativeLibKind::Static { export_symbols: Some(true), .. } = lib.kind
&& seen.insert((lib.name, lib.verbatim))
{
if let Err(err) = add_c_staticlib_symbols(&sess, lib, &mut export_symbols) {
sess.dcx().fatal(format!(
"failed to process C static library `{}`: {}",
lib.name, err
));
}
}
}
}
// ------------ Early order-dependent options ------------
// If we're building something like a dynamic library then some platforms
@ -2224,11 +2309,7 @@ fn linker_with_args(
// dynamic library.
// Must be passed before any libraries to prevent the symbols to export from being thrown away,
// at least on some platforms (e.g. windows-gnu).
cmd.export_symbols(
tmpdir,
crate_type,
&codegen_results.crate_info.exported_symbols[&crate_type],
);
cmd.export_symbols(tmpdir, crate_type, &export_symbols);
// Can be used for adding custom CRT objects or overriding order-dependent options above.
// FIXME: In practice built-in target specs use this for arbitrary order-independent options,
@ -2678,7 +2759,7 @@ fn add_native_libs_from_crate(
let name = lib.name.as_str();
let verbatim = lib.verbatim;
match lib.kind {
NativeLibKind::Static { bundle, whole_archive } => {
NativeLibKind::Static { bundle, whole_archive, .. } => {
if link_static {
let bundle = bundle.unwrap_or(true);
let whole_archive = whole_archive == Some(true);

View file

@ -37,10 +37,6 @@ pub trait BackendTypes {
}
pub trait CodegenBackend {
/// Locale resources for diagnostic messages - a string the content of the Fluent resource.
/// Called before `init` so that all other functions are able to emit translatable diagnostics.
fn locale_resource(&self) -> &'static str;
fn name(&self) -> &'static str;
fn init(&self, _sess: &Session) {}
@ -78,6 +74,12 @@ pub trait CodegenBackend {
fn print_version(&self) {}
/// Returns a list of all intrinsics that this backend definitely
/// replaces, which means their fallback bodies do not need to be monomorphized.
fn replaced_intrinsics(&self) -> Vec<Symbol> {
vec![]
}
/// Value printed by `--print=backend-has-zstd`.
///
/// Used by compiletest to determine whether tests involving zstd compression

View file

@ -5,8 +5,8 @@
use either::{Either, Left, Right};
use rustc_abi::{BackendRepr, HasDataLayout, Size};
use rustc_data_structures::assert_matches;
use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{self, Ty};
use rustc_middle::{bug, mir, span_bug};
use tracing::field::Empty;
use tracing::{instrument, trace};
@ -884,10 +884,38 @@ where
dest.layout().ty,
);
}
// If the source has padding, we want to always do a mem-to-mem copy to ensure consistent
// padding in the target independent of layout choices.
let src_has_padding = match src.layout().backend_repr {
BackendRepr::Scalar(_) => false,
BackendRepr::ScalarPair(left, right)
if matches!(src.layout().ty.kind(), ty::Ref(..) | ty::RawPtr(..)) =>
{
// Wide pointers never have padding, so we can avoid calling `size()`.
debug_assert_eq!(left.size(self) + right.size(self), src.layout().size);
false
}
BackendRepr::ScalarPair(left, right) => {
let left_size = left.size(self);
let right_size = right.size(self);
// We have padding if the sizes don't add up to the total.
left_size + right_size != src.layout().size
}
// Everything else can only exist in memory anyway, so it doesn't matter.
BackendRepr::SimdVector { .. }
| BackendRepr::ScalableVector { .. }
| BackendRepr::Memory { .. } => true,
};
// Let us see if the layout is simple so we take a shortcut,
// avoid force_allocation.
let src = match self.read_immediate_raw(src)? {
let src_val = if src_has_padding {
// Do our best to get an mplace. If there's no mplace, then this is stored as an
// "optimized" local, so its padding is definitely uninitialized and we are fine.
src.to_op(self)?.as_mplace_or_imm()
} else {
// Do our best to get an immediate, to avoid having to force_allocate the destination.
self.read_immediate_raw(src)?
};
let src = match src_val {
Right(src_val) => {
assert!(!src.layout().is_unsized());
assert!(!dest.layout().is_unsized());

View file

@ -97,7 +97,7 @@ pub trait Projectable<'tcx, Prov: Provenance>: Sized + std::fmt::Debug {
}
/// Convert this to an `OpTy`. This might be an irreversible transformation, but is useful for
/// reading from this thing.
/// reading from this thing. This will never actually do a read from memory!
fn to_op<M: Machine<'tcx, Provenance = Prov>>(
&self,
ecx: &InterpCx<'tcx, M>,

View file

@ -23,7 +23,6 @@ rustc_feature = { path = "../rustc_feature" }
rustc_hir_analysis = { path = "../rustc_hir_analysis" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
rustc_hir_typeck = { path = "../rustc_hir_typeck" }
rustc_incremental = { path = "../rustc_incremental" }
rustc_index = { path = "../rustc_index" }
rustc_interface = { path = "../rustc_interface" }
rustc_lexer = { path = "../rustc_lexer" }
@ -33,20 +32,16 @@ rustc_macros = { path = "../rustc_macros" }
rustc_metadata = { path = "../rustc_metadata" }
rustc_middle = { path = "../rustc_middle" }
rustc_mir_build = { path = "../rustc_mir_build" }
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
rustc_mir_transform = { path = "../rustc_mir_transform" }
rustc_monomorphize = { path = "../rustc_monomorphize" }
rustc_parse = { path = "../rustc_parse" }
rustc_passes = { path = "../rustc_passes" }
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
rustc_privacy = { path = "../rustc_privacy" }
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
rustc_resolve = { path = "../rustc_resolve" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_ty_utils = { path = "../rustc_ty_utils" }
serde_json = "1.0.59"
shlex = "1.0"
tracing = { version = "0.1.35" }

View file

@ -124,23 +124,16 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
rustc_expand::DEFAULT_LOCALE_RESOURCE,
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
rustc_hir_typeck::DEFAULT_LOCALE_RESOURCE,
rustc_incremental::DEFAULT_LOCALE_RESOURCE,
rustc_interface::DEFAULT_LOCALE_RESOURCE,
rustc_lint::DEFAULT_LOCALE_RESOURCE,
rustc_metadata::DEFAULT_LOCALE_RESOURCE,
rustc_middle::DEFAULT_LOCALE_RESOURCE,
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
rustc_mir_dataflow::DEFAULT_LOCALE_RESOURCE,
rustc_mir_transform::DEFAULT_LOCALE_RESOURCE,
rustc_monomorphize::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_passes::DEFAULT_LOCALE_RESOURCE,
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
rustc_privacy::DEFAULT_LOCALE_RESOURCE,
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
rustc_session::DEFAULT_LOCALE_RESOURCE,
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
rustc_ty_utils::DEFAULT_LOCALE_RESOURCE,
// tidy-alphabetical-end
];

View file

@ -331,6 +331,8 @@ pub enum NativeLibKind {
bundle: Option<bool>,
/// Whether to link static library without throwing any object files away
whole_archive: Option<bool>,
/// Whether to export c static library symbols
export_symbols: Option<bool>,
},
/// Dynamic library (e.g. `libfoo.so` on Linux)
/// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC).
@ -363,8 +365,8 @@ pub enum NativeLibKind {
impl NativeLibKind {
pub fn has_modifiers(&self) -> bool {
match self {
NativeLibKind::Static { bundle, whole_archive } => {
bundle.is_some() || whole_archive.is_some()
NativeLibKind::Static { bundle, whole_archive, export_symbols } => {
bundle.is_some() || whole_archive.is_some() || export_symbols.is_some()
}
NativeLibKind::Dylib { as_needed }
| NativeLibKind::Framework { as_needed }

View file

@ -9,7 +9,6 @@ rand = "0.9.0"
rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_fs_util = { path = "../rustc_fs_util" }
rustc_graphviz = { path = "../rustc_graphviz" }
rustc_hashes = { path = "../rustc_hashes" }

View file

@ -1,102 +0,0 @@
incremental_assert_loaded =
we asserted that an existing incremental cache directory should be successfully loaded, but it was not
incremental_assert_not_loaded =
we asserted that the incremental cache should not be loaded, but it was loaded
incremental_assertion_auto =
`except` specified DepNodes that can not be affected for "{$name}": "{$e}"
incremental_associated_value_expected = expected an associated value
incremental_associated_value_expected_for = associated value expected for `{$ident}`
incremental_canonicalize_path = incremental compilation: error canonicalizing path `{$path}`: {$err}
incremental_cargo_help_1 =
incremental compilation can be disabled by setting the environment variable CARGO_INCREMENTAL=0 (see https://doc.rust-lang.org/cargo/reference/profiles.html#incremental)
incremental_cargo_help_2 =
the entire build directory can be changed to a different filesystem by setting the environment variable CARGO_TARGET_DIR to a different path (see https://doc.rust-lang.org/cargo/reference/config.html#buildtarget-dir)
incremental_copy_workproduct_to_cache =
error copying object file `{$from}` to incremental directory as `{$to}`: {$err}
incremental_corrupt_file = corrupt incremental compilation artifact found at `{$path}`. This file will automatically be ignored and deleted. If you see this message repeatedly or can provoke it without manually manipulating the compiler's artifacts, please file an issue. The incremental compilation system relies on hardlinks and filesystem locks behaving correctly, and may not deal well with OS crashes, so whatever information you can provide about your filesystem or other state may be very relevant.
incremental_create_dep_graph = failed to create dependency graph at `{$path}`: {$err}
incremental_create_incr_comp_dir =
could not create incremental compilation {$tag} directory `{$path}`: {$err}
incremental_create_lock =
incremental compilation: could not create session directory lock file: {$lock_err}
incremental_create_new = failed to create {$name} at `{$path}`: {$err}
incremental_delete_full = error deleting incremental compilation session directory `{$path}`: {$err}
incremental_delete_incompatible =
failed to delete invalidated or incompatible incremental compilation session directory contents `{$path}`: {$err}
incremental_delete_lock =
error deleting lock file for incremental compilation session directory `{$path}`: {$err}
incremental_delete_old = unable to delete old {$name} at `{$path}`: {$err}
incremental_delete_partial = failed to delete partly initialized session dir `{$path}`: {$err}
incremental_delete_workproduct = file-system error deleting outdated file `{$path}`: {$err}
incremental_finalize = error finalizing incremental compilation session directory `{$path}`: {$err}
incremental_finalized_gc_failed =
failed to garbage collect finalized incremental compilation session directory `{$path}`: {$err}
incremental_hard_link_failed =
hard linking files in the incremental compilation cache failed. copying files instead. consider moving the cache directory to a file system which supports hard linking in session dir `{$path}`
incremental_invalid_gc_failed =
failed to garbage collect invalid incremental compilation session directory `{$path}`: {$err}
incremental_load_dep_graph = could not load dep-graph from `{$path}`: {$err}
incremental_lock_unsupported =
the filesystem for the incremental path at {$session_dir} does not appear to support locking, consider changing the incremental path to a filesystem that supports locking or disable incremental compilation
incremental_missing_depnode = missing `DepNode` variant
incremental_missing_if_this_changed = no `#[rustc_if_this_changed]` annotation detected
incremental_move_dep_graph = failed to move dependency graph from `{$from}` to `{$to}`: {$err}
incremental_no_cfg = no cfg attribute
incremental_no_path = no path from `{$source}` to `{$target}`
incremental_not_clean = `{$dep_node_str}` should be clean but is not
incremental_not_dirty = `{$dep_node_str}` should be dirty but is not
incremental_not_loaded = `{$dep_node_str}` should have been loaded from disk but it was not
incremental_ok = OK
incremental_repeated_depnode_label = dep-node label `{$label}` is repeated
incremental_session_gc_failed =
failed to garbage collect incremental compilation session directory `{$path}`: {$err}
incremental_unchecked_clean = found unchecked `#[rustc_clean]` attribute
incremental_undefined_clean_dirty_assertions =
clean/dirty auto-assertions not yet defined for {$kind}
incremental_undefined_clean_dirty_assertions_item =
clean/dirty auto-assertions not yet defined for Node::Item.node={$kind}
incremental_unknown_rustc_clean_argument = unknown `rustc_clean` argument
incremental_unrecognized_depnode = unrecognized `DepNode` variant: {$name}
incremental_unrecognized_depnode_label = dep-node label `{$label}` not recognized
incremental_write_new = failed to write {$name} to `{$path}`: {$err}

View file

@ -4,7 +4,7 @@ use rustc_macros::Diagnostic;
use rustc_span::{Ident, Span, Symbol};
#[derive(Diagnostic)]
#[diag(incremental_unrecognized_depnode)]
#[diag("unrecognized `DepNode` variant: {$name}")]
pub(crate) struct UnrecognizedDepNode {
#[primary_span]
pub span: Span,
@ -12,28 +12,28 @@ pub(crate) struct UnrecognizedDepNode {
}
#[derive(Diagnostic)]
#[diag(incremental_missing_depnode)]
#[diag("missing `DepNode` variant")]
pub(crate) struct MissingDepNode {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_missing_if_this_changed)]
#[diag("no `#[rustc_if_this_changed]` annotation detected")]
pub(crate) struct MissingIfThisChanged {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_ok)]
#[diag("OK")]
pub(crate) struct Ok {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_no_path)]
#[diag("no path from `{$source}` to `{$target}`")]
pub(crate) struct NoPath {
#[primary_span]
pub span: Span,
@ -42,7 +42,7 @@ pub(crate) struct NoPath {
}
#[derive(Diagnostic)]
#[diag(incremental_assertion_auto)]
#[diag("`except` specified DepNodes that can not be affected for \"{$name}\": \"{$e}\"")]
pub(crate) struct AssertionAuto<'a> {
#[primary_span]
pub span: Span,
@ -51,7 +51,7 @@ pub(crate) struct AssertionAuto<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_undefined_clean_dirty_assertions_item)]
#[diag("clean/dirty auto-assertions not yet defined for Node::Item.node={$kind}")]
pub(crate) struct UndefinedCleanDirtyItem {
#[primary_span]
pub span: Span,
@ -59,7 +59,7 @@ pub(crate) struct UndefinedCleanDirtyItem {
}
#[derive(Diagnostic)]
#[diag(incremental_undefined_clean_dirty_assertions)]
#[diag("clean/dirty auto-assertions not yet defined for {$kind}")]
pub(crate) struct UndefinedCleanDirty {
#[primary_span]
pub span: Span,
@ -67,7 +67,7 @@ pub(crate) struct UndefinedCleanDirty {
}
#[derive(Diagnostic)]
#[diag(incremental_repeated_depnode_label)]
#[diag("dep-node label `{$label}` is repeated")]
pub(crate) struct RepeatedDepNodeLabel<'a> {
#[primary_span]
pub span: Span,
@ -75,7 +75,7 @@ pub(crate) struct RepeatedDepNodeLabel<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_unrecognized_depnode_label)]
#[diag("dep-node label `{$label}` not recognized")]
pub(crate) struct UnrecognizedDepNodeLabel<'a> {
#[primary_span]
pub span: Span,
@ -83,7 +83,7 @@ pub(crate) struct UnrecognizedDepNodeLabel<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_not_dirty)]
#[diag("`{$dep_node_str}` should be dirty but is not")]
pub(crate) struct NotDirty<'a> {
#[primary_span]
pub span: Span,
@ -91,7 +91,7 @@ pub(crate) struct NotDirty<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_not_clean)]
#[diag("`{$dep_node_str}` should be clean but is not")]
pub(crate) struct NotClean<'a> {
#[primary_span]
pub span: Span,
@ -99,7 +99,7 @@ pub(crate) struct NotClean<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_not_loaded)]
#[diag("`{$dep_node_str}` should have been loaded from disk but it was not")]
pub(crate) struct NotLoaded<'a> {
#[primary_span]
pub span: Span,
@ -107,21 +107,21 @@ pub(crate) struct NotLoaded<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_unknown_rustc_clean_argument)]
#[diag("unknown `rustc_clean` argument")]
pub(crate) struct UnknownRustcCleanArgument {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_no_cfg)]
#[diag("no cfg attribute")]
pub(crate) struct NoCfg {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_associated_value_expected_for)]
#[diag("associated value expected for `{$ident}`")]
pub(crate) struct AssociatedValueExpectedFor {
#[primary_span]
pub span: Span,
@ -129,21 +129,21 @@ pub(crate) struct AssociatedValueExpectedFor {
}
#[derive(Diagnostic)]
#[diag(incremental_associated_value_expected)]
#[diag("expected an associated value")]
pub(crate) struct AssociatedValueExpected {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_unchecked_clean)]
#[diag("found unchecked `#[rustc_clean]` attribute")]
pub(crate) struct UncheckedClean {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_delete_old)]
#[diag("unable to delete old {$name} at `{$path}`: {$err}")]
pub(crate) struct DeleteOld<'a> {
pub name: &'a str,
pub path: PathBuf,
@ -151,7 +151,7 @@ pub(crate) struct DeleteOld<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_create_new)]
#[diag("failed to create {$name} at `{$path}`: {$err}")]
pub(crate) struct CreateNew<'a> {
pub name: &'a str,
pub path: PathBuf,
@ -159,7 +159,7 @@ pub(crate) struct CreateNew<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_write_new)]
#[diag("failed to write {$name} to `{$path}`: {$err}")]
pub(crate) struct WriteNew<'a> {
pub name: &'a str,
pub path: PathBuf,
@ -167,14 +167,14 @@ pub(crate) struct WriteNew<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_canonicalize_path)]
#[diag("incremental compilation: error canonicalizing path `{$path}`: {$err}")]
pub(crate) struct CanonicalizePath {
pub path: PathBuf,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_create_incr_comp_dir)]
#[diag("could not create incremental compilation {$tag} directory `{$path}`: {$err}")]
pub(crate) struct CreateIncrCompDir<'a> {
pub tag: &'a str,
pub path: &'a Path,
@ -182,96 +182,112 @@ pub(crate) struct CreateIncrCompDir<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_create_lock)]
#[diag("incremental compilation: could not create session directory lock file: {$lock_err}")]
pub(crate) struct CreateLock<'a> {
pub lock_err: std::io::Error,
pub session_dir: &'a Path,
#[note(incremental_lock_unsupported)]
#[note(
"the filesystem for the incremental path at {$session_dir} does not appear to support locking, consider changing the incremental path to a filesystem that supports locking or disable incremental compilation"
)]
pub is_unsupported_lock: bool,
#[help(incremental_cargo_help_1)]
#[help(incremental_cargo_help_2)]
#[help(
"incremental compilation can be disabled by setting the environment variable CARGO_INCREMENTAL=0 (see https://doc.rust-lang.org/cargo/reference/profiles.html#incremental)"
)]
#[help(
"the entire build directory can be changed to a different filesystem by setting the environment variable CARGO_TARGET_DIR to a different path (see https://doc.rust-lang.org/cargo/reference/config.html#buildtarget-dir)"
)]
pub is_cargo: bool,
}
#[derive(Diagnostic)]
#[diag(incremental_delete_lock)]
#[diag("error deleting lock file for incremental compilation session directory `{$path}`: {$err}")]
pub(crate) struct DeleteLock<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_hard_link_failed)]
#[diag(
"hard linking files in the incremental compilation cache failed. copying files instead. consider moving the cache directory to a file system which supports hard linking in session dir `{$path}`"
)]
pub(crate) struct HardLinkFailed<'a> {
pub path: &'a Path,
}
#[derive(Diagnostic)]
#[diag(incremental_delete_partial)]
#[diag("failed to delete partly initialized session dir `{$path}`: {$err}")]
pub(crate) struct DeletePartial<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_delete_full)]
#[diag("error deleting incremental compilation session directory `{$path}`: {$err}")]
pub(crate) struct DeleteFull<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_finalize)]
#[diag("error finalizing incremental compilation session directory `{$path}`: {$err}")]
pub(crate) struct Finalize<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_invalid_gc_failed)]
#[diag(
"failed to garbage collect invalid incremental compilation session directory `{$path}`: {$err}"
)]
pub(crate) struct InvalidGcFailed<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_finalized_gc_failed)]
#[diag(
"failed to garbage collect finalized incremental compilation session directory `{$path}`: {$err}"
)]
pub(crate) struct FinalizedGcFailed<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_session_gc_failed)]
#[diag("failed to garbage collect incremental compilation session directory `{$path}`: {$err}")]
pub(crate) struct SessionGcFailed<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_assert_not_loaded)]
#[diag("we asserted that the incremental cache should not be loaded, but it was loaded")]
pub(crate) struct AssertNotLoaded;
#[derive(Diagnostic)]
#[diag(incremental_assert_loaded)]
#[diag(
"we asserted that an existing incremental cache directory should be successfully loaded, but it was not"
)]
pub(crate) struct AssertLoaded;
#[derive(Diagnostic)]
#[diag(incremental_delete_incompatible)]
#[diag(
"failed to delete invalidated or incompatible incremental compilation session directory contents `{$path}`: {$err}"
)]
pub(crate) struct DeleteIncompatible {
pub path: PathBuf,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_load_dep_graph)]
#[diag("could not load dep-graph from `{$path}`: {$err}")]
pub(crate) struct LoadDepGraph {
pub path: PathBuf,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_move_dep_graph)]
#[diag("failed to move dependency graph from `{$from}` to `{$to}`: {$err}")]
pub(crate) struct MoveDepGraph<'a> {
pub from: &'a Path,
pub to: &'a Path,
@ -279,14 +295,14 @@ pub(crate) struct MoveDepGraph<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_create_dep_graph)]
#[diag("failed to create dependency graph at `{$path}`: {$err}")]
pub(crate) struct CreateDepGraph<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_copy_workproduct_to_cache)]
#[diag("error copying object file `{$from}` to incremental directory as `{$to}`: {$err}")]
pub(crate) struct CopyWorkProductToCache<'a> {
pub from: &'a Path,
pub to: &'a Path,
@ -294,14 +310,16 @@ pub(crate) struct CopyWorkProductToCache<'a> {
}
#[derive(Diagnostic)]
#[diag(incremental_delete_workproduct)]
#[diag("file-system error deleting outdated file `{$path}`: {$err}")]
pub(crate) struct DeleteWorkProduct<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_corrupt_file)]
#[diag(
"corrupt incremental compilation artifact found at `{$path}`. This file will automatically be ignored and deleted. If you see this message repeatedly or can provoke it without manually manipulating the compiler's artifacts, please file an issue. The incremental compilation system relies on hardlinks and filesystem locks behaving correctly, and may not deal well with OS crashes, so whatever information you can provide about your filesystem or other state may be very relevant."
)]
pub(crate) struct CorruptFile<'a> {
pub path: &'a Path,
}

View file

@ -21,5 +21,3 @@ pub fn provide(providers: &mut Providers) {
providers.hooks.save_dep_graph =
|tcx| tcx.sess.time("serialize_dep_graph", || persist::save_dep_graph(tcx));
}
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -19,7 +19,6 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" }
rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_fs_util = { path = "../rustc_fs_util" }
rustc_hir = { path = "../rustc_hir" }
rustc_hir_analysis = { path = "../rustc_hir_analysis" }

View file

@ -1,56 +0,0 @@
interface_abi_required_feature =
target feature `{$feature}` must be {$enabled} to ensure that the ABI of the current target can be implemented correctly
.note = this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
interface_abi_required_feature_issue = for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
interface_crate_name_does_not_match = `--crate-name` and `#[crate_name]` are required to match, but `{$crate_name}` != `{$attr_crate_name}`
interface_crate_name_invalid = crate names cannot start with a `-`, but `{$crate_name}` has a leading hyphen
interface_emoji_identifier =
identifiers cannot contain emoji: `{$ident}`
interface_error_writing_dependencies =
error writing dependencies to `{$path}`: {$error}
interface_failed_writing_file =
failed to write file {$path}: {$error}"
interface_ferris_identifier =
Ferris cannot be used as an identifier
.suggestion = try using their name instead
interface_generated_file_conflicts_with_directory =
the generated executable for the input file "{$input_path}" conflicts with the existing directory "{$dir_path}"
interface_ignoring_extra_filename = ignoring -C extra-filename flag due to -o flag
interface_ignoring_out_dir = ignoring --out-dir flag due to -o flag
interface_input_file_would_be_overwritten =
the input file "{$path}" would be overwritten by the generated executable
interface_mixed_bin_crate =
cannot mix `bin` crate type with others
interface_mixed_proc_macro_crate =
cannot mix `proc-macro` crate type with others
interface_multiple_output_types_adaption =
due to multiple output types requested, the explicitly specified output file name will be adapted for each output type
interface_multiple_output_types_to_stdout = can't use option `-o` or `--emit` to write multiple output types to stdout
interface_out_dir_error =
failed to find or create the directory specified by `--out-dir`
interface_proc_macro_crate_panic_abort =
building proc macro crate with `panic=abort` or `panic=immediate-abort` may crash the compiler should the proc-macro panic
interface_temps_dir_error =
failed to find or create the directory specified by `--temps-dir`
interface_unsupported_crate_type_for_codegen_backend =
dropping unsupported crate type `{$crate_type}` for codegen backend `{$codegen_backend}`
interface_unsupported_crate_type_for_target =
dropping unsupported crate type `{$crate_type}` for target `{$target_triple}`

View file

@ -7,7 +7,9 @@ use rustc_span::{Span, Symbol};
use rustc_target::spec::TargetTuple;
#[derive(Diagnostic)]
#[diag(interface_crate_name_does_not_match)]
#[diag(
"`--crate-name` and `#[crate_name]` are required to match, but `{$crate_name}` != `{$attr_crate_name}`"
)]
pub(crate) struct CrateNameDoesNotMatch {
#[primary_span]
pub(crate) span: Span,
@ -16,23 +18,27 @@ pub(crate) struct CrateNameDoesNotMatch {
}
#[derive(Diagnostic)]
#[diag(interface_crate_name_invalid)]
#[diag("crate names cannot start with a `-`, but `{$crate_name}` has a leading hyphen")]
pub(crate) struct CrateNameInvalid<'a> {
pub(crate) crate_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(interface_ferris_identifier)]
#[diag("Ferris cannot be used as an identifier")]
pub struct FerrisIdentifier {
#[primary_span]
pub spans: Vec<Span>,
#[suggestion(code = "{ferris_fix}", applicability = "maybe-incorrect")]
#[suggestion(
"try using their name instead",
code = "{ferris_fix}",
applicability = "maybe-incorrect"
)]
pub first_span: Span,
pub ferris_fix: &'static str,
}
#[derive(Diagnostic)]
#[diag(interface_emoji_identifier)]
#[diag("identifiers cannot contain emoji: `{$ident}`")]
pub struct EmojiIdentifier {
#[primary_span]
pub spans: Vec<Span>,
@ -40,86 +46,96 @@ pub struct EmojiIdentifier {
}
#[derive(Diagnostic)]
#[diag(interface_mixed_bin_crate)]
#[diag("cannot mix `bin` crate type with others")]
pub struct MixedBinCrate;
#[derive(Diagnostic)]
#[diag(interface_mixed_proc_macro_crate)]
#[diag("cannot mix `proc-macro` crate type with others")]
pub struct MixedProcMacroCrate;
#[derive(Diagnostic)]
#[diag(interface_error_writing_dependencies)]
#[diag("error writing dependencies to `{$path}`: {$error}")]
pub struct ErrorWritingDependencies<'a> {
pub path: &'a Path,
pub error: io::Error,
}
#[derive(Diagnostic)]
#[diag(interface_input_file_would_be_overwritten)]
#[diag("the input file \"{$path}\" would be overwritten by the generated executable")]
pub struct InputFileWouldBeOverWritten<'a> {
pub path: &'a Path,
}
#[derive(Diagnostic)]
#[diag(interface_generated_file_conflicts_with_directory)]
#[diag(
"the generated executable for the input file \"{$input_path}\" conflicts with the existing directory \"{$dir_path}\""
)]
pub struct GeneratedFileConflictsWithDirectory<'a> {
pub input_path: &'a Path,
pub dir_path: &'a Path,
}
#[derive(Diagnostic)]
#[diag(interface_temps_dir_error)]
#[diag("failed to find or create the directory specified by `--temps-dir`")]
pub struct TempsDirError;
#[derive(Diagnostic)]
#[diag(interface_out_dir_error)]
#[diag("failed to find or create the directory specified by `--out-dir`")]
pub struct OutDirError;
#[derive(Diagnostic)]
#[diag(interface_failed_writing_file)]
#[diag("failed to write file {$path}: {$error}\"")]
pub struct FailedWritingFile<'a> {
pub path: &'a Path,
pub error: io::Error,
}
#[derive(Diagnostic)]
#[diag(interface_proc_macro_crate_panic_abort)]
#[diag(
"building proc macro crate with `panic=abort` or `panic=immediate-abort` may crash the compiler should the proc-macro panic"
)]
pub struct ProcMacroCratePanicAbort;
#[derive(Diagnostic)]
#[diag(interface_multiple_output_types_adaption)]
#[diag(
"due to multiple output types requested, the explicitly specified output file name will be adapted for each output type"
)]
pub struct MultipleOutputTypesAdaption;
#[derive(Diagnostic)]
#[diag(interface_ignoring_extra_filename)]
#[diag("ignoring -C extra-filename flag due to -o flag")]
pub struct IgnoringExtraFilename;
#[derive(Diagnostic)]
#[diag(interface_ignoring_out_dir)]
#[diag("ignoring --out-dir flag due to -o flag")]
pub struct IgnoringOutDir;
#[derive(Diagnostic)]
#[diag(interface_multiple_output_types_to_stdout)]
#[diag("can't use option `-o` or `--emit` to write multiple output types to stdout")]
pub struct MultipleOutputTypesToStdout;
#[derive(Diagnostic)]
#[diag(interface_abi_required_feature)]
#[note]
#[note(interface_abi_required_feature_issue)]
#[diag(
"target feature `{$feature}` must be {$enabled} to ensure that the ABI of the current target can be implemented correctly"
)]
#[note(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
#[note("for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>")]
pub(crate) struct AbiRequiredTargetFeature<'a> {
pub feature: &'a str,
pub enabled: &'a str,
}
#[derive(Diagnostic)]
#[diag(interface_unsupported_crate_type_for_codegen_backend)]
#[diag("dropping unsupported crate type `{$crate_type}` for codegen backend `{$codegen_backend}`")]
pub(crate) struct UnsupportedCrateTypeForCodegenBackend {
pub(crate) crate_type: CrateType,
pub(crate) codegen_backend: &'static str,
}
#[derive(Diagnostic)]
#[diag(interface_unsupported_crate_type_for_target)]
#[diag("dropping unsupported crate type `{$crate_type}` for target `{$target_triple}`")]
pub(crate) struct UnsupportedCrateTypeForTarget<'a> {
pub(crate) crate_type: CrateType,
pub(crate) target_triple: &'a TargetTuple,

View file

@ -55,11 +55,7 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
cfgs.into_iter()
.map(|s| {
let psess = ParseSess::emitter_with_note(
vec![
crate::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_session::DEFAULT_LOCALE_RESOURCE,
],
vec![rustc_parse::DEFAULT_LOCALE_RESOURCE],
format!("this occurred on the command line: `--cfg={s}`"),
);
let filename = FileName::cfg_spec_source_code(&s);
@ -131,11 +127,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
for s in specs {
let psess = ParseSess::emitter_with_note(
vec![
crate::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_session::DEFAULT_LOCALE_RESOURCE,
],
vec![rustc_parse::DEFAULT_LOCALE_RESOURCE],
format!("this occurred on the command line: `--check-cfg={s}`"),
);
let filename = FileName::cfg_spec_source_code(&s);
@ -463,9 +455,6 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
Err(e) => early_dcx.early_fatal(format!("failed to load fluent bundle: {e}")),
};
let mut locale_resources = config.locale_resources;
locale_resources.push(codegen_backend.locale_resource());
let mut sess = rustc_session::build_session(
config.opts,
CompilerIO {
@ -476,7 +465,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
},
bundle,
config.registry,
locale_resources,
config.locale_resources,
config.lint_caps,
target,
util::rustc_version_str().unwrap_or("unknown"),
@ -485,6 +474,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
);
codegen_backend.init(&sess);
sess.replaced_intrinsics = FxHashSet::from_iter(codegen_backend.replaced_intrinsics());
let cfg = parse_cfg(sess.dcx(), config.crate_cfg);
let mut cfg = config::build_configuration(&sess, cfg);

View file

@ -21,5 +21,3 @@ pub use queries::Linker;
#[cfg(test)]
mod tests;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -379,7 +379,7 @@ fn test_native_libs_tracking_hash_different_values() {
NativeLib {
name: String::from("a"),
new_name: None,
kind: NativeLibKind::Static { bundle: None, whole_archive: None },
kind: NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None },
verbatim: None,
},
NativeLib {
@ -401,7 +401,7 @@ fn test_native_libs_tracking_hash_different_values() {
NativeLib {
name: String::from("a"),
new_name: None,
kind: NativeLibKind::Static { bundle: None, whole_archive: None },
kind: NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None },
verbatim: None,
},
NativeLib {
@ -423,13 +423,13 @@ fn test_native_libs_tracking_hash_different_values() {
NativeLib {
name: String::from("a"),
new_name: None,
kind: NativeLibKind::Static { bundle: None, whole_archive: None },
kind: NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None },
verbatim: None,
},
NativeLib {
name: String::from("b"),
new_name: None,
kind: NativeLibKind::Static { bundle: None, whole_archive: None },
kind: NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None },
verbatim: None,
},
NativeLib {
@ -445,7 +445,7 @@ fn test_native_libs_tracking_hash_different_values() {
NativeLib {
name: String::from("a"),
new_name: None,
kind: NativeLibKind::Static { bundle: None, whole_archive: None },
kind: NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None },
verbatim: None,
},
NativeLib {
@ -467,7 +467,7 @@ fn test_native_libs_tracking_hash_different_values() {
NativeLib {
name: String::from("a"),
new_name: None,
kind: NativeLibKind::Static { bundle: None, whole_archive: None },
kind: NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None },
verbatim: None,
},
NativeLib {
@ -501,7 +501,7 @@ fn test_native_libs_tracking_hash_different_order() {
NativeLib {
name: String::from("a"),
new_name: None,
kind: NativeLibKind::Static { bundle: None, whole_archive: None },
kind: NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None },
verbatim: None,
},
NativeLib {
@ -528,7 +528,7 @@ fn test_native_libs_tracking_hash_different_order() {
NativeLib {
name: String::from("a"),
new_name: None,
kind: NativeLibKind::Static { bundle: None, whole_archive: None },
kind: NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None },
verbatim: None,
},
NativeLib {
@ -549,7 +549,7 @@ fn test_native_libs_tracking_hash_different_order() {
NativeLib {
name: String::from("a"),
new_name: None,
kind: NativeLibKind::Static { bundle: None, whole_archive: None },
kind: NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None },
verbatim: None,
},
NativeLib {

View file

@ -361,10 +361,6 @@ pub struct DummyCodegenBackend {
}
impl CodegenBackend for DummyCodegenBackend {
fn locale_resource(&self) -> &'static str {
""
}
fn name(&self) -> &'static str {
"dummy"
}

View file

@ -326,6 +326,14 @@ lint_expectation = this lint expectation is unfulfilled
.note = the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message
.rationale = {$rationale}
lint_expected_name_value =
expected this to be of the form `... = "..."`
.warn = {-lint_previously_accepted}
lint_expected_no_args =
didn't expect any arguments here
.warn = {-lint_previously_accepted}
lint_for_loops_over_fallibles =
for loop over {$article} `{$ref_prefix}{$ty}`. This is more readably written as an `if let` statement
.suggestion = consider using `if let` to clear intent
@ -558,6 +566,10 @@ lint_macro_expr_fragment_specifier_2024_migration =
lint_malformed_attribute = malformed lint attribute input
lint_malformed_doc =
malformed `doc` attribute input
.warn = {-lint_previously_accepted}
lint_map_unit_fn = `Iterator::map` call that discard the iterator's values
.note = `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated
.function_label = this function returns `()`, which is likely not what you wanted

View file

@ -428,5 +428,11 @@ pub fn decorate_attribute_lint(
sugg: suggested.map(|s| lints::UnknownCrateTypesSuggestion { span, snippet: s }),
}
.decorate_lint(diag),
&AttributeLintKind::MalformedDoc => lints::MalformedDoc.decorate_lint(diag),
&AttributeLintKind::ExpectedNoArgs => lints::ExpectedNoArgs.decorate_lint(diag),
&AttributeLintKind::ExpectedNameValue => lints::ExpectedNameValue.decorate_lint(diag),
}
}

View file

@ -3185,6 +3185,21 @@ pub(crate) struct UnusedDuplicate {
pub warning: bool,
}
#[derive(LintDiagnostic)]
#[diag(lint_malformed_doc)]
#[warning]
pub(crate) struct MalformedDoc;
#[derive(LintDiagnostic)]
#[diag(lint_expected_no_args)]
#[warning]
pub(crate) struct ExpectedNoArgs;
#[derive(LintDiagnostic)]
#[diag(lint_expected_name_value)]
#[warning]
pub(crate) struct ExpectedNameValue;
#[derive(LintDiagnostic)]
#[diag(lint_unsafe_attr_outside_unsafe)]
pub(crate) struct UnsafeAttrOutsideUnsafeLint {

View file

@ -3458,7 +3458,7 @@ declare_lint! {
/// but this lint was introduced to avoid breaking any existing
/// crates which included them.
pub INVALID_DOC_ATTRIBUTES,
Deny,
Warn,
"detects invalid `#[doc(...)]` attributes",
}

View file

@ -826,6 +826,9 @@ pub enum AttributeLintKind {
span: Span,
suggested: Option<Symbol>,
},
MalformedDoc,
ExpectedNoArgs,
ExpectedNameValue,
}
pub type RegisteredTools = FxIndexSet<Ident>;

View file

@ -90,7 +90,7 @@ struct QueryModifiers {
arena_cache: Option<Ident>,
/// Cache the query to disk if the `Block` returns true.
cache: Option<(Option<Pat>, Block)>,
cache_on_disk_if: Option<(Option<Pat>, Block)>,
/// A cycle error for this query aborting the compilation with a fatal error.
cycle_fatal: Option<Ident>,
@ -134,7 +134,7 @@ struct QueryModifiers {
fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
let mut arena_cache = None;
let mut cache = None;
let mut cache_on_disk_if = None;
let mut desc = None;
let mut cycle_fatal = None;
let mut cycle_delay_bug = None;
@ -175,8 +175,11 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
let list = attr_content.parse_terminated(Expr::parse, Token![,])?;
try_insert!(desc = (tcx, list));
} else if modifier == "cache_on_disk_if" {
// Parse a cache modifier like:
// `cache(tcx) { |tcx| key.is_local() }`
// Parse a cache-on-disk modifier like:
//
// `cache_on_disk_if { true }`
// `cache_on_disk_if { key.is_local() }`
// `cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) }`
let args = if input.peek(token::Paren) {
let args;
parenthesized!(args in input);
@ -186,7 +189,7 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
None
};
let block = input.parse()?;
try_insert!(cache = (args, block));
try_insert!(cache_on_disk_if = (args, block));
} else if modifier == "arena_cache" {
try_insert!(arena_cache = modifier);
} else if modifier == "cycle_fatal" {
@ -218,7 +221,7 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
};
Ok(QueryModifiers {
arena_cache,
cache,
cache_on_disk_if,
desc,
cycle_fatal,
cycle_delay_bug,
@ -260,12 +263,18 @@ fn doc_comment_from_desc(list: &Punctuated<Expr, token::Comma>) -> Result<Attrib
Ok(parse_quote! { #[doc = #doc_string] })
}
/// Add the impl of QueryDescription for the query to `impls` if one is requested
fn add_query_desc_cached_impl(
query: &Query,
descs: &mut proc_macro2::TokenStream,
cached: &mut proc_macro2::TokenStream,
) {
/// Contains token streams that are used to accumulate per-query helper
/// functions, to be used by the final output of `rustc_queries!`.
///
/// Helper items typically have the same name as the query they relate to,
/// and expect to be interpolated into a dedicated module.
#[derive(Default)]
struct HelperTokenStreams {
description_fns_stream: proc_macro2::TokenStream,
cache_on_disk_if_fns_stream: proc_macro2::TokenStream,
}
fn make_helpers_for_query(query: &Query, streams: &mut HelperTokenStreams) {
let Query { name, key, modifiers, .. } = &query;
// This dead code exists to instruct rust-analyzer about the link between the `rustc_queries`
@ -281,15 +290,15 @@ fn add_query_desc_cached_impl(
};
// Generate a function to check whether we should cache the query to disk, for some key.
if let Some((args, expr)) = modifiers.cache.as_ref() {
if let Some((args, expr)) = modifiers.cache_on_disk_if.as_ref() {
let tcx = args.as_ref().map(|t| quote! { #t }).unwrap_or_else(|| quote! { _ });
// expr is a `Block`, meaning that `{ #expr }` gets expanded
// to `{ { stmts... } }`, which triggers the `unused_braces` lint.
// we're taking `key` by reference, but some rustc types usually prefer being passed by value
cached.extend(quote! {
streams.cache_on_disk_if_fns_stream.extend(quote! {
#[allow(unused_variables, unused_braces, rustc::pass_by_value)]
#[inline]
pub fn #name<'tcx>(#tcx: TyCtxt<'tcx>, #key: &crate::query::queries::#name::Key<'tcx>) -> bool {
pub fn #name<'tcx>(#tcx: TyCtxt<'tcx>, #key: &crate::queries::#name::Key<'tcx>) -> bool {
#ra_hint
#expr
}
@ -301,13 +310,13 @@ fn add_query_desc_cached_impl(
let desc = quote! {
#[allow(unused_variables)]
pub fn #name<'tcx>(tcx: TyCtxt<'tcx>, key: crate::query::queries::#name::Key<'tcx>) -> String {
pub fn #name<'tcx>(tcx: TyCtxt<'tcx>, key: crate::queries::#name::Key<'tcx>) -> String {
let (#tcx, #key) = (tcx, key);
format!(#desc)
}
};
descs.extend(quote! {
streams.description_fns_stream.extend(quote! {
#desc
});
}
@ -316,8 +325,7 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
let queries = parse_macro_input!(input as List<Query>);
let mut query_stream = quote! {};
let mut query_description_stream = quote! {};
let mut query_cached_stream = quote! {};
let mut helpers = HelperTokenStreams::default();
let mut feedable_queries = quote! {};
let mut errors = quote! {};
@ -357,14 +365,17 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
no_hash,
anon,
eval_always,
feedable,
depth_limit,
separate_provide_extern,
return_result_from_ensure_ok,
);
// Pass on the cache modifier
if modifiers.cache.is_some() {
attributes.push(quote! { (cache) });
// If there was a `cache_on_disk_if` modifier in the real input, pass
// on a synthetic `(cache_on_disk)` modifier that can be inspected by
// macro-rules macros.
if modifiers.cache_on_disk_if.is_some() {
attributes.push(quote! { (cache_on_disk) });
}
// This uses the span of the query definition for the commas,
@ -398,9 +409,11 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
});
}
add_query_desc_cached_impl(&query, &mut query_description_stream, &mut query_cached_stream);
make_helpers_for_query(&query, &mut helpers);
}
let HelperTokenStreams { description_fns_stream, cache_on_disk_if_fns_stream } = helpers;
TokenStream::from(quote! {
/// Higher-order macro that invokes the specified macro with a prepared
/// list of all query signatures (including modifiers).
@ -430,12 +443,17 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
}
pub mod descs {
use super::*;
#query_description_stream
#description_fns_stream
}
pub mod cached {
// FIXME(Zalathar): Instead of declaring these functions directly, can
// we put them in a macro and then expand that macro downstream in
// `rustc_query_impl`, where the functions are actually used?
pub mod _cache_on_disk_if_fns {
use super::*;
#query_cached_stream
#cache_on_disk_if_fns_stream
}
#errors
})
}

View file

@ -161,7 +161,7 @@ fn find_bundled_library(
tcx: TyCtxt<'_>,
) -> Option<Symbol> {
let sess = tcx.sess;
if let NativeLibKind::Static { bundle: Some(true) | None, whole_archive } = kind
if let NativeLibKind::Static { bundle: Some(true) | None, whole_archive, .. } = kind
&& tcx.crate_types().iter().any(|t| matches!(t, &CrateType::Rlib | CrateType::StaticLib))
&& (sess.opts.unstable_opts.packed_bundled_libs || has_cfg || whole_archive == Some(true))
{

View file

@ -11,7 +11,8 @@ use rustc_middle::bug;
use rustc_middle::metadata::{AmbigModChild, ModChild};
use rustc_middle::middle::exported_symbols::ExportedSymbol;
use rustc_middle::middle::stability::DeprecationEntry;
use rustc_middle::query::{ExternProviders, LocalCrate};
use rustc_middle::queries::ExternProviders;
use rustc_middle::query::LocalCrate;
use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::{self, TyCtxt};
use rustc_middle::util::Providers;
@ -134,8 +135,8 @@ macro_rules! provide_one {
($tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => $compute:block) => {
fn $name<'tcx>(
$tcx: TyCtxt<'tcx>,
def_id_arg: rustc_middle::query::queries::$name::Key<'tcx>,
) -> rustc_middle::query::queries::$name::ProvidedValue<'tcx> {
def_id_arg: rustc_middle::queries::$name::Key<'tcx>,
) -> rustc_middle::queries::$name::ProvidedValue<'tcx> {
let _prof_timer =
$tcx.prof.generic_activity(concat!("metadata_decode_entry_", stringify!($name)));

View file

@ -86,6 +86,8 @@ mod values;
#[macro_use]
pub mod query;
#[macro_use]
pub mod queries;
#[macro_use]
pub mod dep_graph;
// Allows macros to refer to this crate as `::rustc_middle`

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@ use rustc_span::source_map::Spanned;
use crate::mir::interpret::EvalToValTreeResult;
use crate::mir::mono::{MonoItem, NormalizationErrorInMono};
use crate::query::CyclePlaceholder;
use crate::query::plumbing::CyclePlaceholder;
use crate::traits::solve;
use crate::ty::adjustment::CoerceUnsizedInfo;
use crate::ty::{self, Ty, TyCtxt};

File diff suppressed because it is too large Load diff

View file

@ -12,10 +12,10 @@ pub use sealed::IntoQueryParam;
use crate::dep_graph;
use crate::dep_graph::DepKind;
use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
use crate::query::{
use crate::queries::{
ExternProviders, PerQueryVTables, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates,
};
use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
use crate::ty::TyCtxt;
pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;
@ -45,7 +45,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub query_cache: usize,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub execute_query: fn(tcx: TyCtxt<'tcx>, k: C::Key) -> C::Value,
pub compute: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,
pub compute_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,
pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub hash_result: HashResult<C::Value>,
@ -189,8 +189,8 @@ macro_rules! query_ensure_select {
}
macro_rules! query_helper_param_ty {
(DefId) => { impl IntoQueryParam<DefId> };
(LocalDefId) => { impl IntoQueryParam<LocalDefId> };
(DefId) => { impl $crate::query::IntoQueryParam<DefId> };
(LocalDefId) => { impl $crate::query::IntoQueryParam<LocalDefId> };
($K:ty) => { $K };
}
@ -213,7 +213,7 @@ macro_rules! local_key_if_separate_extern {
$($K)*
};
([(separate_provide_extern) $($rest:tt)*] $($K:tt)*) => {
<$($K)* as AsLocalKey>::LocalKey
<$($K)* as $crate::query::AsLocalKey>::LocalKey
};
([$other:tt $($modifiers:tt)*] $($K:tt)*) => {
local_key_if_separate_extern!([$($modifiers)*] $($K)*)
@ -227,8 +227,8 @@ macro_rules! separate_provide_extern_decl {
([(separate_provide_extern) $($rest:tt)*][$name:ident]) => {
for<'tcx> fn(
TyCtxt<'tcx>,
queries::$name::Key<'tcx>,
) -> queries::$name::ProvidedValue<'tcx>
$name::Key<'tcx>,
) -> $name::ProvidedValue<'tcx>
};
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
separate_provide_extern_decl!([$($modifiers)*][$($args)*])
@ -266,94 +266,90 @@ macro_rules! define_callbacks {
[$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,
)*
) => {
$(#[allow(unused_lifetimes)] pub mod $name {
use super::*;
use $crate::query::erase::{self, Erased};
#[allow(unused_lifetimes)]
pub mod queries {
$(pub mod $name {
use super::super::*;
use $crate::query::erase::{self, Erased};
pub type Key<'tcx> = $($K)*;
pub type Value<'tcx> = $V;
pub type Key<'tcx> = $($K)*;
pub type Value<'tcx> = $V;
pub type LocalKey<'tcx> = local_key_if_separate_extern!([$($modifiers)*] $($K)*);
pub type LocalKey<'tcx> = local_key_if_separate_extern!([$($modifiers)*] $($K)*);
/// This type alias specifies the type returned from query providers and the type
/// used for decoding. For regular queries this is the declared returned type `V`,
/// but `arena_cache` will use `<V as ArenaCached>::Provided` instead.
pub type ProvidedValue<'tcx> = query_if_arena!(
[$($modifiers)*]
(<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Provided)
($V)
);
/// This type alias specifies the type returned from query providers and the type
/// used for decoding. For regular queries this is the declared returned type `V`,
/// but `arena_cache` will use `<V as ArenaCached>::Provided` instead.
pub type ProvidedValue<'tcx> = query_if_arena!(
[$($modifiers)*]
(<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Provided)
($V)
);
/// This function takes `ProvidedValue` and converts it to an erased `Value` by
/// allocating it on an arena if the query has the `arena_cache` modifier. The
/// value is then erased and returned. This will happen when computing the query
/// using a provider or decoding a stored result.
#[inline(always)]
pub fn provided_to_erased<'tcx>(
_tcx: TyCtxt<'tcx>,
provided_value: ProvidedValue<'tcx>,
) -> Erased<Value<'tcx>> {
// Store the provided value in an arena and get a reference
// to it, for queries with `arena_cache`.
let value: Value<'tcx> = query_if_arena!([$($modifiers)*]
{
use $crate::query::arena_cached::ArenaCached;
/// This function takes `ProvidedValue` and converts it to an erased `Value` by
/// allocating it on an arena if the query has the `arena_cache` modifier. The
/// value is then erased and returned. This will happen when computing the query
/// using a provider or decoding a stored result.
#[inline(always)]
pub fn provided_to_erased<'tcx>(
_tcx: TyCtxt<'tcx>,
provided_value: ProvidedValue<'tcx>,
) -> Erased<Value<'tcx>> {
// Store the provided value in an arena and get a reference
// to it, for queries with `arena_cache`.
let value: Value<'tcx> = query_if_arena!([$($modifiers)*]
{
use $crate::query::arena_cached::ArenaCached;
if mem::needs_drop::<<$V as ArenaCached<'tcx>>::Allocated>() {
<$V as ArenaCached>::alloc_in_arena(
|v| _tcx.query_system.arenas.$name.alloc(v),
provided_value,
)
} else {
<$V as ArenaCached>::alloc_in_arena(
|v| _tcx.arena.dropless.alloc(v),
provided_value,
)
}
if mem::needs_drop::<<$V as ArenaCached<'tcx>>::Allocated>() {
<$V as ArenaCached>::alloc_in_arena(
|v| _tcx.query_system.arenas.$name.alloc(v),
provided_value,
)
} else {
<$V as ArenaCached>::alloc_in_arena(
|v| _tcx.arena.dropless.alloc(v),
provided_value,
)
}
// Otherwise, the provided value is the value.
(provided_value)
);
erase::erase_val(value)
}
// Otherwise, the provided value is the value.
(provided_value)
);
erase::erase_val(value)
}
pub type Storage<'tcx> = <$($K)* as $crate::query::Key>::Cache<Erased<$V>>;
// Ensure that keys grow no larger than 88 bytes by accident.
// Increase this limit if necessary, but do try to keep the size low if possible
#[cfg(target_pointer_width = "64")]
const _: () = {
if size_of::<Key<'static>>() > 88 {
panic!("{}", concat!(
"the query `",
stringify!($name),
"` has a key type `",
stringify!($($K)*),
"` that is too large"
));
}
};
pub type Storage<'tcx> = <$($K)* as keys::Key>::Cache<Erased<$V>>;
// Ensure that keys grow no larger than 88 bytes by accident.
// Increase this limit if necessary, but do try to keep the size low if possible
#[cfg(target_pointer_width = "64")]
const _: () = {
if size_of::<Key<'static>>() > 88 {
panic!("{}", concat!(
"the query `",
stringify!($name),
"` has a key type `",
stringify!($($K)*),
"` that is too large"
));
}
};
// Ensure that values grow no larger than 64 bytes by accident.
// Increase this limit if necessary, but do try to keep the size low if possible
#[cfg(target_pointer_width = "64")]
#[cfg(not(feature = "rustc_randomized_layouts"))]
const _: () = {
if size_of::<Value<'static>>() > 64 {
panic!("{}", concat!(
"the query `",
stringify!($name),
"` has a value type `",
stringify!($V),
"` that is too large"
));
}
};
})*
}
// Ensure that values grow no larger than 64 bytes by accident.
// Increase this limit if necessary, but do try to keep the size low if possible
#[cfg(target_pointer_width = "64")]
#[cfg(not(feature = "rustc_randomized_layouts"))]
const _: () = {
if size_of::<Value<'static>>() > 64 {
panic!("{}", concat!(
"the query `",
stringify!($name),
"` has a value type `",
stringify!($V),
"` that is too large"
));
}
};
})*
/// Holds per-query arenas for queries with the `arena_cache` modifier.
#[derive(Default)]
@ -371,10 +367,10 @@ macro_rules! define_callbacks {
#[derive(Default)]
pub struct QueryCaches<'tcx> {
$($(#[$attr])* pub $name: queries::$name::Storage<'tcx>,)*
$($(#[$attr])* pub $name: $name::Storage<'tcx>,)*
}
impl<'tcx> TyCtxtEnsureOk<'tcx> {
impl<'tcx> $crate::query::TyCtxtEnsureOk<'tcx> {
$($(#[$attr])*
#[inline(always)]
pub fn $name(
@ -386,13 +382,13 @@ macro_rules! define_callbacks {
self.tcx,
self.tcx.query_system.fns.engine.$name,
&self.tcx.query_system.caches.$name,
key.into_query_param(),
$crate::query::IntoQueryParam::into_query_param(key),
false,
)
})*
}
impl<'tcx> TyCtxtEnsureDone<'tcx> {
impl<'tcx> $crate::query::TyCtxtEnsureDone<'tcx> {
$($(#[$attr])*
#[inline(always)]
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
@ -400,7 +396,7 @@ macro_rules! define_callbacks {
self.tcx,
self.tcx.query_system.fns.engine.$name,
&self.tcx.query_system.caches.$name,
key.into_query_param(),
$crate::query::IntoQueryParam::into_query_param(key),
true,
);
})*
@ -416,7 +412,7 @@ macro_rules! define_callbacks {
})*
}
impl<'tcx> TyCtxtAt<'tcx> {
impl<'tcx> $crate::query::TyCtxtAt<'tcx> {
$($(#[$attr])*
#[inline(always)]
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V
@ -428,7 +424,7 @@ macro_rules! define_callbacks {
self.tcx.query_system.fns.engine.$name,
&self.tcx.query_system.caches.$name,
self.span,
key.into_query_param(),
$crate::query::IntoQueryParam::into_query_param(key),
))
})*
}
@ -438,22 +434,22 @@ macro_rules! define_callbacks {
/// ("Per" just makes this pluralized name more visually distinct.)
pub struct PerQueryVTables<'tcx> {
$(
pub $name: ::rustc_middle::query::plumbing::QueryVTable<'tcx, queries::$name::Storage<'tcx>>,
pub $name: ::rustc_middle::query::plumbing::QueryVTable<'tcx, $name::Storage<'tcx>>,
)*
}
#[derive(Default)]
pub struct QueryStates<'tcx> {
$(
pub $name: QueryState<'tcx, $($K)*>,
pub $name: $crate::query::QueryState<'tcx, $($K)*>,
)*
}
pub struct Providers {
$(pub $name: for<'tcx> fn(
TyCtxt<'tcx>,
queries::$name::LocalKey<'tcx>,
) -> queries::$name::ProvidedValue<'tcx>,)*
$name::LocalKey<'tcx>,
) -> $name::ProvidedValue<'tcx>,)*
}
pub struct ExternProviders {
@ -490,8 +486,8 @@ macro_rules! define_callbacks {
$(pub $name: for<'tcx> fn(
TyCtxt<'tcx>,
Span,
queries::$name::Key<'tcx>,
QueryMode,
$name::Key<'tcx>,
$crate::query::QueryMode,
) -> Option<$crate::query::erase::Erased<$V>>,)*
}
};
@ -499,14 +495,14 @@ macro_rules! define_callbacks {
macro_rules! define_feedable {
($($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => {
$(impl<'tcx, K: IntoQueryParam<$($K)*> + Copy> TyCtxtFeed<'tcx, K> {
$(impl<'tcx, K: $crate::query::IntoQueryParam<$($K)*> + Copy> TyCtxtFeed<'tcx, K> {
$(#[$attr])*
#[inline(always)]
pub fn $name(self, value: queries::$name::ProvidedValue<'tcx>) {
pub fn $name(self, value: $name::ProvidedValue<'tcx>) {
let key = self.key().into_query_param();
let tcx = self.tcx;
let erased_value = queries::$name::provided_to_erased(tcx, value);
let erased_value = $name::provided_to_erased(tcx, value);
let dep_kind: dep_graph::DepKind = dep_graph::dep_kinds::$name;

View file

@ -2,7 +2,7 @@ pub mod bug;
#[derive(Default, Copy, Clone)]
pub struct Providers {
pub queries: crate::query::Providers,
pub extern_queries: crate::query::ExternProviders,
pub queries: crate::queries::Providers,
pub extern_queries: crate::queries::ExternProviders,
pub hooks: crate::hooks::Providers,
}

View file

@ -10,7 +10,6 @@ regex = "1"
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_graphviz = { path = "../rustc_graphviz" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }

View file

@ -1,17 +0,0 @@
mir_dataflow_peek_argument_not_a_local =
rustc_peek: argument was not a local
mir_dataflow_peek_argument_untracked =
rustc_peek: argument untracked
mir_dataflow_peek_bit_not_set =
rustc_peek: bit not set
mir_dataflow_peek_must_be_not_temporary =
dataflow::sanity_check cannot feed a non-temp to rustc_peek
mir_dataflow_peek_must_be_place_or_ref_place =
rustc_peek: argument expression must be either `place` or `&place`
mir_dataflow_stop_after_dataflow_ended_compilation =
stop_after_dataflow ended compilation

View file

@ -2,39 +2,39 @@ use rustc_macros::Diagnostic;
use rustc_span::Span;
#[derive(Diagnostic)]
#[diag(mir_dataflow_stop_after_dataflow_ended_compilation)]
#[diag("stop_after_dataflow ended compilation")]
pub(crate) struct StopAfterDataFlowEndedCompilation;
#[derive(Diagnostic)]
#[diag(mir_dataflow_peek_must_be_place_or_ref_place)]
#[diag("rustc_peek: argument expression must be either `place` or `&place`")]
pub(crate) struct PeekMustBePlaceOrRefPlace {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(mir_dataflow_peek_must_be_not_temporary)]
#[diag("dataflow::sanity_check cannot feed a non-temp to rustc_peek")]
pub(crate) struct PeekMustBeNotTemporary {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(mir_dataflow_peek_bit_not_set)]
#[diag("rustc_peek: bit not set")]
pub(crate) struct PeekBitNotSet {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(mir_dataflow_peek_argument_not_a_local)]
#[diag("rustc_peek: argument was not a local")]
pub(crate) struct PeekArgumentNotALocal {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(mir_dataflow_peek_argument_untracked)]
#[diag("rustc_peek: argument untracked")]
pub(crate) struct PeekArgumentUntracked {
#[primary_span]
pub span: Span,

View file

@ -34,8 +34,6 @@ pub mod rustc_peek;
mod un_derefer;
pub mod value_analysis;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub struct MoveDataTypingEnv<'tcx> {
pub move_data: MoveData<'tcx>,
pub typing_env: ty::TypingEnv<'tcx>,

View file

@ -8,7 +8,6 @@ edition = "2024"
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }

View file

@ -1,82 +0,0 @@
monomorphize_abi_error_disabled_vector_type =
this function {$is_call ->
[true] call
*[false] definition
} uses {$is_scalable ->
[true] scalable
*[false] SIMD
} vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled{$is_call ->
[true] {" "}in the caller
*[false] {""}
}
.label = function {$is_call ->
[true] called
*[false] defined
} here
.help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`)
monomorphize_abi_error_unsupported_unsized_parameter =
this function {$is_call ->
[true] call
*[false] definition
} uses unsized type `{$ty}` which is not supported with the chosen ABI
.label = function {$is_call ->
[true] called
*[false] defined
} here
.help = only rustic ABIs support unsized parameters
monomorphize_abi_error_unsupported_vector_type =
this function {$is_call ->
[true] call
*[false] definition
} uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI
.label = function {$is_call ->
[true] called
*[false] defined
} here
monomorphize_abi_required_target_feature =
this function {$is_call ->
[true] call
*[false] definition
} uses ABI "{$abi}" which requires the `{$required_feature}` target feature, which is not enabled{$is_call ->
[true] {" "}in the caller
*[false] {""}
}
.label = function {$is_call ->
[true] called
*[false] defined
} here
.help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`)
monomorphize_couldnt_dump_mono_stats =
unexpected error occurred while dumping monomorphization stats: {$error}
monomorphize_encountered_error_while_instantiating =
the above error was encountered while instantiating `{$kind} {$instance}`
monomorphize_encountered_error_while_instantiating_global_asm =
the above error was encountered while instantiating `global_asm`
monomorphize_large_assignments =
moving {$size} bytes
.label = value moved from here
.note = the current maximum size is {$limit}, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
monomorphize_no_optimized_mir =
missing optimized MIR for `{$instance}` in the crate `{$crate_name}`
.note = missing optimized MIR for this item (was the crate `{$crate_name}` compiled with `--emit=metadata`?)
monomorphize_recursion_limit =
reached the recursion limit while instantiating `{$instance}`
.note = `{$def_path_str}` defined here
monomorphize_start_not_found = using `fn main` requires the standard library
.help = use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[no_mangle]`
monomorphize_static_initializer_cyclic = static initializer forms a cycle involving `{$head}`
.label = part of this cycle
.note = cyclic static initializers are not supported for target `{$target}`
monomorphize_symbol_already_defined = symbol `{$symbol}` is already defined

View file

@ -1002,11 +1002,12 @@ fn visit_instance_use<'tcx>(
if tcx.should_codegen_locally(panic_instance) {
output.push(create_fn_mono_item(tcx, panic_instance, source));
}
} else if !intrinsic.must_be_overridden {
} else if !intrinsic.must_be_overridden
&& !tcx.sess.replaced_intrinsics.contains(&intrinsic.name)
{
// Codegen the fallback body of intrinsics with fallback bodies.
// We explicitly skip this otherwise to ensure we get a linker error
// if anyone tries to call this intrinsic and the codegen backend did not
// override the implementation.
// We have to skip this otherwise as there's no body to codegen.
// We also skip intrinsics the backend handles, to reduce monomorphizations.
let instance = ty::Instance::new_raw(instance.def_id(), instance.args);
if tcx.should_codegen_locally(instance) {
output.push(create_fn_mono_item(tcx, instance, source));

View file

@ -3,37 +3,41 @@ use rustc_middle::ty::{Instance, Ty};
use rustc_span::{Span, Symbol};
#[derive(Diagnostic)]
#[diag(monomorphize_recursion_limit)]
#[diag("reached the recursion limit while instantiating `{$instance}`")]
pub(crate) struct RecursionLimit<'tcx> {
#[primary_span]
pub span: Span,
pub instance: Instance<'tcx>,
#[note]
#[note("`{$def_path_str}` defined here")]
pub def_span: Span,
pub def_path_str: String,
}
#[derive(Diagnostic)]
#[diag(monomorphize_no_optimized_mir)]
#[diag("missing optimized MIR for `{$instance}` in the crate `{$crate_name}`")]
pub(crate) struct NoOptimizedMir {
#[note]
#[note(
"missing optimized MIR for this item (was the crate `{$crate_name}` compiled with `--emit=metadata`?)"
)]
pub span: Span,
pub crate_name: Symbol,
pub instance: String,
}
#[derive(LintDiagnostic)]
#[diag(monomorphize_large_assignments)]
#[note]
#[diag("moving {$size} bytes")]
#[note(
"the current maximum size is {$limit}, but it can be customized with the move_size_limit attribute: `#![move_size_limit = \"...\"]`"
)]
pub(crate) struct LargeAssignmentsLint {
#[label]
#[label("value moved from here")]
pub span: Span,
pub size: u64,
pub limit: u64,
}
#[derive(Diagnostic)]
#[diag(monomorphize_symbol_already_defined)]
#[diag("symbol `{$symbol}` is already defined")]
pub(crate) struct SymbolAlreadyDefined {
#[primary_span]
pub span: Option<Span>,
@ -41,13 +45,13 @@ pub(crate) struct SymbolAlreadyDefined {
}
#[derive(Diagnostic)]
#[diag(monomorphize_couldnt_dump_mono_stats)]
#[diag("unexpected error occurred while dumping monomorphization stats: {$error}")]
pub(crate) struct CouldntDumpMonoStats {
pub error: String,
}
#[derive(Diagnostic)]
#[diag(monomorphize_encountered_error_while_instantiating)]
#[diag("the above error was encountered while instantiating `{$kind} {$instance}`")]
pub(crate) struct EncounteredErrorWhileInstantiating<'tcx> {
#[primary_span]
pub span: Span,
@ -56,23 +60,41 @@ pub(crate) struct EncounteredErrorWhileInstantiating<'tcx> {
}
#[derive(Diagnostic)]
#[diag(monomorphize_encountered_error_while_instantiating_global_asm)]
#[diag("the above error was encountered while instantiating `global_asm`")]
pub(crate) struct EncounteredErrorWhileInstantiatingGlobalAsm {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(monomorphize_start_not_found)]
#[help]
#[diag("using `fn main` requires the standard library")]
#[help(
"use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[no_mangle]`"
)]
pub(crate) struct StartNotFound;
#[derive(Diagnostic)]
#[diag(monomorphize_abi_error_disabled_vector_type)]
#[help]
#[diag("this function {$is_call ->
[true] call
*[false] definition
} uses {$is_scalable ->
[true] scalable
*[false] SIMD
} vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled{$is_call ->
[true] {\" \"}in the caller
*[false] {\"\"}
}")]
#[help(
"consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable=\"{$required_feature}\")]`)"
)]
pub(crate) struct AbiErrorDisabledVectorType<'a> {
#[primary_span]
#[label]
#[label(
"function {$is_call ->
[true] called
*[false] defined
} here"
)]
pub span: Span,
pub required_feature: &'a str,
pub ty: Ty<'a>,
@ -83,11 +105,21 @@ pub(crate) struct AbiErrorDisabledVectorType<'a> {
}
#[derive(Diagnostic)]
#[diag(monomorphize_abi_error_unsupported_unsized_parameter)]
#[help]
#[diag(
"this function {$is_call ->
[true] call
*[false] definition
} uses unsized type `{$ty}` which is not supported with the chosen ABI"
)]
#[help("only rustic ABIs support unsized parameters")]
pub(crate) struct AbiErrorUnsupportedUnsizedParameter<'a> {
#[primary_span]
#[label]
#[label(
"function {$is_call ->
[true] called
*[false] defined
} here"
)]
pub span: Span,
pub ty: Ty<'a>,
/// Whether this is a problem at a call site or at a declaration.
@ -95,10 +127,20 @@ pub(crate) struct AbiErrorUnsupportedUnsizedParameter<'a> {
}
#[derive(Diagnostic)]
#[diag(monomorphize_abi_error_unsupported_vector_type)]
#[diag(
"this function {$is_call ->
[true] call
*[false] definition
} uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI"
)]
pub(crate) struct AbiErrorUnsupportedVectorType<'a> {
#[primary_span]
#[label]
#[label(
"function {$is_call ->
[true] called
*[false] defined
} here"
)]
pub span: Span,
pub ty: Ty<'a>,
/// Whether this is a problem at a call site or at a declaration.
@ -106,11 +148,24 @@ pub(crate) struct AbiErrorUnsupportedVectorType<'a> {
}
#[derive(Diagnostic)]
#[diag(monomorphize_abi_required_target_feature)]
#[help]
#[diag("this function {$is_call ->
[true] call
*[false] definition
} uses ABI \"{$abi}\" which requires the `{$required_feature}` target feature, which is not enabled{$is_call ->
[true] {\" \"}in the caller
*[false] {\"\"}
}")]
#[help(
"consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable=\"{$required_feature}\")]`)"
)]
pub(crate) struct AbiRequiredTargetFeature<'a> {
#[primary_span]
#[label]
#[label(
"function {$is_call ->
[true] called
*[false] defined
} here"
)]
pub span: Span,
pub required_feature: &'a str,
pub abi: &'a str,
@ -119,12 +174,12 @@ pub(crate) struct AbiRequiredTargetFeature<'a> {
}
#[derive(Diagnostic)]
#[diag(monomorphize_static_initializer_cyclic)]
#[note]
#[diag("static initializer forms a cycle involving `{$head}`")]
#[note("cyclic static initializers are not supported for target `{$target}`")]
pub(crate) struct StaticInitializerCyclic<'a> {
#[primary_span]
pub span: Span,
#[label]
#[label("part of this cycle")]
pub labels: Vec<Span>,
pub head: &'a str,
pub target: &'a str,

View file

@ -20,8 +20,6 @@ mod mono_checks;
mod partitioning;
mod util;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
fn custom_coerce_unsize_info<'tcx>(
tcx: TyCtxtAt<'tcx>,
source_ty: Ty<'tcx>,

View file

@ -87,6 +87,10 @@ passes_deprecated_annotation_has_no_effect =
passes_deprecated_attribute =
deprecated attribute must be paired with either stable or unstable attribute
passes_diagnostic_diagnostic_on_const_only_for_non_const_trait_impls =
`#[diagnostic::on_const]` can only be applied to non-const trait impls
.label = this is a const trait impl
passes_diagnostic_diagnostic_on_const_only_for_trait_impls =
`#[diagnostic::on_const]` can only be applied to trait impls
.label = not a trait impl

View file

@ -67,6 +67,13 @@ struct DiagnosticOnConstOnlyForTraitImpls {
item_span: Span,
}
#[derive(LintDiagnostic)]
#[diag(passes_diagnostic_diagnostic_on_const_only_for_non_const_trait_impls)]
struct DiagnosticOnConstOnlyForNonConstTraitImpls {
#[label]
item_span: Span,
}
fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>) -> Target {
match impl_item.kind {
hir::ImplItemKind::Const(..) => Target::AssocConst,
@ -630,7 +637,16 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
if target == (Target::Impl { of_trait: true }) {
match item.unwrap() {
ItemLike::Item(it) => match it.expect_impl().constness {
Constness::Const => {}
Constness::Const => {
let item_span = self.tcx.hir_span(hir_id);
self.tcx.emit_node_span_lint(
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
hir_id,
attr_span,
DiagnosticOnConstOnlyForNonConstTraitImpls { item_span },
);
return;
}
Constness::NotConst => return,
},
ItemLike::ForeignItem => {}

View file

@ -8,7 +8,6 @@ edition = "2024"
rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hir = { path = "../rustc_hir" }
rustc_macros = { path = "../rustc_macros" }
rustc_middle = { path = "../rustc_middle" }

View file

@ -1,39 +0,0 @@
privacy_field_is_private =
{$len ->
[1] field
*[other] fields
} {$field_names} of {$variant_descr} `{$def_path_str}` {$len ->
[1] is
*[other] are
} private
.label = in this type
privacy_field_is_private_is_update_syntax_label = {$rest_len ->
[1] field
*[other] fields
} {$rest_field_names} {$rest_len ->
[1] is
*[other] are
} private
privacy_field_is_private_label = private field
privacy_from_private_dep_in_public_interface =
{$kind} `{$descr}` from private dependency '{$krate}' in public interface
privacy_in_public_interface = {$vis_descr} {$kind} `{$descr}` in public interface
.label = can't leak {$vis_descr} {$kind}
.visibility_label = `{$descr}` declared as {$vis_descr}
privacy_item_is_private = {$kind} `{$descr}` is private
.label = private {$kind}
privacy_private_interface_or_bounds_lint = {$ty_kind} `{$ty_descr}` is more private than the item `{$item_descr}`
.item_label = {$item_kind} `{$item_descr}` is reachable at visibility `{$item_vis_descr}`
.ty_note = but {$ty_kind} `{$ty_descr}` is only usable at visibility `{$ty_vis_descr}`
privacy_report_effective_visibility = {$descr}
privacy_unnameable_types_lint = {$kind} `{$descr}` is reachable but cannot be named
.label = reachable at visibility `{$reachable_vis}`, but can only be named at visibility `{$reexported_vis}`
privacy_unnamed_item_is_private = {$kind} is private
.label = private {$kind}

View file

@ -4,11 +4,17 @@ use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol};
#[derive(Diagnostic)]
#[diag(privacy_field_is_private, code = E0451)]
#[diag("{$len ->
[1] field
*[other] fields
} {$field_names} of {$variant_descr} `{$def_path_str}` {$len ->
[1] is
*[other] are
} private", code = E0451)]
pub(crate) struct FieldIsPrivate {
#[primary_span]
pub span: MultiSpan,
#[label]
#[label("in this type")]
pub struct_span: Option<Span>,
pub field_names: String,
pub variant_descr: &'static str,
@ -20,14 +26,22 @@ pub(crate) struct FieldIsPrivate {
#[derive(Subdiagnostic)]
pub(crate) enum FieldIsPrivateLabel {
#[label(privacy_field_is_private_is_update_syntax_label)]
#[label(
"{$rest_len ->
[1] field
*[other] fields
} {$rest_field_names} {$rest_len ->
[1] is
*[other] are
} private"
)]
IsUpdateSyntax {
#[primary_span]
span: Span,
rest_field_names: String,
rest_len: usize,
},
#[label(privacy_field_is_private_label)]
#[label("private field")]
Other {
#[primary_span]
span: Span,
@ -35,17 +49,17 @@ pub(crate) enum FieldIsPrivateLabel {
}
#[derive(Diagnostic)]
#[diag(privacy_item_is_private)]
#[diag("{$kind} `{$descr}` is private")]
pub(crate) struct ItemIsPrivate<'a> {
#[primary_span]
#[label]
#[label("private {$kind}")]
pub span: Span,
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
}
#[derive(Diagnostic)]
#[diag(privacy_unnamed_item_is_private)]
#[diag("{$kind} is private")]
pub(crate) struct UnnamedItemIsPrivate {
#[primary_span]
pub span: Span,
@ -53,20 +67,20 @@ pub(crate) struct UnnamedItemIsPrivate {
}
#[derive(Diagnostic)]
#[diag(privacy_in_public_interface, code = E0446)]
#[diag("{$vis_descr} {$kind} `{$descr}` in public interface", code = E0446)]
pub(crate) struct InPublicInterface<'a> {
#[primary_span]
#[label]
#[label("can't leak {$vis_descr} {$kind}")]
pub span: Span,
pub vis_descr: &'static str,
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
#[label(privacy_visibility_label)]
#[label("`{$descr}` declared as {$vis_descr}")]
pub vis_span: Span,
}
#[derive(Diagnostic)]
#[diag(privacy_report_effective_visibility)]
#[diag("{$descr}")]
pub(crate) struct ReportEffectiveVisibility {
#[primary_span]
pub span: Span,
@ -74,7 +88,7 @@ pub(crate) struct ReportEffectiveVisibility {
}
#[derive(LintDiagnostic)]
#[diag(privacy_from_private_dep_in_public_interface)]
#[diag("{$kind} `{$descr}` from private dependency '{$krate}' in public interface")]
pub(crate) struct FromPrivateDependencyInPublicInterface<'a> {
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
@ -82,9 +96,11 @@ pub(crate) struct FromPrivateDependencyInPublicInterface<'a> {
}
#[derive(LintDiagnostic)]
#[diag(privacy_unnameable_types_lint)]
#[diag("{$kind} `{$descr}` is reachable but cannot be named")]
pub(crate) struct UnnameableTypesLint<'a> {
#[label]
#[label(
"reachable at visibility `{$reachable_vis}`, but can only be named at visibility `{$reexported_vis}`"
)]
pub span: Span,
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
@ -96,14 +112,14 @@ pub(crate) struct UnnameableTypesLint<'a> {
// They will replace private-in-public errors and compatibility lints in future.
// See https://rust-lang.github.io/rfcs/2145-type-privacy.html for more details.
#[derive(LintDiagnostic)]
#[diag(privacy_private_interface_or_bounds_lint)]
#[diag("{$ty_kind} `{$ty_descr}` is more private than the item `{$item_descr}`")]
pub(crate) struct PrivateInterfacesOrBoundsLint<'a> {
#[label(privacy_item_label)]
#[label("{$item_kind} `{$item_descr}` is reachable at visibility `{$item_vis_descr}`")]
pub item_span: Span,
pub item_kind: &'a str,
pub item_descr: DiagArgFromDisplay<'a>,
pub item_vis_descr: &'a str,
#[note(privacy_ty_note)]
#[note("but {$ty_kind} `{$ty_descr}` is only usable at visibility `{$ty_vis_descr}`")]
pub ty_span: Span,
pub ty_kind: &'a str,
pub ty_descr: DiagArgFromDisplay<'a>,

View file

@ -39,8 +39,6 @@ use rustc_span::hygiene::Transparency;
use rustc_span::{Ident, Span, Symbol, sym};
use tracing::debug;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
////////////////////////////////////////////////////////////////////////////////
// Generic infrastructure used to implement specific visitors below.
////////////////////////////////////////////////////////////////////////////////

View file

@ -13,11 +13,12 @@ use rustc_data_structures::stable_hasher::HashStable;
use rustc_data_structures::sync::AtomicU64;
use rustc_middle::arena::Arena;
use rustc_middle::dep_graph::{self, DepKind, DepKindVTable, DepNodeIndex};
use rustc_middle::queries::{
self, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates,
};
use rustc_middle::query::AsLocalKey;
use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
use rustc_middle::query::plumbing::{QuerySystem, QuerySystemFns, QueryVTable};
use rustc_middle::query::{
AsLocalKey, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates, queries,
};
use rustc_middle::ty::TyCtxt;
use rustc_query_system::Value;
use rustc_query_system::dep_graph::SerializedDepNodeIndex;
@ -28,7 +29,7 @@ use rustc_query_system::query::{
};
use rustc_span::{ErrorGuaranteed, Span};
use crate::plumbing::{__rust_begin_short_backtrace, encode_all_query_results, try_mark_green};
use crate::plumbing::{encode_all_query_results, try_mark_green};
use crate::profiling_support::QueryKeyStringCache;
#[macro_use]
@ -122,7 +123,7 @@ where
#[inline(always)]
fn compute(self, qcx: QueryCtxt<'tcx>, key: Self::Key) -> Self::Value {
(self.vtable.compute)(qcx.tcx, key)
(self.vtable.compute_fn)(qcx.tcx, key)
}
#[inline(always)]

View file

@ -300,15 +300,31 @@ macro_rules! call_provider {
};
}
macro_rules! should_ever_cache_on_disk {
([]$yes:tt $no:tt) => {{
/// Expands to one of two token trees, depending on whether the current query
/// has the `cache_on_disk_if` modifier.
macro_rules! if_cache_on_disk {
([] $yes:tt $no:tt) => {
$no
}};
([(cache) $($rest:tt)*]$yes:tt $no:tt) => {{
};
// The `cache_on_disk_if` modifier generates a synthetic `(cache_on_disk)`,
// modifier, for use by this macro and similar macros.
([(cache_on_disk) $($rest:tt)*] $yes:tt $no:tt) => {
$yes
}};
([$other:tt $($modifiers:tt)*]$yes:tt $no:tt) => {
should_ever_cache_on_disk!([$($modifiers)*]$yes $no)
};
([$other:tt $($modifiers:tt)*] $yes:tt $no:tt) => {
if_cache_on_disk!([$($modifiers)*] $yes $no)
};
}
/// Conditionally expands to some token trees, if the current query has the
/// `cache_on_disk_if` modifier.
macro_rules! item_if_cache_on_disk {
([] $($item:tt)*) => {};
([(cache_on_disk) $($rest:tt)*] $($item:tt)*) => {
$($item)*
};
([$other:tt $($modifiers:tt)*] $($item:tt)*) => {
item_if_cache_on_disk! { [$($modifiers)*] $($item)* }
};
}
@ -544,40 +560,6 @@ where
}
}
macro_rules! item_if_cached {
([] $tokens:tt) => {};
([(cache) $($rest:tt)*] { $($tokens:tt)* }) => {
$($tokens)*
};
([$other:tt $($modifiers:tt)*] $tokens:tt) => {
item_if_cached! { [$($modifiers)*] $tokens }
};
}
macro_rules! expand_if_cached {
([], $tokens:expr) => {{
None
}};
([(cache) $($rest:tt)*], $tokens:expr) => {{
Some($tokens)
}};
([$other:tt $($modifiers:tt)*], $tokens:expr) => {
expand_if_cached!([$($modifiers)*], $tokens)
};
}
/// Don't show the backtrace for query system by default
/// use `RUST_BACKTRACE=full` to show all the backtraces
#[inline(never)]
pub(crate) fn __rust_begin_short_backtrace<F, T>(f: F) -> T
where
F: FnOnce() -> T,
{
let result = f();
std::hint::black_box(());
result
}
// NOTE: `$V` isn't used here, but we still need to match on it so it can be passed to other macros
// invoked by `rustc_with_all_queries`.
macro_rules! define_queries {
@ -636,6 +618,32 @@ macro_rules! define_queries {
}
}
/// Defines a `compute` function for this query, to be used as a
/// function pointer in the query's vtable.
mod compute_fn {
use super::*;
use ::rustc_middle::queries::$name::{Key, Value, provided_to_erased};
/// This function would be named `compute`, but we also want it
/// to mark the boundaries of an omitted region in backtraces.
#[inline(never)]
pub(crate) fn __rust_begin_short_backtrace<'tcx>(
tcx: TyCtxt<'tcx>,
key: Key<'tcx>,
) -> Erased<Value<'tcx>> {
#[cfg(debug_assertions)]
let _guard = tracing::span!(tracing::Level::TRACE, stringify!($name), ?key).entered();
// Call the actual provider function for this query.
let provided_value = call_provider!([$($modifiers)*][tcx, $name, key]);
rustc_middle::ty::print::with_reduced_queries!({
tracing::trace!(?provided_value);
});
provided_to_erased(tcx, provided_value)
}
}
pub(crate) fn make_query_vtable<'tcx>()
-> QueryVTable<'tcx, queries::$name::Storage<'tcx>>
{
@ -646,32 +654,17 @@ macro_rules! define_queries {
cycle_error_handling: cycle_error_handling!([$($modifiers)*]),
query_state: std::mem::offset_of!(QueryStates<'tcx>, $name),
query_cache: std::mem::offset_of!(QueryCaches<'tcx>, $name),
will_cache_on_disk_for_key_fn: should_ever_cache_on_disk!([$($modifiers)*] {
Some(::rustc_middle::query::cached::$name)
will_cache_on_disk_for_key_fn: if_cache_on_disk!([$($modifiers)*] {
Some(::rustc_middle::queries::_cache_on_disk_if_fns::$name)
} {
None
}),
execute_query: |tcx, key| erase::erase_val(tcx.$name(key)),
compute: |tcx, key| {
#[cfg(debug_assertions)]
let _guard = tracing::span!(tracing::Level::TRACE, stringify!($name), ?key).entered();
__rust_begin_short_backtrace(||
queries::$name::provided_to_erased(
tcx,
{
let ret = call_provider!([$($modifiers)*][tcx, $name, key]);
rustc_middle::ty::print::with_reduced_queries!({
tracing::trace!(?ret);
});
ret
}
)
)
},
try_load_from_disk_fn: should_ever_cache_on_disk!([$($modifiers)*] {
compute_fn: self::compute_fn::__rust_begin_short_backtrace,
try_load_from_disk_fn: if_cache_on_disk!([$($modifiers)*] {
Some(|tcx, key, prev_index, index| {
// Check the `cache_on_disk_if` condition for this key.
if !::rustc_middle::query::cached::$name(tcx, key) {
if !::rustc_middle::queries::_cache_on_disk_if_fns::$name(tcx, key) {
return None;
}
@ -684,9 +677,9 @@ macro_rules! define_queries {
} {
None
}),
is_loadable_from_disk_fn: should_ever_cache_on_disk!([$($modifiers)*] {
is_loadable_from_disk_fn: if_cache_on_disk!([$($modifiers)*] {
Some(|tcx, key, index| -> bool {
::rustc_middle::query::cached::$name(tcx, key) &&
::rustc_middle::queries::_cache_on_disk_if_fns::$name(tcx, key) &&
$crate::plumbing::loadable_from_disk(tcx, index)
})
} {
@ -746,7 +739,7 @@ macro_rules! define_queries {
let make_frame = |tcx, key| {
let kind = rustc_middle::dep_graph::dep_kinds::$name;
let name = stringify!($name);
$crate::plumbing::create_query_frame(tcx, rustc_middle::query::descs::$name, key, kind, name)
$crate::plumbing::create_query_frame(tcx, queries::descs::$name, key, kind, name)
};
// Call `gather_active_jobs_inner` to do the actual work.
@ -781,7 +774,7 @@ macro_rules! define_queries {
)
}
item_if_cached! { [$($modifiers)*] {
item_if_cache_on_disk! { [$($modifiers)*]
pub(crate) fn encode_query_results<'tcx>(
tcx: TyCtxt<'tcx>,
encoder: &mut CacheEncoder<'_, 'tcx>,
@ -794,7 +787,7 @@ macro_rules! define_queries {
query_result_index,
)
}
}}
}
pub(crate) fn query_key_hash_verify<'tcx>(tcx: TyCtxt<'tcx>) {
$crate::plumbing::query_key_hash_verify(
@ -816,8 +809,8 @@ macro_rules! define_queries {
}
}
pub fn make_query_vtables<'tcx>() -> ::rustc_middle::query::PerQueryVTables<'tcx> {
::rustc_middle::query::PerQueryVTables {
pub fn make_query_vtables<'tcx>() -> queries::PerQueryVTables<'tcx> {
queries::PerQueryVTables {
$(
$name: query_impl::$name::make_query_vtable(),
)*
@ -848,7 +841,15 @@ macro_rules! define_queries {
&mut CacheEncoder<'_, 'tcx>,
&mut EncodedDepNodeIndex)
>
] = &[$(expand_if_cached!([$($modifiers)*], query_impl::$name::encode_query_results)),*];
] = &[
$(
if_cache_on_disk!([$($modifiers)*] {
Some(query_impl::$name::encode_query_results)
} {
None
})
),*
];
const QUERY_KEY_HASH_VERIFY: &[
for<'tcx> fn(TyCtxt<'tcx>)

View file

@ -12,7 +12,6 @@ rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_fs_util = { path = "../rustc_fs_util" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" }

View file

@ -1,149 +0,0 @@
session_apple_deployment_target_invalid =
failed to parse deployment target specified in {$env_var}: {$error}
session_apple_deployment_target_too_low =
deployment target in {$env_var} was set to {$version}, but the minimum supported by `rustc` is {$os_min}
session_binary_float_literal_not_supported = binary float literal is not supported
session_branch_protection_requires_aarch64 = `-Zbranch-protection` is only supported on aarch64
session_cannot_enable_crt_static_linux = sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`
session_cannot_mix_and_match_sanitizers = `-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}`
session_cli_feature_diagnostic_help =
add `-Zcrate-attr="feature({$feature})"` to the command-line options to enable
session_crate_name_empty = crate name must not be empty
session_embed_source_insufficient_dwarf_version = `-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}
session_embed_source_requires_debug_info = `-Zembed-source=y` requires debug information to be enabled
session_expr_parentheses_needed = parentheses are required to parse this as an expression
session_failed_to_create_profiler = failed to create profiler: {$err}
session_feature_diagnostic_for_issue =
see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information
session_feature_diagnostic_help =
add `#![feature({$feature})]` to the crate attributes to enable
session_feature_diagnostic_suggestion =
add `#![feature({$feature})]` to the crate attributes to enable
session_feature_suggest_upgrade_compiler =
this compiler was built on {$date}; consider upgrading it if it is out of date
session_file_is_not_writeable = output file {$file} is not writeable -- check its permissions
session_file_write_fail = failed to write `{$path}` due to error `{$err}`
session_function_return_requires_x86_or_x86_64 = `-Zfunction-return` (except `keep`) is only supported on x86 and x86_64
session_function_return_thunk_extern_requires_non_large_code_model = `-Zfunction-return=thunk-extern` is only supported on non-large code models
session_hexadecimal_float_literal_not_supported = hexadecimal float literal is not supported
session_incompatible_linker_flavor = linker flavor `{$flavor}` is incompatible with the current target
.note = compatible flavors are: {$compatible_list}
session_indirect_branch_cs_prefix_requires_x86_or_x86_64 = `-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64
session_instrumentation_not_supported = {$us} instrumentation is not supported for this target
session_int_literal_too_large = integer literal is too large
.note = value exceeds limit of `{$limit}`
session_invalid_character_in_crate_name = invalid character {$character} in crate name: `{$crate_name}`
session_invalid_float_literal_suffix = invalid suffix `{$suffix}` for float literal
.label = invalid suffix `{$suffix}`
.help = valid suffixes are `f32` and `f64`
session_invalid_float_literal_width = invalid width `{$width}` for float literal
.help = valid widths are 32 and 64
session_invalid_int_literal_width = invalid width `{$width}` for integer literal
.help = valid widths are 8, 16, 32, 64 and 128
session_invalid_literal_suffix = suffixes on {$kind} literals are invalid
.label = invalid suffix `{$suffix}`
session_invalid_num_literal_base_prefix = invalid base prefix for number literal
.note = base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
.suggestion = try making the prefix lowercase
session_invalid_num_literal_suffix = invalid suffix `{$suffix}` for number literal
.label = invalid suffix `{$suffix}`
.help = the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
session_linker_plugin_lto_windows_not_supported = linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets
session_must_be_name_of_associated_function = must be a name of an associated function
session_not_circumvent_feature = `-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine
session_not_supported = not supported
session_octal_float_literal_not_supported = octal float literal is not supported
session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C profile-sample-use` does not exist
session_profile_use_file_does_not_exist = file `{$path}` passed to `-C profile-use` does not exist
session_sanitizer_cfi_canonical_jump_tables_requires_cfi = `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`
session_sanitizer_cfi_generalize_pointers_requires_cfi = `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`
session_sanitizer_cfi_normalize_integers_requires_cfi = `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`
session_sanitizer_cfi_requires_lto = `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`
session_sanitizer_cfi_requires_single_codegen_unit = `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`
session_sanitizer_kcfi_arity_requires_kcfi = `-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`
session_sanitizer_kcfi_requires_panic_abort = `-Z sanitizer=kcfi` requires `-C panic=abort`
session_sanitizer_not_supported = {$us} sanitizer is not supported for this target
session_sanitizers_not_supported = {$us} sanitizers are not supported for this target
session_skipping_const_checks = skipping const checks
session_soft_float_deprecated =
`-Csoft-float` is unsound and deprecated; use a corresponding *eabi target instead
.note = it will be removed or ignored in a future version of Rust
session_soft_float_deprecated_issue = see issue #129893 <https://github.com/rust-lang/rust/issues/129893> for more information
session_soft_float_ignored =
`-Csoft-float` is ignored on this target; it only has an effect on *eabihf targets
.note = this may become a hard error in a future version of Rust
session_split_debuginfo_unstable_platform = `-Csplit-debuginfo={$debuginfo}` is unstable on this platform
session_split_lto_unit_requires_lto = `-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`
session_target_requires_unwind_tables = target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`
session_target_small_data_threshold_not_supported = `-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored
session_target_stack_protector_not_supported = `-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored
session_unexpected_builtin_cfg = unexpected `--cfg {$cfg}` flag
.controlled_by = config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`
.incoherent = manually setting a built-in cfg can and does create incoherent behaviors
session_unleashed_feature_help_named = skipping check for `{$gate}` feature
session_unleashed_feature_help_unnamed = skipping check that does not even have a feature gate
session_unstable_virtual_function_elimination = `-Zvirtual-function-elimination` requires `-Clto`
session_unsupported_dwarf_version = requested DWARF version {$dwarf_version} is not supported
session_unsupported_dwarf_version_help = supported DWARF versions are 2, 3, 4 and 5
session_unsupported_reg_struct_return_arch = `-Zreg-struct-return` is only supported on x86
session_unsupported_regparm = `-Zregparm={$regparm}` is unsupported (valid values 0-3)
session_unsupported_regparm_arch = `-Zregparm=N` is only supported on x86

View file

@ -53,7 +53,9 @@ fn parse_native_lib(cx: &ParseNativeLibCx<'_>, value: &str) -> NativeLib {
let NativeLibParts { kind, modifiers, name, new_name } = split_native_lib_value(value);
let kind = kind.map_or(NativeLibKind::Unspecified, |kind| match kind {
"static" => NativeLibKind::Static { bundle: None, whole_archive: None },
"static" => {
NativeLibKind::Static { bundle: None, whole_archive: None, export_symbols: None }
}
"dylib" => NativeLibKind::Dylib { as_needed: None },
"framework" => NativeLibKind::Framework { as_needed: None },
"link-arg" => {
@ -105,7 +107,7 @@ fn parse_and_apply_modifier(cx: &ParseNativeLibCx<'_>, modifier: &str, native_li
Some(("-", m)) => (m, false),
_ => cx.early_dcx.early_fatal(
"invalid linking modifier syntax, expected '+' or '-' prefix \
before one of: bundle, verbatim, whole-archive, as-needed",
before one of: bundle, verbatim, whole-archive, as-needed, export-symbols",
),
};
@ -125,6 +127,13 @@ fn parse_and_apply_modifier(cx: &ParseNativeLibCx<'_>, modifier: &str, native_li
("bundle", _) => early_dcx
.early_fatal("linking modifier `bundle` is only compatible with `static` linking kind"),
("export-symbols", NativeLibKind::Static { export_symbols, .. }) => {
assign_modifier(export_symbols)
}
("export-symbols", _) => early_dcx.early_fatal(
"linking modifier `export-symbols` is only compatible with `static` linking kind",
),
("verbatim", _) => assign_modifier(&mut native_lib.verbatim),
("whole-archive", NativeLibKind::Static { whole_archive, .. }) => {
@ -151,7 +160,7 @@ fn parse_and_apply_modifier(cx: &ParseNativeLibCx<'_>, modifier: &str, native_li
_ => early_dcx.early_fatal(format!(
"unknown linking modifier `{modifier}`, expected one \
of: bundle, verbatim, whole-archive, as-needed"
of: bundle, verbatim, whole-archive, as-needed, export-symbols"
)),
}
}

View file

@ -15,9 +15,11 @@ use crate::parse::ParseSess;
#[derive(Diagnostic)]
pub(crate) enum AppleDeploymentTarget {
#[diag(session_apple_deployment_target_invalid)]
#[diag("failed to parse deployment target specified in {$env_var}: {$error}")]
Invalid { env_var: &'static str, error: ParseIntError },
#[diag(session_apple_deployment_target_too_low)]
#[diag(
"deployment target in {$env_var} was set to {$version}, but the minimum supported by `rustc` is {$os_min}"
)]
TooLow { env_var: &'static str, version: String, os_min: String },
}
@ -34,13 +36,13 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for FeatureGateError {
}
#[derive(Subdiagnostic)]
#[note(session_feature_diagnostic_for_issue)]
#[note("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")]
pub(crate) struct FeatureDiagnosticForIssue {
pub(crate) n: NonZero<u32>,
}
#[derive(Subdiagnostic)]
#[note(session_feature_suggest_upgrade_compiler)]
#[note("this compiler was built on {$date}; consider upgrading it if it is out of date")]
pub(crate) struct SuggestUpgradeCompiler {
date: &'static str,
}
@ -58,14 +60,14 @@ impl SuggestUpgradeCompiler {
}
#[derive(Subdiagnostic)]
#[help(session_feature_diagnostic_help)]
#[help("add `#![feature({$feature})]` to the crate attributes to enable")]
pub(crate) struct FeatureDiagnosticHelp {
pub(crate) feature: Symbol,
}
#[derive(Subdiagnostic)]
#[suggestion(
session_feature_diagnostic_suggestion,
"add `#![feature({$feature})]` to the crate attributes to enable",
applicability = "maybe-incorrect",
code = "#![feature({feature})]\n"
)]
@ -76,169 +78,181 @@ pub struct FeatureDiagnosticSuggestion {
}
#[derive(Subdiagnostic)]
#[help(session_cli_feature_diagnostic_help)]
#[help("add `-Zcrate-attr=\"feature({$feature})\"` to the command-line options to enable")]
pub(crate) struct CliFeatureDiagnosticHelp {
pub(crate) feature: Symbol,
}
#[derive(Diagnostic)]
#[diag(session_must_be_name_of_associated_function)]
#[diag("must be a name of an associated function")]
pub struct MustBeNameOfAssociatedFunction {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(session_not_circumvent_feature)]
#[diag(
"`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine"
)]
pub(crate) struct NotCircumventFeature;
#[derive(Diagnostic)]
#[diag(session_linker_plugin_lto_windows_not_supported)]
#[diag(
"linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets"
)]
pub(crate) struct LinkerPluginToWindowsNotSupported;
#[derive(Diagnostic)]
#[diag(session_profile_use_file_does_not_exist)]
#[diag("file `{$path}` passed to `-C profile-use` does not exist")]
pub(crate) struct ProfileUseFileDoesNotExist<'a> {
pub(crate) path: &'a std::path::Path,
}
#[derive(Diagnostic)]
#[diag(session_profile_sample_use_file_does_not_exist)]
#[diag("file `{$path}` passed to `-C profile-sample-use` does not exist")]
pub(crate) struct ProfileSampleUseFileDoesNotExist<'a> {
pub(crate) path: &'a std::path::Path,
}
#[derive(Diagnostic)]
#[diag(session_target_requires_unwind_tables)]
#[diag("target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`")]
pub(crate) struct TargetRequiresUnwindTables;
#[derive(Diagnostic)]
#[diag(session_instrumentation_not_supported)]
#[diag("{$us} instrumentation is not supported for this target")]
pub(crate) struct InstrumentationNotSupported {
pub(crate) us: String,
}
#[derive(Diagnostic)]
#[diag(session_sanitizer_not_supported)]
#[diag("{$us} sanitizer is not supported for this target")]
pub(crate) struct SanitizerNotSupported {
pub(crate) us: String,
}
#[derive(Diagnostic)]
#[diag(session_sanitizers_not_supported)]
#[diag("{$us} sanitizers are not supported for this target")]
pub(crate) struct SanitizersNotSupported {
pub(crate) us: String,
}
#[derive(Diagnostic)]
#[diag(session_cannot_mix_and_match_sanitizers)]
#[diag("`-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}`")]
pub(crate) struct CannotMixAndMatchSanitizers {
pub(crate) first: String,
pub(crate) second: String,
}
#[derive(Diagnostic)]
#[diag(session_cannot_enable_crt_static_linux)]
#[diag(
"sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`"
)]
pub(crate) struct CannotEnableCrtStaticLinux;
#[derive(Diagnostic)]
#[diag(session_sanitizer_cfi_requires_lto)]
#[diag("`-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`")]
pub(crate) struct SanitizerCfiRequiresLto;
#[derive(Diagnostic)]
#[diag(session_sanitizer_cfi_requires_single_codegen_unit)]
#[diag("`-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`")]
pub(crate) struct SanitizerCfiRequiresSingleCodegenUnit;
#[derive(Diagnostic)]
#[diag(session_sanitizer_cfi_canonical_jump_tables_requires_cfi)]
#[diag("`-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`")]
pub(crate) struct SanitizerCfiCanonicalJumpTablesRequiresCfi;
#[derive(Diagnostic)]
#[diag(session_sanitizer_cfi_generalize_pointers_requires_cfi)]
#[diag("`-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
pub(crate) struct SanitizerCfiGeneralizePointersRequiresCfi;
#[derive(Diagnostic)]
#[diag(session_sanitizer_cfi_normalize_integers_requires_cfi)]
#[diag("`-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
pub(crate) struct SanitizerCfiNormalizeIntegersRequiresCfi;
#[derive(Diagnostic)]
#[diag(session_sanitizer_kcfi_arity_requires_kcfi)]
#[diag("`-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`")]
pub(crate) struct SanitizerKcfiArityRequiresKcfi;
#[derive(Diagnostic)]
#[diag(session_sanitizer_kcfi_requires_panic_abort)]
#[diag("`-Z sanitizer=kcfi` requires `-C panic=abort`")]
pub(crate) struct SanitizerKcfiRequiresPanicAbort;
#[derive(Diagnostic)]
#[diag(session_split_lto_unit_requires_lto)]
#[diag("`-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`")]
pub(crate) struct SplitLtoUnitRequiresLto;
#[derive(Diagnostic)]
#[diag(session_unstable_virtual_function_elimination)]
#[diag("`-Zvirtual-function-elimination` requires `-Clto`")]
pub(crate) struct UnstableVirtualFunctionElimination;
#[derive(Diagnostic)]
#[diag(session_unsupported_dwarf_version)]
#[help(session_unsupported_dwarf_version_help)]
#[diag("requested DWARF version {$dwarf_version} is not supported")]
#[help("supported DWARF versions are 2, 3, 4 and 5")]
pub(crate) struct UnsupportedDwarfVersion {
pub(crate) dwarf_version: u32,
}
#[derive(Diagnostic)]
#[diag(session_embed_source_insufficient_dwarf_version)]
#[diag(
"`-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}"
)]
pub(crate) struct EmbedSourceInsufficientDwarfVersion {
pub(crate) dwarf_version: u32,
}
#[derive(Diagnostic)]
#[diag(session_embed_source_requires_debug_info)]
#[diag("`-Zembed-source=y` requires debug information to be enabled")]
pub(crate) struct EmbedSourceRequiresDebugInfo;
#[derive(Diagnostic)]
#[diag(session_target_stack_protector_not_supported)]
#[diag(
"`-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored"
)]
pub(crate) struct StackProtectorNotSupportedForTarget<'a> {
pub(crate) stack_protector: StackProtector,
pub(crate) target_triple: &'a TargetTuple,
}
#[derive(Diagnostic)]
#[diag(session_target_small_data_threshold_not_supported)]
#[diag(
"`-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored"
)]
pub(crate) struct SmallDataThresholdNotSupportedForTarget<'a> {
pub(crate) target_triple: &'a TargetTuple,
}
#[derive(Diagnostic)]
#[diag(session_branch_protection_requires_aarch64)]
#[diag("`-Zbranch-protection` is only supported on aarch64")]
pub(crate) struct BranchProtectionRequiresAArch64;
#[derive(Diagnostic)]
#[diag(session_split_debuginfo_unstable_platform)]
#[diag("`-Csplit-debuginfo={$debuginfo}` is unstable on this platform")]
pub(crate) struct SplitDebugInfoUnstablePlatform {
pub(crate) debuginfo: SplitDebuginfo,
}
#[derive(Diagnostic)]
#[diag(session_file_is_not_writeable)]
#[diag("output file {$file} is not writeable -- check its permissions")]
pub(crate) struct FileIsNotWriteable<'a> {
pub(crate) file: &'a std::path::Path,
}
#[derive(Diagnostic)]
#[diag(session_file_write_fail)]
#[diag("failed to write `{$path}` due to error `{$err}`")]
pub(crate) struct FileWriteFail<'a> {
pub(crate) path: &'a std::path::Path,
pub(crate) err: String,
}
#[derive(Diagnostic)]
#[diag(session_crate_name_empty)]
#[diag("crate name must not be empty")]
pub(crate) struct CrateNameEmpty {
#[primary_span]
pub(crate) span: Option<Span>,
}
#[derive(Diagnostic)]
#[diag(session_invalid_character_in_crate_name)]
#[diag("invalid character {$character} in crate name: `{$crate_name}`")]
pub(crate) struct InvalidCharacterInCrateName {
#[primary_span]
pub(crate) span: Option<Span>,
@ -247,7 +261,10 @@ pub(crate) struct InvalidCharacterInCrateName {
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(session_expr_parentheses_needed, applicability = "machine-applicable")]
#[multipart_suggestion(
"parentheses are required to parse this as an expression",
applicability = "machine-applicable"
)]
pub struct ExprParenthesesNeeded {
#[suggestion_part(code = "(")]
left: Span,
@ -262,7 +279,7 @@ impl ExprParenthesesNeeded {
}
#[derive(Diagnostic)]
#[diag(session_skipping_const_checks)]
#[diag("skipping const checks")]
pub(crate) struct SkippingConstChecks {
#[subdiagnostic]
pub(crate) unleashed_features: Vec<UnleashedFeatureHelp>,
@ -270,13 +287,13 @@ pub(crate) struct SkippingConstChecks {
#[derive(Subdiagnostic)]
pub(crate) enum UnleashedFeatureHelp {
#[help(session_unleashed_feature_help_named)]
#[help("skipping check for `{$gate}` feature")]
Named {
#[primary_span]
span: Span,
gate: Symbol,
},
#[help(session_unleashed_feature_help_unnamed)]
#[help("skipping check that does not even have a feature gate")]
Unnamed {
#[primary_span]
span: Span,
@ -284,10 +301,10 @@ pub(crate) enum UnleashedFeatureHelp {
}
#[derive(Diagnostic)]
#[diag(session_invalid_literal_suffix)]
#[diag("suffixes on {$kind} literals are invalid")]
struct InvalidLiteralSuffix<'a> {
#[primary_span]
#[label]
#[label("invalid suffix `{$suffix}`")]
span: Span,
// FIXME(#100717)
kind: &'a str,
@ -295,8 +312,8 @@ struct InvalidLiteralSuffix<'a> {
}
#[derive(Diagnostic)]
#[diag(session_invalid_int_literal_width)]
#[help]
#[diag("invalid width `{$width}` for integer literal")]
#[help("valid widths are 8, 16, 32, 64 and 128")]
struct InvalidIntLiteralWidth {
#[primary_span]
span: Span,
@ -304,28 +321,32 @@ struct InvalidIntLiteralWidth {
}
#[derive(Diagnostic)]
#[diag(session_invalid_num_literal_base_prefix)]
#[note]
#[diag("invalid base prefix for number literal")]
#[note("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")]
struct InvalidNumLiteralBasePrefix {
#[primary_span]
#[suggestion(applicability = "maybe-incorrect", code = "{fixed}")]
#[suggestion(
"try making the prefix lowercase",
applicability = "maybe-incorrect",
code = "{fixed}"
)]
span: Span,
fixed: String,
}
#[derive(Diagnostic)]
#[diag(session_invalid_num_literal_suffix)]
#[help]
#[diag("invalid suffix `{$suffix}` for number literal")]
#[help("the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)")]
struct InvalidNumLiteralSuffix {
#[primary_span]
#[label]
#[label("invalid suffix `{$suffix}`")]
span: Span,
suffix: String,
}
#[derive(Diagnostic)]
#[diag(session_invalid_float_literal_width)]
#[help]
#[diag("invalid width `{$width}` for float literal")]
#[help("valid widths are 32 and 64")]
struct InvalidFloatLiteralWidth {
#[primary_span]
span: Span,
@ -333,18 +354,18 @@ struct InvalidFloatLiteralWidth {
}
#[derive(Diagnostic)]
#[diag(session_invalid_float_literal_suffix)]
#[help]
#[diag("invalid suffix `{$suffix}` for float literal")]
#[help("valid suffixes are `f32` and `f64`")]
struct InvalidFloatLiteralSuffix {
#[primary_span]
#[label]
#[label("invalid suffix `{$suffix}`")]
span: Span,
suffix: String,
}
#[derive(Diagnostic)]
#[diag(session_int_literal_too_large)]
#[note]
#[diag("integer literal is too large")]
#[note("value exceeds limit of `{$limit}`")]
struct IntLiteralTooLarge {
#[primary_span]
span: Span,
@ -352,26 +373,26 @@ struct IntLiteralTooLarge {
}
#[derive(Diagnostic)]
#[diag(session_hexadecimal_float_literal_not_supported)]
#[diag("hexadecimal float literal is not supported")]
struct HexadecimalFloatLiteralNotSupported {
#[primary_span]
#[label(session_not_supported)]
#[label("not supported")]
span: Span,
}
#[derive(Diagnostic)]
#[diag(session_octal_float_literal_not_supported)]
#[diag("octal float literal is not supported")]
struct OctalFloatLiteralNotSupported {
#[primary_span]
#[label(session_not_supported)]
#[label("not supported")]
span: Span,
}
#[derive(Diagnostic)]
#[diag(session_binary_float_literal_not_supported)]
#[diag("binary float literal is not supported")]
struct BinaryFloatLiteralNotSupported {
#[primary_span]
#[label(session_not_supported)]
#[label("not supported")]
span: Span,
}
@ -457,60 +478,60 @@ pub fn create_lit_error(psess: &ParseSess, err: LitError, lit: token::Lit, span:
}
#[derive(Diagnostic)]
#[diag(session_incompatible_linker_flavor)]
#[note]
#[diag("linker flavor `{$flavor}` is incompatible with the current target")]
#[note("compatible flavors are: {$compatible_list}")]
pub(crate) struct IncompatibleLinkerFlavor {
pub(crate) flavor: &'static str,
pub(crate) compatible_list: String,
}
#[derive(Diagnostic)]
#[diag(session_function_return_requires_x86_or_x86_64)]
#[diag("`-Zfunction-return` (except `keep`) is only supported on x86 and x86_64")]
pub(crate) struct FunctionReturnRequiresX86OrX8664;
#[derive(Diagnostic)]
#[diag(session_function_return_thunk_extern_requires_non_large_code_model)]
#[diag("`-Zfunction-return=thunk-extern` is only supported on non-large code models")]
pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
#[derive(Diagnostic)]
#[diag(session_indirect_branch_cs_prefix_requires_x86_or_x86_64)]
#[diag("`-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64")]
pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664;
#[derive(Diagnostic)]
#[diag(session_unsupported_regparm)]
#[diag("`-Zregparm={$regparm}` is unsupported (valid values 0-3)")]
pub(crate) struct UnsupportedRegparm {
pub(crate) regparm: u32,
}
#[derive(Diagnostic)]
#[diag(session_unsupported_regparm_arch)]
#[diag("`-Zregparm=N` is only supported on x86")]
pub(crate) struct UnsupportedRegparmArch;
#[derive(Diagnostic)]
#[diag(session_unsupported_reg_struct_return_arch)]
#[diag("`-Zreg-struct-return` is only supported on x86")]
pub(crate) struct UnsupportedRegStructReturnArch;
#[derive(Diagnostic)]
#[diag(session_failed_to_create_profiler)]
#[diag("failed to create profiler: {$err}")]
pub(crate) struct FailedToCreateProfiler {
pub(crate) err: String,
}
#[derive(Diagnostic)]
#[diag(session_soft_float_ignored)]
#[note]
#[diag("`-Csoft-float` is ignored on this target; it only has an effect on *eabihf targets")]
#[note("this may become a hard error in a future version of Rust")]
pub(crate) struct SoftFloatIgnored;
#[derive(Diagnostic)]
#[diag(session_soft_float_deprecated)]
#[note]
#[note(session_soft_float_deprecated_issue)]
#[diag("`-Csoft-float` is unsound and deprecated; use a corresponding *eabi target instead")]
#[note("it will be removed or ignored in a future version of Rust")]
#[note("see issue #129893 <https://github.com/rust-lang/rust/issues/129893> for more information")]
pub(crate) struct SoftFloatDeprecated;
#[derive(LintDiagnostic)]
#[diag(session_unexpected_builtin_cfg)]
#[note(session_controlled_by)]
#[note(session_incoherent)]
#[diag("unexpected `--cfg {$cfg}` flag")]
#[note("config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`")]
#[note("manually setting a built-in cfg can and does create incoherent behaviors")]
pub(crate) struct UnexpectedBuiltinCfg {
pub(crate) cfg: String,
pub(crate) cfg_name: Symbol,

View file

@ -32,8 +32,6 @@ pub mod output;
pub use getopts;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
/// Requirements for a `StableHashingContext` to be used in this crate.
/// This is a hack to allow using the `HashStable_Generic` derive macro
/// instead of implementing everything in `rustc_middle`.

View file

@ -8,7 +8,7 @@ use std::{env, io};
use rand::{RngCore, rng};
use rustc_data_structures::base_n::{CASE_INSENSITIVE, ToBaseN};
use rustc_data_structures::flock;
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
use rustc_data_structures::sync::{DynSend, DynSync, Lock, MappedReadGuard, ReadGuard, RwLock};
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
@ -154,6 +154,10 @@ pub struct Session {
/// preserved with a flag like `-C save-temps`, since these files may be
/// hard linked.
pub invocation_temp: Option<String>,
/// The names of intrinsics that the current codegen backend replaces
/// with its own implementations.
pub replaced_intrinsics: FxHashSet<Symbol>,
}
#[derive(Clone, Copy)]
@ -1092,6 +1096,7 @@ pub fn build_session(
target_filesearch,
host_filesearch,
invocation_temp,
replaced_intrinsics: FxHashSet::default(), // filled by `run_compiler`
};
validate_commandline_args_with_session_available(&sess);

View file

@ -1002,6 +1002,7 @@ symbols! {
explicit_tail_calls,
export_name,
export_stable,
export_symbols: "export-symbols",
expr,
expr_2021,
expr_fragment_specifier_2024,

View file

@ -3363,6 +3363,9 @@ impl Target {
Err(format!("could not find specification for target {target_tuple:?}"))
}
TargetTuple::TargetJson { ref contents, .. } if !unstable_options => {
Err("custom targets are unstable and require `-Zunstable-options`".to_string())
}
TargetTuple::TargetJson { ref contents, .. } => Target::from_json(contents),
}
}

View file

@ -954,7 +954,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let new_obligation =
self.mk_trait_obligation_with_new_self_ty(obligation.param_env, trait_pred_and_self);
if self.predicate_must_hold_modulo_regions(&new_obligation) {
if !matches!(tail_expr.kind, hir::ExprKind::Err(_))
&& self.predicate_must_hold_modulo_regions(&new_obligation)
{
err.span_suggestion_short(
stmt.span.with_lo(tail_expr.span.hi()),
"remove this semicolon",

View file

@ -9,7 +9,6 @@ itertools = "0.12"
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }

View file

@ -1,61 +0,0 @@
ty_utils_address_and_deref_not_supported = dereferencing or taking the address is not supported in generic constants
ty_utils_adt_not_supported = struct/enum construction is not supported in generic constants
ty_utils_array_not_supported = array construction is not supported in generic constants
ty_utils_assign_not_supported = assignment is not supported in generic constants
ty_utils_binary_not_supported = unsupported binary operation in generic constants
ty_utils_block_not_supported = blocks are not supported in generic constants
ty_utils_borrow_not_supported = borrowing is not supported in generic constants
ty_utils_box_not_supported = allocations are not allowed in generic constants
ty_utils_by_use_not_supported = .use is not allowed in generic constants
ty_utils_closure_and_return_not_supported = closures and function keywords are not supported in generic constants
ty_utils_const_block_not_supported = const blocks are not supported in generic constants
ty_utils_control_flow_not_supported = control flow is not supported in generic constants
ty_utils_field_not_supported = field access is not supported in generic constants
ty_utils_generic_constant_too_complex = overly complex generic constant
.help = consider moving this anonymous constant into a `const` function
.maybe_supported = this operation may be supported in the future
ty_utils_impl_trait_duplicate_arg = non-defining opaque type use in defining scope
.label = generic argument `{$arg}` used twice
.note = for this opaque type
ty_utils_impl_trait_not_param = non-defining opaque type use in defining scope
.label = argument `{$arg}` is not a generic parameter
.note = for this opaque type
ty_utils_index_not_supported = indexing is not supported in generic constants
ty_utils_inline_asm_not_supported = assembly is not supported in generic constants
ty_utils_logical_op_not_supported = unsupported operation in generic constants, short-circuiting operations would imply control flow
ty_utils_loop_not_supported = loops and loop control flow are not supported in generic constants
ty_utils_needs_drop_overflow = overflow while checking whether `{$query_ty}` requires drop
ty_utils_never_to_any_not_supported = coercing the `never` type is not supported in generic constants
ty_utils_non_primitive_simd_type = monomorphising SIMD type `{$ty}` with a non-primitive-scalar (integer/float/pointer) element type `{$e_ty}`
ty_utils_operation_not_supported = unsupported operation in generic constants
ty_utils_pointer_not_supported = pointer casts are not allowed in generic constants
ty_utils_tuple_not_supported = tuple construction is not supported in generic constants
ty_utils_unexpected_fnptr_associated_item = `FnPtr` trait with unexpected associated item
ty_utils_yield_not_supported = coroutine control flow is not allowed in generic constants

View file

@ -6,18 +6,18 @@ use rustc_middle::ty::{GenericArg, Ty};
use rustc_span::Span;
#[derive(Diagnostic)]
#[diag(ty_utils_needs_drop_overflow)]
#[diag("overflow while checking whether `{$query_ty}` requires drop")]
pub(crate) struct NeedsDropOverflow<'tcx> {
pub query_ty: Ty<'tcx>,
}
#[derive(Diagnostic)]
#[diag(ty_utils_generic_constant_too_complex)]
#[help]
#[diag("overly complex generic constant")]
#[help("consider moving this anonymous constant into a `const` function")]
pub(crate) struct GenericConstantTooComplex {
#[primary_span]
pub span: Span,
#[note(ty_utils_maybe_supported)]
#[note("this operation may be supported in the future")]
pub maybe_supported: bool,
#[subdiagnostic]
pub sub: GenericConstantTooComplexSub,
@ -25,84 +25,88 @@ pub(crate) struct GenericConstantTooComplex {
#[derive(Subdiagnostic)]
pub(crate) enum GenericConstantTooComplexSub {
#[label(ty_utils_borrow_not_supported)]
#[label("borrowing is not supported in generic constants")]
BorrowNotSupported(#[primary_span] Span),
#[label(ty_utils_address_and_deref_not_supported)]
#[label("dereferencing or taking the address is not supported in generic constants")]
AddressAndDerefNotSupported(#[primary_span] Span),
#[label(ty_utils_array_not_supported)]
#[label("array construction is not supported in generic constants")]
ArrayNotSupported(#[primary_span] Span),
#[label(ty_utils_block_not_supported)]
#[label("blocks are not supported in generic constants")]
BlockNotSupported(#[primary_span] Span),
#[label(ty_utils_never_to_any_not_supported)]
#[label("coercing the `never` type is not supported in generic constants")]
NeverToAnyNotSupported(#[primary_span] Span),
#[label(ty_utils_tuple_not_supported)]
#[label("tuple construction is not supported in generic constants")]
TupleNotSupported(#[primary_span] Span),
#[label(ty_utils_index_not_supported)]
#[label("indexing is not supported in generic constants")]
IndexNotSupported(#[primary_span] Span),
#[label(ty_utils_field_not_supported)]
#[label("field access is not supported in generic constants")]
FieldNotSupported(#[primary_span] Span),
#[label(ty_utils_const_block_not_supported)]
#[label("const blocks are not supported in generic constants")]
ConstBlockNotSupported(#[primary_span] Span),
#[label(ty_utils_adt_not_supported)]
#[label("struct/enum construction is not supported in generic constants")]
AdtNotSupported(#[primary_span] Span),
#[label(ty_utils_pointer_not_supported)]
#[label("pointer casts are not allowed in generic constants")]
PointerNotSupported(#[primary_span] Span),
#[label(ty_utils_yield_not_supported)]
#[label("coroutine control flow is not allowed in generic constants")]
YieldNotSupported(#[primary_span] Span),
#[label(ty_utils_loop_not_supported)]
#[label("loops and loop control flow are not supported in generic constants")]
LoopNotSupported(#[primary_span] Span),
#[label(ty_utils_box_not_supported)]
#[label("allocations are not allowed in generic constants")]
BoxNotSupported(#[primary_span] Span),
#[label(ty_utils_binary_not_supported)]
#[label("unsupported binary operation in generic constants")]
BinaryNotSupported(#[primary_span] Span),
#[label(ty_utils_by_use_not_supported)]
#[label(".use is not allowed in generic constants")]
ByUseNotSupported(#[primary_span] Span),
#[label(ty_utils_logical_op_not_supported)]
#[label(
"unsupported operation in generic constants, short-circuiting operations would imply control flow"
)]
LogicalOpNotSupported(#[primary_span] Span),
#[label(ty_utils_assign_not_supported)]
#[label("assignment is not supported in generic constants")]
AssignNotSupported(#[primary_span] Span),
#[label(ty_utils_closure_and_return_not_supported)]
#[label("closures and function keywords are not supported in generic constants")]
ClosureAndReturnNotSupported(#[primary_span] Span),
#[label(ty_utils_control_flow_not_supported)]
#[label("control flow is not supported in generic constants")]
ControlFlowNotSupported(#[primary_span] Span),
#[label(ty_utils_inline_asm_not_supported)]
#[label("assembly is not supported in generic constants")]
InlineAsmNotSupported(#[primary_span] Span),
#[label(ty_utils_operation_not_supported)]
#[label("unsupported operation in generic constants")]
OperationNotSupported(#[primary_span] Span),
}
#[derive(Diagnostic)]
#[diag(ty_utils_unexpected_fnptr_associated_item)]
#[diag("`FnPtr` trait with unexpected associated item")]
pub(crate) struct UnexpectedFnPtrAssociatedItem {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ty_utils_non_primitive_simd_type)]
#[diag(
"monomorphising SIMD type `{$ty}` with a non-primitive-scalar (integer/float/pointer) element type `{$e_ty}`"
)]
pub(crate) struct NonPrimitiveSimdType<'tcx> {
pub ty: Ty<'tcx>,
pub e_ty: Ty<'tcx>,
}
#[derive(Diagnostic)]
#[diag(ty_utils_impl_trait_duplicate_arg)]
#[diag("non-defining opaque type use in defining scope")]
pub(crate) struct DuplicateArg<'tcx> {
pub arg: GenericArg<'tcx>,
#[primary_span]
#[label]
#[label("generic argument `{$arg}` used twice")]
pub span: Span,
#[note]
#[note("for this opaque type")]
pub opaque_span: Span,
}
#[derive(Diagnostic)]
#[diag(ty_utils_impl_trait_not_param, code = E0792)]
#[diag("non-defining opaque type use in defining scope", code = E0792)]
pub(crate) struct NotParam<'tcx> {
pub arg: GenericArg<'tcx>,
#[primary_span]
#[label]
#[label("argument `{$arg}` is not a generic parameter")]
pub span: Span,
#[note]
#[note("for this opaque type")]
pub opaque_span: Span,
}

View file

@ -31,8 +31,6 @@ pub mod sig_types;
mod structural_match;
mod ty;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub fn provide(providers: &mut Providers) {
abi::provide(providers);
assoc::provide(providers);

View file

@ -2301,6 +2301,57 @@ fn test_fs_set_times() {
}
}
#[test]
fn test_fs_set_times_on_dir() {
#[cfg(target_vendor = "apple")]
use crate::os::darwin::fs::FileTimesExt;
#[cfg(windows)]
use crate::os::windows::fs::FileTimesExt;
let tmp = tmpdir();
let dir_path = tmp.join("testdir");
fs::create_dir(&dir_path).unwrap();
let mut times = FileTimes::new();
let accessed = SystemTime::UNIX_EPOCH + Duration::from_secs(12345);
let modified = SystemTime::UNIX_EPOCH + Duration::from_secs(54321);
times = times.set_accessed(accessed).set_modified(modified);
#[cfg(any(windows, target_vendor = "apple"))]
let created = SystemTime::UNIX_EPOCH + Duration::from_secs(32123);
#[cfg(any(windows, target_vendor = "apple"))]
{
times = times.set_created(created);
}
match fs::set_times(&dir_path, times) {
// Allow unsupported errors on platforms which don't support setting times.
#[cfg(not(any(
windows,
all(
unix,
not(any(
target_os = "android",
target_os = "redox",
target_os = "espidf",
target_os = "horizon"
))
)
)))]
Err(e) if e.kind() == ErrorKind::Unsupported => return,
Err(e) => panic!("error setting directory times: {e:?}"),
Ok(_) => {}
}
let metadata = fs::metadata(&dir_path).unwrap();
assert_eq!(metadata.accessed().unwrap(), accessed);
assert_eq!(metadata.modified().unwrap(), modified);
#[cfg(any(windows, target_vendor = "apple"))]
{
assert_eq!(metadata.created().unwrap(), created);
}
}
#[test]
fn test_fs_set_times_follows_symlink() {
#[cfg(target_vendor = "apple")]

View file

@ -1556,7 +1556,7 @@ pub fn set_perm(p: &WCStr, perm: FilePermissions) -> io::Result<()> {
pub fn set_times(p: &WCStr, times: FileTimes) -> io::Result<()> {
let mut opts = OpenOptions::new();
opts.write(true);
opts.access_mode(c::FILE_WRITE_ATTRIBUTES);
opts.custom_flags(c::FILE_FLAG_BACKUP_SEMANTICS);
let file = File::open_native(p, &opts)?;
file.set_times(times)
@ -1564,7 +1564,7 @@ pub fn set_times(p: &WCStr, times: FileTimes) -> io::Result<()> {
pub fn set_times_nofollow(p: &WCStr, times: FileTimes) -> io::Result<()> {
let mut opts = OpenOptions::new();
opts.write(true);
opts.access_mode(c::FILE_WRITE_ATTRIBUTES);
// `FILE_FLAG_OPEN_REPARSE_POINT` for no_follow behavior
opts.custom_flags(c::FILE_FLAG_BACKUP_SEMANTICS | c::FILE_FLAG_OPEN_REPARSE_POINT);
let file = File::open_native(p, &opts)?;

View file

@ -111,6 +111,29 @@ pub struct JsonStepSystemStats {
pub cpu_utilization_percent: f64,
}
#[derive(Eq, Hash, PartialEq, Debug)]
pub enum DebuggerKind {
Gdb,
Lldb,
Cdb,
}
impl DebuggerKind {
pub fn debuginfo_kind(name: &str) -> Option<DebuggerKind> {
let name = name.to_ascii_lowercase();
if name.contains("debuginfo-gdb") {
Some(DebuggerKind::Gdb)
} else if name.contains("debuginfo-lldb") {
Some(DebuggerKind::Lldb)
} else if name.contains("debuginfo-cdb") {
Some(DebuggerKind::Cdb)
} else {
None
}
}
}
fn null_as_f64_nan<'de, D: serde::Deserializer<'de>>(d: D) -> Result<f64, D::Error> {
use serde::Deserialize as _;
Option::<f64>::deserialize(d).map(|f| f.unwrap_or(f64::NAN))

View file

@ -3,7 +3,7 @@ use std::fmt::Debug;
use std::time::Duration;
use build_helper::metrics::{
BuildStep, JsonRoot, TestOutcome, TestSuite, TestSuiteMetadata, escape_step_name,
BuildStep, DebuggerKind, JsonRoot, TestOutcome, TestSuite, TestSuiteMetadata, escape_step_name,
format_build_steps,
};
@ -139,11 +139,39 @@ fn record_test_suites(metrics: &JsonRoot) {
let table = render_table(aggregated);
println!("\n# Test results\n");
println!("{table}");
report_debuginfo_statistics(&suites);
} else {
eprintln!("No test suites found in metrics");
}
}
fn report_debuginfo_statistics(suites: &[&TestSuite]) {
let mut debugger_test_record: HashMap<DebuggerKind, TestSuiteRecord> = HashMap::new();
for suite in suites {
if let TestSuiteMetadata::Compiletest { .. } = suite.metadata {
for test in &suite.tests {
if let Some(kind) = DebuggerKind::debuginfo_kind(&test.name) {
let record =
debugger_test_record.entry(kind).or_insert(TestSuiteRecord::default());
match test.outcome {
TestOutcome::Passed => record.passed += 1,
TestOutcome::Ignored { .. } => record.ignored += 1,
TestOutcome::Failed => record.failed += 1,
}
}
}
}
}
println!("## DebugInfo Test Statistics");
for (kind, record) in debugger_test_record {
println!(
"- {:?}: Passed ✅={}, Failed ❌={}, Ignored 🚫={}",
kind, record.passed, record.failed, record.ignored
);
}
}
fn render_table(suites: BTreeMap<String, TestSuiteRecord>) -> String {
use std::fmt::Write;

View file

@ -6,7 +6,7 @@ const TEST_JOBS_YML_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/tes
fn auto_jobs() {
let stdout = get_matrix("push", "commit", "refs/heads/automation/bors/auto");
insta::assert_snapshot!(stdout, @r#"
jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-14","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set rust.jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","SELECT_XCODE":"/Applications/Xcode_15.4.app","TOOLSTATE_PUBLISH":1,"USE_XCODE_CLANG":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}]
jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-14","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DEVELOPER_DIR":"/Applications/Xcode_15.4.app/Contents/Developer","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set rust.jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","TOOLSTATE_PUBLISH":1,"USE_XCODE_CLANG":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}]
run_type=auto
"#);
}

View file

@ -33,7 +33,7 @@ envs:
# Ensure that host tooling is tested on our minimum supported macOS version.
MACOSX_DEPLOYMENT_TARGET: 10.12
MACOSX_STD_DEPLOYMENT_TARGET: 10.12
SELECT_XCODE: /Applications/Xcode_15.2.app
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
NO_LLVM_ASSERTIONS: 1
NO_DEBUG_ASSERTIONS: 1
NO_OVERFLOW_CHECKS: 1
@ -112,7 +112,7 @@ auto:
--enable-profiler
--set rust.jemalloc
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
SELECT_XCODE: /Applications/Xcode_15.4.app
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
USE_XCODE_CLANG: 1
# Aarch64 tooling only needs to support macOS 11.0 and up as nothing else
# supports the hardware, so only need to test it there.

View file

@ -50,6 +50,9 @@ ENV RUST_CONFIGURE_ARGS \
--enable-full-tools \
--enable-profiler \
--enable-sanitizers \
--disable-docs
--disable-docs \
--set rust.jemalloc \
--set rust.lto=thin \
--set rust.codegen-units=1
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $TARGETS

View file

@ -33,6 +33,9 @@ ENV RUST_CONFIGURE_ARGS \
--enable-profiler \
--enable-sanitizers \
--disable-docs \
--set rust.jemalloc \
--set rust.lto=thin \
--set rust.codegen-units=1 \
--set target.loongarch64-unknown-linux-musl.crt-static=false \
--musl-root-loongarch64=/x-tools/loongarch64-unknown-linux-musl/loongarch64-unknown-linux-musl/sysroot/usr

View file

@ -2,8 +2,8 @@
set -euo pipefail
# https://github.com/rust-lang/rust/pull/145974
LINUX_VERSION=842cfd8e5aff3157cb25481b2900b49c188d628a
# https://github.com/rust-lang/rust/pull/151534
LINUX_VERSION=eb268c7972f65fa0b11b051c5ef2b92747bb2b62
# Build rustc, rustdoc, cargo, clippy-driver and rustfmt
../x.py build --stage 2 library rustdoc clippy rustfmt

View file

@ -459,7 +459,7 @@ auto:
# Ensure that host tooling is built to support our minimum support macOS version.
MACOSX_DEPLOYMENT_TARGET: 10.12
MACOSX_STD_DEPLOYMENT_TARGET: 10.12
SELECT_XCODE: /Applications/Xcode_15.4.app
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
USE_XCODE_CLANG: 1
DIST_REQUIRE_ALL_TOOLS: 1
CODEGEN_BACKENDS: llvm,cranelift
@ -475,7 +475,7 @@ auto:
# FIXME(madsmtm): This might be redundant, as we're not building host tooling here (?)
MACOSX_DEPLOYMENT_TARGET: 10.12
MACOSX_STD_DEPLOYMENT_TARGET: 10.12
SELECT_XCODE: /Applications/Xcode_15.2.app
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
<<: *job-macos
- name: dist-aarch64-apple
@ -496,7 +496,7 @@ auto:
# supports the hardware.
MACOSX_DEPLOYMENT_TARGET: 11.0
MACOSX_STD_DEPLOYMENT_TARGET: 11.0
SELECT_XCODE: /Applications/Xcode_15.4.app
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
USE_XCODE_CLANG: 1
DIST_REQUIRE_ALL_TOOLS: 1
CODEGEN_BACKENDS: llvm,cranelift
@ -511,7 +511,7 @@ auto:
--enable-sanitizers
--enable-profiler
--set rust.jemalloc
SELECT_XCODE: /Applications/Xcode_15.4.app
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
USE_XCODE_CLANG: 1
# Aarch64 tooling only needs to support macOS 11.0 and up as nothing else
# supports the hardware, so only need to test it there.

View file

@ -1,11 +0,0 @@
#!/bin/bash
# This script selects the Xcode instance to use.
set -euo pipefail
IFS=$'\n\t'
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
if isMacOS; then
sudo xcode-select -s "${SELECT_XCODE}"
fi

View file

@ -47,6 +47,7 @@ pub use crate::assertion_helpers::{
assert_contains, assert_contains_regex, assert_count_is, assert_dirs_are_equal, assert_equals,
assert_not_contains, assert_not_contains_regex,
};
pub use crate::command::CompletedProcess;
// `diff` is implemented in terms of the [similar] library.
//
// [similar]: https://github.com/mitsuhiko/similar

View file

@ -10,7 +10,7 @@ This is invoked automatically when building mdbook-style documentation, for exam
## Cargo workspace
This package defines a separate cargo workspace from the main Rust workspace for a few reasons (ref [#127786](https://github.com/rust-lang/rust/pull/127786):
This package defines a separate cargo workspace from the main Rust workspace for a few reasons (ref [#127786](https://github.com/rust-lang/rust/pull/127786)):
- Avoids requiring checking out submodules for developers who are not working on the documentation. Otherwise, some submodules such as those that have custom preprocessors would be required for cargo to find the dependencies.
- Avoids problems with updating dependencies. Unfortunately this workspace has a rather large set of dependencies, which can make coordinating updates difficult (see [#127890](https://github.com/rust-lang/rust/issues/127890)).

View file

@ -38,14 +38,14 @@ fn square(x: f32) -> f32 {
// CHECK-LABEL: ; abi_handling::df1
// CHECK-NEXT: Function Attrs
// debug-NEXT: define internal { float, float }
// debug-SAME: (ptr align 4 %x, ptr align 4 %bx_0)
// debug-SAME: (ptr {{.*}}%x, ptr {{.*}}%bx_0)
// release-NEXT: define internal fastcc float
// release-SAME: (float %x.0.val, float %x.4.val)
// CHECK-LABEL: ; abi_handling::f1
// CHECK-NEXT: Function Attrs
// debug-NEXT: define internal float
// debug-SAME: (ptr align 4 %x)
// debug-SAME: (ptr {{.*}}%x)
// release-NEXT: define internal fastcc noundef float
// release-SAME: (float %x.0.val, float %x.4.val)
#[autodiff_forward(df1, Dual, Dual)]
@ -58,7 +58,7 @@ fn f1(x: &[f32; 2]) -> f32 {
// CHECK-NEXT: Function Attrs
// debug-NEXT: define internal { float, float }
// debug-SAME: (ptr %f, float %x, float %dret)
// release-NEXT: define internal fastcc float
// release-NEXT: define internal fastcc noundef float
// release-SAME: (float noundef %x)
// CHECK-LABEL: ; abi_handling::f2
@ -77,13 +77,13 @@ fn f2(f: fn(f32) -> f32, x: f32) -> f32 {
// CHECK-NEXT: Function Attrs
// debug-NEXT: define internal { float, float }
// debug-SAME: (ptr align 4 %x, ptr align 4 %bx_0, ptr align 4 %y, ptr align 4 %by_0)
// release-NEXT: define internal fastcc { float, float }
// release-NEXT: define internal fastcc float
// release-SAME: (float %x.0.val)
// CHECK-LABEL: ; abi_handling::f3
// CHECK-NEXT: Function Attrs
// debug-NEXT: define internal float
// debug-SAME: (ptr align 4 %x, ptr align 4 %y)
// debug-SAME: (ptr {{.*}}%x, ptr {{.*}}%y)
// release-NEXT: define internal fastcc noundef float
// release-SAME: (float %x.0.val)
#[autodiff_forward(df3, Dual, Dual, Dual)]
@ -160,7 +160,7 @@ fn f6(i: NestedInput) -> f32 {
// CHECK-LABEL: ; abi_handling::f7
// CHECK-NEXT: Function Attrs
// debug-NEXT: define internal float
// debug-SAME: (ptr align 4 %x.0, ptr align 4 %x.1)
// debug-SAME: (ptr {{.*}}%x.0, ptr {{.*}}%x.1)
// release-NEXT: define internal fastcc noundef float
// release-SAME: (float %x.0.0.val, float %x.1.0.val)
#[autodiff_forward(df7, Dual, Dual)]

View file

@ -1,13 +1,11 @@
//@ compile-flags: -Zautodiff=Enable,NoTT,NoPostopt -C opt-level=3 -Clto=fat
//@ no-prefer-dynamic
//@ needs-enzyme
//
// In Enzyme, we test against a large range of LLVM versions (5+) and don't have overly many
// breakages. One benefit is that we match the IR generated by Enzyme only after running it
// through LLVM's O3 pipeline, which will remove most of the noise.
// However, our integration test could also be affected by changes in how rustc lowers MIR into
// LLVM-IR, which could cause additional noise and thus breakages. If that's the case, we should
// reduce this test to only match the first lines and the ret instructions.
// This test combines two features of Enzyme, automatic differentiation and batching. As such, it is
// especially prone to breakages. I reduced it therefore to a minimal check matches argument/return
// types. Based on the original batching author, implementing the batching feature over MLIR instead
// of LLVM should give significantly more reliable performance.
#![feature(autodiff)]
@ -22,69 +20,20 @@ fn square(x: &f32) -> f32 {
x * x
}
// The base ("scalar") case d_square3, without batching.
// CHECK: define internal fastcc float @fwddiffesquare(float %x.0.val, float %"x'.0.val")
// CHECK: %0 = fadd fast float %"x'.0.val", %"x'.0.val"
// CHECK-NEXT: %1 = fmul fast float %0, %x.0.val
// CHECK-NEXT: ret float %1
// CHECK-NEXT: }
// d_square2
// CHECK: define internal [4 x float] @fwddiffe4square(ptr noalias noundef readonly align 4 captures(none) dereferenceable(4) %x, [4 x ptr] %"x'")
// CHECK-NEXT: start:
// CHECK-NEXT: %0 = extractvalue [4 x ptr] %"x'", 0
// CHECK-NEXT: %"_2'ipl" = load float, ptr %0, align 4
// CHECK-NEXT: %1 = extractvalue [4 x ptr] %"x'", 1
// CHECK-NEXT: %"_2'ipl1" = load float, ptr %1, align 4
// CHECK-NEXT: %2 = extractvalue [4 x ptr] %"x'", 2
// CHECK-NEXT: %"_2'ipl2" = load float, ptr %2, align 4
// CHECK-NEXT: %3 = extractvalue [4 x ptr] %"x'", 3
// CHECK-NEXT: %"_2'ipl3" = load float, ptr %3, align 4
// CHECK-NEXT: %_2 = load float, ptr %x, align 4
// CHECK-NEXT: %4 = fmul fast float %"_2'ipl", %_2
// CHECK-NEXT: %5 = fmul fast float %"_2'ipl1", %_2
// CHECK-NEXT: %6 = fmul fast float %"_2'ipl2", %_2
// CHECK-NEXT: %7 = fmul fast float %"_2'ipl3", %_2
// CHECK-NEXT: %8 = fmul fast float %"_2'ipl", %_2
// CHECK-NEXT: %9 = fmul fast float %"_2'ipl1", %_2
// CHECK-NEXT: %10 = fmul fast float %"_2'ipl2", %_2
// CHECK-NEXT: %11 = fmul fast float %"_2'ipl3", %_2
// CHECK-NEXT: %12 = fadd fast float %4, %8
// CHECK-NEXT: %13 = insertvalue [4 x float] undef, float %12, 0
// CHECK-NEXT: %14 = fadd fast float %5, %9
// CHECK-NEXT: %15 = insertvalue [4 x float] %13, float %14, 1
// CHECK-NEXT: %16 = fadd fast float %6, %10
// CHECK-NEXT: %17 = insertvalue [4 x float] %15, float %16, 2
// CHECK-NEXT: %18 = fadd fast float %7, %11
// CHECK-NEXT: %19 = insertvalue [4 x float] %17, float %18, 3
// CHECK-NEXT: ret [4 x float] %19
// CHECK: define internal fastcc [4 x float] @fwddiffe4square(float %x.0.val, [4 x ptr] %"x'")
// CHECK: ret [4 x float]
// CHECK-NEXT: }
// d_square3, the extra float is the original return value (x * x)
// CHECK: define internal { float, [4 x float] } @fwddiffe4square.1(ptr noalias noundef readonly align 4 captures(none) dereferenceable(4) %x, [4 x ptr] %"x'")
// CHECK-NEXT: start:
// CHECK-NEXT: %0 = extractvalue [4 x ptr] %"x'", 0
// CHECK-NEXT: %"_2'ipl" = load float, ptr %0, align 4
// CHECK-NEXT: %1 = extractvalue [4 x ptr] %"x'", 1
// CHECK-NEXT: %"_2'ipl1" = load float, ptr %1, align 4
// CHECK-NEXT: %2 = extractvalue [4 x ptr] %"x'", 2
// CHECK-NEXT: %"_2'ipl2" = load float, ptr %2, align 4
// CHECK-NEXT: %3 = extractvalue [4 x ptr] %"x'", 3
// CHECK-NEXT: %"_2'ipl3" = load float, ptr %3, align 4
// CHECK-NEXT: %_2 = load float, ptr %x, align 4
// CHECK-NEXT: %_0 = fmul float %_2, %_2
// CHECK-NEXT: %4 = fmul fast float %"_2'ipl", %_2
// CHECK-NEXT: %5 = fmul fast float %"_2'ipl1", %_2
// CHECK-NEXT: %6 = fmul fast float %"_2'ipl2", %_2
// CHECK-NEXT: %7 = fmul fast float %"_2'ipl3", %_2
// CHECK-NEXT: %8 = fmul fast float %"_2'ipl", %_2
// CHECK-NEXT: %9 = fmul fast float %"_2'ipl1", %_2
// CHECK-NEXT: %10 = fmul fast float %"_2'ipl2", %_2
// CHECK-NEXT: %11 = fmul fast float %"_2'ipl3", %_2
// CHECK-NEXT: %12 = fadd fast float %4, %8
// CHECK-NEXT: %13 = insertvalue [4 x float] undef, float %12, 0
// CHECK-NEXT: %14 = fadd fast float %5, %9
// CHECK-NEXT: %15 = insertvalue [4 x float] %13, float %14, 1
// CHECK-NEXT: %16 = fadd fast float %6, %10
// CHECK-NEXT: %17 = insertvalue [4 x float] %15, float %16, 2
// CHECK-NEXT: %18 = fadd fast float %7, %11
// CHECK-NEXT: %19 = insertvalue [4 x float] %17, float %18, 3
// CHECK-NEXT: %20 = insertvalue { float, [4 x float] } undef, float %_0, 0
// CHECK-NEXT: %21 = insertvalue { float, [4 x float] } %20, [4 x float] %19, 1
// CHECK-NEXT: ret { float, [4 x float] } %21
// CHECK: define internal fastcc { float, [4 x float] } @fwddiffe4square.{{.*}}(float %x.0.val, [4 x ptr] %"x'")
// CHECK: ret { float, [4 x float] }
// CHECK-NEXT: }
fn main() {

View file

@ -1,6 +1,14 @@
//@ compile-flags: -Zautodiff=Enable -Zautodiff=NoPostopt -C opt-level=3 -Clto=fat
//@ no-prefer-dynamic
//@ needs-enzyme
//@ revisions: F32 F64 Main
// Here we verify that the function `square` can be differentiated over f64.
// This is interesting to test, since the user never calls `square` with f64, so on it's own rustc
// would have no reason to monomorphize it that way. However, Enzyme needs the f64 version of
// `square` in order to be able to differentiate it, so we have logic to enforce the
// monomorphization. Here, we test this logic.
#![feature(autodiff)]
use std::autodiff::autodiff_reverse;
@ -12,32 +20,37 @@ fn square<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T {
}
// Ensure that `d_square::<f32>` code is generated
//
// CHECK: ; generic::square
// CHECK-NEXT: ; Function Attrs: {{.*}}
// CHECK-NEXT: define internal {{.*}} float
// CHECK-NEXT: start:
// CHECK-NOT: ret
// CHECK: fmul float
// F32-LABEL: ; generic::square::<f32>
// F32-NEXT: ; Function Attrs: {{.*}}
// F32-NEXT: define internal {{.*}} float
// F32-NEXT: start:
// F32-NOT: ret
// F32: fmul float
// Ensure that `d_square::<f64>` code is generated even if `square::<f64>` was never called
//
// CHECK: ; generic::square
// CHECK-NEXT: ; Function Attrs:
// CHECK-NEXT: define internal {{.*}} double
// CHECK-NEXT: start:
// CHECK-NOT: ret
// CHECK: fmul double
// F64-LABEL: ; generic::d_square::<f64>
// F64-NEXT: ; Function Attrs: {{.*}}
// F64-NEXT: define internal {{.*}} void
// F64-NEXT: start:
// F64-NEXT: {{(tail )?}}call {{(fastcc )?}}void @diffe_{{.*}}(double {{.*}}, ptr {{.*}})
// F64-NEXT: ret void
// Main-LABEL: ; generic::main
// Main: ; call generic::square::<f32>
// Main: ; call generic::d_square::<f64>
fn main() {
let xf32: f32 = std::hint::black_box(3.0);
let xf64: f64 = std::hint::black_box(3.0);
let seed: f64 = std::hint::black_box(1.0);
let outputf32 = square::<f32>(&xf32);
assert_eq!(9.0, outputf32);
let mut df_dxf64: f64 = std::hint::black_box(0.0);
let output_f64 = d_square::<f64>(&xf64, &mut df_dxf64, 1.0);
let output_f64 = d_square::<f64>(&xf64, &mut df_dxf64, seed);
assert_eq!(6.0, df_dxf64);
}

View file

@ -8,7 +8,7 @@
// merged placeholder function anymore, and compilation would fail. We prevent this by disabling
// LLVM's merge_function pass before AD. Here we implicetely test that our solution keeps working.
// We also explicetly test that we keep running merge_function after AD, by checking for two
// identical function calls in the LLVM-IR, while having two different calls in the Rust code.
// identical function calls in the LLVM-IR, despite having two different calls in the Rust code.
#![feature(autodiff)]
use std::autodiff::autodiff_reverse;
@ -27,14 +27,14 @@ fn square2(x: &f64) -> f64 {
// CHECK:; identical_fnc::main
// CHECK-NEXT:; Function Attrs:
// CHECK-NEXT:define internal void @_ZN13identical_fnc4main17h6009e4f751bf9407E()
// CHECK-NEXT:define internal void
// CHECK-NEXT:start:
// CHECK-NOT:br
// CHECK-NOT:ret
// CHECK:; call identical_fnc::d_square
// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square[[HASH:.+]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx1)
// CHECK-NEXT:call fastcc void @[[HASH:.+]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx1)
// CHECK:; call identical_fnc::d_square
// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square[[HASH]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx2)
// CHECK-NEXT:call fastcc void @[[HASH]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx2)
fn main() {
let x = std::hint::black_box(3.0);

View file

@ -11,10 +11,9 @@
use std::intrinsics::{carrying_mul_add, fallback};
// The fallbacks are emitted even when they're never used, but optimize out.
// The fallbacks should not be emitted.
// RAW: wide_mul_u128
// OPT-NOT: wide_mul_u128
// NOT: wide_mul_u128
// CHECK-LABEL: @cma_u8
#[no_mangle]

View file

@ -4,6 +4,6 @@
use run_make_support::{llvm_filecheck, rfs, rustc};
fn main() {
rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run();
rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run();
llvm_filecheck().patterns("array.check").stdin_buf(rfs::read("test.ll")).run();
}

View file

@ -9,6 +9,7 @@ fn main() {
.arg("-Zautodiff=Enable")
.arg("-Zautodiff=NoPostopt")
.opt_level("0")
.arg("-Clto=fat")
.emit("llvm-ir")
.run();

View file

@ -8,6 +8,7 @@ fn main() {
rustc()
.input("test.rs")
.arg("-Zautodiff=Enable,NoTT")
.arg("-Clto=fat")
.emit("llvm-ir")
.arg("-o")
.arg("nott.ll")
@ -17,6 +18,7 @@ fn main() {
rustc()
.input("test.rs")
.arg("-Zautodiff=Enable")
.arg("-Clto=fat")
.emit("llvm-ir")
.arg("-o")
.arg("with_tt.ll")

View file

@ -4,6 +4,6 @@
use run_make_support::{llvm_filecheck, rfs, rustc};
fn main() {
rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run();
rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run();
llvm_filecheck().patterns("recursion.check").stdin_buf(rfs::read("test.ll")).run();
}

View file

@ -5,7 +5,7 @@ use run_make_support::{llvm_filecheck, rfs, rustc};
fn main() {
// Compile with TypeTree enabled and emit LLVM IR
rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run();
rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run();
// Check that f128 TypeTree metadata is correctly generated
llvm_filecheck().patterns("f128.check").stdin_buf(rfs::read("test.ll")).run();

View file

@ -5,7 +5,7 @@ use run_make_support::{llvm_filecheck, rfs, rustc};
fn main() {
// Compile with TypeTree enabled and emit LLVM IR
rustc().input("test.rs").arg("-Zautodiff=Enable").emit("llvm-ir").run();
rustc().input("test.rs").arg("-Zautodiff=Enable").arg("-Clto=fat").emit("llvm-ir").run();
// Check that f16 TypeTree metadata is correctly generated
llvm_filecheck().patterns("f16.check").stdin_buf(rfs::read("test.ll")).run();

Some files were not shown because too many files have changed in this diff Show more