Auto merge of #152156 - JonathanBrouwer:rollup-hT8ON1e, r=JonathanBrouwer

Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#150379 (Return `ExitCode` from `rustc_driver::main` instead of calling `process::exit`)
 - rust-lang/rust#152033 (Rename trait `DepNodeParams` to `DepNodeKey`)
 - rust-lang/rust#152142 (Convert to inline diagnostics in `rustc_hir_typeck`)
 - rust-lang/rust#152145 (Disable flaky test `oneshot::recv_timeout_before_send`)
 - rust-lang/rust#152020 (Remove dummy loads on offload codegen)
 - rust-lang/rust#152023 (Some `rustc_query_system` cleanups)
 - rust-lang/rust#152068 (Convert to inline diagnostics in `rustc_resolve`)
 - rust-lang/rust#152081 (Port depgraph testing attributes to parser)
 - rust-lang/rust#152090 (Port reexport_test_harness_main to attr parser)
 - rust-lang/rust#152105 (Convert to inline diagnostics in `rustc_ast_lowering`)
 - rust-lang/rust#152108 (Convert to inline diagnostics in `rustc_expand`)
 - rust-lang/rust#152110 (Fix incorrect RSS on systems with non-4K page size)
 - rust-lang/rust#152111 (bootstrap: exclude hexagon-unknown-qurt from llvm-libunwind default)
 - rust-lang/rust#152114 (Convert to inline diagnostics in `rustc_mir_transform`)
 - rust-lang/rust#152115 (Convert to inline diagnostics in `rustc_metadata`)
 - rust-lang/rust#152116 (Remove rustdoc GUI flaky test)
 - rust-lang/rust#152118 (Convert to inline diagnostics in `rustc_codegen_ssa`)
 - rust-lang/rust#152128 (Adopt matches-logical-or-141497.rs to LLVM HEAD)

Failed merges:

 - rust-lang/rust#152070 (Convert to inline diagnostics in `rustc_pattern_analysis`)
 - rust-lang/rust#152106 (Convert to inline diagnostics in `rustc_ast_passes`)
 - rust-lang/rust#152109 (Convert to inline diagnostics in `rustc_errors`)
 - rust-lang/rust#152117 (Convert to inline diagnostics in `rustc_trait_selection`)
 - rust-lang/rust#152119 (Convert to inline diagnostics in `rustc_middle`)
 - rust-lang/rust#152126 (Convert to inline diagnostics in `rustc_mir_build`)
 - rust-lang/rust#152131 (Port rustc_no_implicit_bounds attribute to parser.)
This commit is contained in:
bors 2026-02-05 07:36:53 +00:00
commit 0a13b43612
107 changed files with 2521 additions and 3869 deletions

View file

@ -3490,7 +3490,6 @@ dependencies = [
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
"rustc_fluent_macro",
"rustc_hir",
"rustc_index",
"rustc_macros",
@ -3672,7 +3671,6 @@ dependencies = [
"rustc_attr_parsing",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_fs_util",
"rustc_hashes",
"rustc_hir",
@ -3774,7 +3772,6 @@ dependencies = [
"libc",
"rustc_abi",
"rustc_ast",
"rustc_ast_lowering",
"rustc_ast_passes",
"rustc_ast_pretty",
"rustc_borrowck",
@ -3787,7 +3784,6 @@ dependencies = [
"rustc_feature",
"rustc_hir_analysis",
"rustc_hir_pretty",
"rustc_hir_typeck",
"rustc_index",
"rustc_interface",
"rustc_lexer",
@ -3875,7 +3871,6 @@ dependencies = [
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
"rustc_fluent_macro",
"rustc_hir",
"rustc_lexer",
"rustc_lint_defs",
@ -4017,7 +4012,6 @@ dependencies = [
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_hir",
"rustc_hir_analysis",
"rustc_hir_pretty",
@ -4039,7 +4033,6 @@ name = "rustc_incremental"
version = "0.0.0"
dependencies = [
"rand 0.9.2",
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
"rustc_fs_util",
@ -4051,7 +4044,6 @@ dependencies = [
"rustc_serialize",
"rustc_session",
"rustc_span",
"thin-vec",
"tracing",
]
@ -4237,7 +4229,6 @@ dependencies = [
"rustc_errors",
"rustc_expand",
"rustc_feature",
"rustc_fluent_macro",
"rustc_fs_util",
"rustc_hir",
"rustc_hir_pretty",
@ -4347,7 +4338,6 @@ dependencies = [
"rustc_const_eval",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_hir",
"rustc_index",
"rustc_infer",
@ -4534,9 +4524,11 @@ version = "0.0.0"
dependencies = [
"measureme",
"rustc_data_structures",
"rustc_errors",
"rustc_hashes",
"rustc_hir",
"rustc_index",
"rustc_macros",
"rustc_middle",
"rustc_query_system",
"rustc_serialize",
@ -4581,7 +4573,6 @@ dependencies = [
"rustc_errors",
"rustc_expand",
"rustc_feature",
"rustc_fluent_macro",
"rustc_hir",
"rustc_index",
"rustc_macros",

View file

@ -3,6 +3,8 @@
// Several crates are depended upon but unused so that they are present in the sysroot
#![expect(unused_crate_dependencies)]
use std::process::ExitCode;
// A note about jemalloc: rustc uses jemalloc when built for CI and
// distribution. The obvious way to do this is with the `#[global_allocator]`
// mechanism. However, for complicated reasons (see
@ -38,6 +40,6 @@
#[cfg(feature = "jemalloc")]
use tikv_jemalloc_sys as _;
fn main() {
fn main() -> ExitCode {
rustc_driver::main()
}

View file

@ -15,7 +15,6 @@ rustc_attr_parsing = { path = "../rustc_attr_parsing" }
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_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }

View file

@ -1,191 +0,0 @@
ast_lowering_abi_specified_multiple_times =
`{$prev_name}` ABI specified multiple times
.label = previously specified here
.note = these ABIs are equivalent on the current target
ast_lowering_arbitrary_expression_in_pattern =
arbitrary expressions aren't allowed in patterns
.pattern_from_macro_note = the `expr` fragment specifier forces the metavariable's content to be an expression
.const_block_in_pattern_help = use a named `const`-item or an `if`-guard (`x if x == const {"{ ... }"}`) instead
ast_lowering_argument = argument
ast_lowering_assoc_ty_binding_in_dyn =
associated type bounds are not allowed in `dyn` types
.suggestion = use `impl Trait` to introduce a type instead
ast_lowering_assoc_ty_parentheses =
parenthesized generic arguments cannot be used in associated type constraints
ast_lowering_async_bound_not_on_trait =
`async` bound modifier only allowed on trait, not `{$descr}`
ast_lowering_async_bound_only_for_fn_traits =
`async` bound modifier only allowed on `Fn`/`FnMut`/`FnOnce` traits
ast_lowering_async_coroutines_not_supported =
`async` coroutines are not yet supported
ast_lowering_att_syntax_only_x86 =
the `att_syntax` option is only supported on x86
ast_lowering_await_only_in_async_fn_and_blocks =
`await` is only allowed inside `async` functions and blocks
.label = only allowed inside `async` functions and blocks
ast_lowering_bad_return_type_notation_inputs =
argument types not allowed with return type notation
.suggestion = remove the input types
ast_lowering_bad_return_type_notation_needs_dots = return type notation arguments must be elided with `..`
.suggestion = use the correct syntax by adding `..` to the arguments
ast_lowering_bad_return_type_notation_output =
return type not allowed with return type notation
ast_lowering_bad_return_type_notation_output_suggestion = use the right argument notation and remove the return type
ast_lowering_bad_return_type_notation_position = return type notation not allowed in this position yet
ast_lowering_clobber_abi_not_supported =
`clobber_abi` is not supported on this target
ast_lowering_closure_cannot_be_static = closures cannot be static
ast_lowering_coroutine_too_many_parameters =
too many parameters for a coroutine (expected 0 or 1 parameters)
ast_lowering_default_field_in_tuple = default fields are not supported in tuple structs
.label = default fields are only supported on structs
ast_lowering_delegation_cycle_in_signature_resolution = encountered a cycle during delegation signature resolution
ast_lowering_delegation_unresolved_callee = failed to resolve delegation callee
ast_lowering_does_not_support_modifiers =
the `{$class_name}` register class does not support template modifiers
ast_lowering_extra_double_dot =
`..` can only be used once per {$ctx} pattern
.label = can only be used once per {$ctx} pattern
ast_lowering_functional_record_update_destructuring_assignment =
functional record updates are not allowed in destructuring assignments
.suggestion = consider removing the trailing pattern
ast_lowering_generic_param_default_in_binder =
defaults for generic parameters are not allowed in `for<...>` binders
ast_lowering_generic_type_with_parentheses =
parenthesized type parameters may only be used with a `Fn` trait
.label = only `Fn` traits may use parentheses
ast_lowering_inclusive_range_with_no_end = inclusive range with no end
ast_lowering_inline_asm_unsupported_target =
inline assembly is unsupported on this target
ast_lowering_invalid_abi =
invalid ABI: found `{$abi}`
.label = invalid ABI
.note = invoke `{$command}` for a full list of supported calling conventions
ast_lowering_invalid_abi_clobber_abi =
invalid ABI for `clobber_abi`
.note = the following ABIs are supported on this target: {$supported_abis}
ast_lowering_invalid_abi_suggestion = there's a similarly named valid ABI `{$suggestion}`
ast_lowering_invalid_asm_template_modifier_const =
asm template modifiers are not allowed for `const` arguments
ast_lowering_invalid_asm_template_modifier_label =
asm template modifiers are not allowed for `label` arguments
ast_lowering_invalid_asm_template_modifier_reg_class =
invalid asm template modifier for this register class
ast_lowering_invalid_asm_template_modifier_sym =
asm template modifiers are not allowed for `sym` arguments
ast_lowering_invalid_legacy_const_generic_arg =
invalid argument to a legacy const generic: cannot have const blocks, closures, async blocks or items
ast_lowering_invalid_legacy_const_generic_arg_suggestion =
try using a const generic argument instead
ast_lowering_invalid_register =
invalid register `{$reg}`: {$error}
ast_lowering_invalid_register_class =
invalid register class `{$reg_class}`: unknown register class
.note = the following register classes are supported on this target: {$supported_register_classes}
ast_lowering_match_arm_with_no_body =
`match` arm with no body
.suggestion = add a body after the pattern
ast_lowering_misplaced_double_dot =
`..` patterns are not allowed here
.note = only allowed in tuple, tuple struct, and slice patterns
ast_lowering_misplaced_impl_trait =
`impl Trait` is not allowed in {$position}
.note = `impl Trait` is only allowed in arguments and return types of functions and methods
ast_lowering_never_pattern_with_body =
a never pattern is always unreachable
.label = this will never be executed
.suggestion = remove this expression
ast_lowering_never_pattern_with_guard =
a guard on a never pattern will never be run
.suggestion = remove this guard
ast_lowering_no_precise_captures_on_apit = `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
ast_lowering_previously_used_here = previously used here
ast_lowering_register1 = register `{$reg1_name}`
ast_lowering_register2 = register `{$reg2_name}`
ast_lowering_register_class_only_clobber =
register class `{$reg_class_name}` can only be used as a clobber, not as an input or output
ast_lowering_register_class_only_clobber_stable =
register class `{$reg_class_name}` can only be used as a clobber in stable
ast_lowering_register_conflict =
register `{$reg1_name}` conflicts with register `{$reg2_name}`
.help = use `lateout` instead of `out` to avoid conflict
ast_lowering_remove_parentheses = remove these parentheses
ast_lowering_sub_tuple_binding =
`{$ident_name} @` is not allowed in a {$ctx}
.label = this is only allowed in slice patterns
.help = remove this and bind each tuple field independently
ast_lowering_sub_tuple_binding_suggestion = if you don't need to use the contents of {$ident}, discard the tuple's remaining fields
ast_lowering_support_modifiers =
the `{$class_name}` register class supports the following template modifiers: {$modifiers}
ast_lowering_template_modifier = template modifier
ast_lowering_this_not_async = this is not `async`
ast_lowering_underscore_expr_lhs_assign =
in expressions, `_` can only be used on the left-hand side of an assignment
.label = `_` not allowed here
ast_lowering_union_default_field_values = unions cannot have default field values
ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
ast_lowering_unstable_inline_assembly_label_operand_with_outputs =
using both label and output operands for inline assembly is unstable
ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable
ast_lowering_use_angle_brackets = use angle brackets instead
ast_lowering_yield = yield syntax is experimental
ast_lowering_yield_in_closure =
`yield` can only be used in `#[coroutine]` closures, or `gen` blocks
.suggestion = use `#[coroutine]` to make this closure a coroutine

View file

@ -3,6 +3,7 @@ use std::fmt::Write;
use rustc_ast::*;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_errors::inline_fluent;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_session::parse::feature_err;
@ -19,8 +20,7 @@ use super::errors::{
RegisterConflict,
};
use crate::{
AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, ParamMode,
ResolverAstLoweringExt, fluent_generated as fluent,
AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt,
};
impl<'a, 'hir> LoweringContext<'a, 'hir> {
@ -67,7 +67,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
&self.tcx.sess,
sym::asm_experimental_arch,
sp,
fluent::ast_lowering_unstable_inline_assembly,
inline_fluent!("inline assembly is not stable yet on this architecture"),
)
.emit();
}
@ -84,7 +84,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
&self.tcx.sess,
sym::asm_unwind,
sp,
fluent::ast_lowering_unstable_may_unwind,
inline_fluent!("the `may_unwind` option is unstable"),
)
.emit();
}
@ -499,7 +499,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
sess,
sym::asm_goto_with_outputs,
*op_sp,
fluent::ast_lowering_unstable_inline_assembly_label_operand_with_outputs,
inline_fluent!(
"using both label and output operands for inline assembly is unstable"
),
)
.emit();
}

View file

@ -4,17 +4,17 @@ use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Ident, Span, Symbol};
#[derive(Diagnostic)]
#[diag(ast_lowering_generic_type_with_parentheses, code = E0214)]
#[diag("parenthesized type parameters may only be used with a `Fn` trait", code = E0214)]
pub(crate) struct GenericTypeWithParentheses {
#[primary_span]
#[label]
#[label("only `Fn` traits may use parentheses")]
pub span: Span,
#[subdiagnostic]
pub sub: Option<UseAngleBrackets>,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(ast_lowering_use_angle_brackets, applicability = "maybe-incorrect")]
#[multipart_suggestion("use angle brackets instead", applicability = "maybe-incorrect")]
pub(crate) struct UseAngleBrackets {
#[suggestion_part(code = "<")]
pub open_param: Span,
@ -23,11 +23,11 @@ pub(crate) struct UseAngleBrackets {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_invalid_abi, code = E0703)]
#[note]
#[diag("invalid ABI: found `{$abi}`", code = E0703)]
#[note("invoke `{$command}` for a full list of supported calling conventions")]
pub(crate) struct InvalidAbi {
#[primary_span]
#[label]
#[label("invalid ABI")]
pub span: Span,
pub abi: Symbol,
pub command: String,
@ -36,16 +36,16 @@ pub(crate) struct InvalidAbi {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_default_field_in_tuple)]
#[diag("default fields are not supported in tuple structs")]
pub(crate) struct TupleStructWithDefault {
#[primary_span]
#[label]
#[label("default fields are only supported on structs")]
pub span: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(
ast_lowering_invalid_abi_suggestion,
"there's a similarly named valid ABI `{$suggestion}`",
code = "\"{suggestion}\"",
applicability = "maybe-incorrect",
style = "verbose"
@ -57,7 +57,7 @@ pub(crate) struct InvalidAbiSuggestion {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_assoc_ty_parentheses)]
#[diag("parenthesized generic arguments cannot be used in associated type constraints")]
pub(crate) struct AssocTyParentheses {
#[primary_span]
pub span: Span,
@ -67,12 +67,12 @@ pub(crate) struct AssocTyParentheses {
#[derive(Subdiagnostic)]
pub(crate) enum AssocTyParenthesesSub {
#[multipart_suggestion(ast_lowering_remove_parentheses)]
#[multipart_suggestion("remove these parentheses")]
Empty {
#[suggestion_part(code = "")]
parentheses_span: Span,
},
#[multipart_suggestion(ast_lowering_use_angle_brackets)]
#[multipart_suggestion("use angle brackets instead")]
NotEmpty {
#[suggestion_part(code = "<")]
open_param: Span,
@ -82,8 +82,8 @@ pub(crate) enum AssocTyParenthesesSub {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_misplaced_impl_trait, code = E0562)]
#[note]
#[diag("`impl Trait` is not allowed in {$position}", code = E0562)]
#[note("`impl Trait` is only allowed in arguments and return types of functions and methods")]
pub(crate) struct MisplacedImplTrait<'a> {
#[primary_span]
pub span: Span,
@ -91,97 +91,106 @@ pub(crate) struct MisplacedImplTrait<'a> {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_assoc_ty_binding_in_dyn)]
#[diag("associated type bounds are not allowed in `dyn` types")]
pub(crate) struct MisplacedAssocTyBinding {
#[primary_span]
pub span: Span,
#[suggestion(code = " = impl", applicability = "maybe-incorrect", style = "verbose")]
#[suggestion(
"use `impl Trait` to introduce a type instead",
code = " = impl",
applicability = "maybe-incorrect",
style = "verbose"
)]
pub suggestion: Option<Span>,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_underscore_expr_lhs_assign)]
#[diag("in expressions, `_` can only be used on the left-hand side of an assignment")]
pub(crate) struct UnderscoreExprLhsAssign {
#[primary_span]
#[label]
#[label("`_` not allowed here")]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_await_only_in_async_fn_and_blocks, code = E0728)]
#[diag("`await` is only allowed inside `async` functions and blocks", code = E0728)]
pub(crate) struct AwaitOnlyInAsyncFnAndBlocks {
#[primary_span]
#[label]
#[label("only allowed inside `async` functions and blocks")]
pub await_kw_span: Span,
#[label(ast_lowering_this_not_async)]
#[label("this is not `async`")]
pub item_span: Option<Span>,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_coroutine_too_many_parameters, code = E0628)]
#[diag("too many parameters for a coroutine (expected 0 or 1 parameters)", code = E0628)]
pub(crate) struct CoroutineTooManyParameters {
#[primary_span]
pub fn_decl_span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_closure_cannot_be_static, code = E0697)]
#[diag("closures cannot be static", code = E0697)]
pub(crate) struct ClosureCannotBeStatic {
#[primary_span]
pub fn_decl_span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_functional_record_update_destructuring_assignment)]
#[diag("functional record updates are not allowed in destructuring assignments")]
pub(crate) struct FunctionalRecordUpdateDestructuringAssignment {
#[primary_span]
#[suggestion(code = "", applicability = "machine-applicable")]
#[suggestion(
"consider removing the trailing pattern",
code = "",
applicability = "machine-applicable"
)]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_async_coroutines_not_supported, code = E0727)]
#[diag("`async` coroutines are not yet supported", code = E0727)]
pub(crate) struct AsyncCoroutinesNotSupported {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_inline_asm_unsupported_target, code = E0472)]
#[diag("inline assembly is unsupported on this target", code = E0472)]
pub(crate) struct InlineAsmUnsupportedTarget {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_att_syntax_only_x86)]
#[diag("the `att_syntax` option is only supported on x86")]
pub(crate) struct AttSyntaxOnlyX86 {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_abi_specified_multiple_times)]
#[diag("`{$prev_name}` ABI specified multiple times")]
pub(crate) struct AbiSpecifiedMultipleTimes {
#[primary_span]
pub abi_span: Span,
pub prev_name: Symbol,
#[label]
#[label("previously specified here")]
pub prev_span: Span,
#[note]
#[note("these ABIs are equivalent on the current target")]
pub equivalent: bool,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_clobber_abi_not_supported)]
#[diag("`clobber_abi` is not supported on this target")]
pub(crate) struct ClobberAbiNotSupported {
#[primary_span]
pub abi_span: Span,
}
#[derive(Diagnostic)]
#[note]
#[diag(ast_lowering_invalid_abi_clobber_abi)]
#[note("the following ABIs are supported on this target: {$supported_abis}")]
#[diag("invalid ABI for `clobber_abi`")]
pub(crate) struct InvalidAbiClobberAbi {
#[primary_span]
pub abi_span: Span,
@ -189,7 +198,7 @@ pub(crate) struct InvalidAbiClobberAbi {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_invalid_register)]
#[diag("invalid register `{$reg}`: {$error}")]
pub(crate) struct InvalidRegister<'a> {
#[primary_span]
pub op_span: Span,
@ -198,8 +207,10 @@ pub(crate) struct InvalidRegister<'a> {
}
#[derive(Diagnostic)]
#[note]
#[diag(ast_lowering_invalid_register_class)]
#[note(
"the following register classes are supported on this target: {$supported_register_classes}"
)]
#[diag("invalid register class `{$reg_class}`: unknown register class")]
pub(crate) struct InvalidRegisterClass {
#[primary_span]
pub op_span: Span,
@ -208,12 +219,12 @@ pub(crate) struct InvalidRegisterClass {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_invalid_asm_template_modifier_reg_class)]
#[diag("invalid asm template modifier for this register class")]
pub(crate) struct InvalidAsmTemplateModifierRegClass {
#[primary_span]
#[label(ast_lowering_template_modifier)]
#[label("template modifier")]
pub placeholder_span: Span,
#[label(ast_lowering_argument)]
#[label("argument")]
pub op_span: Span,
#[subdiagnostic]
pub sub: InvalidAsmTemplateModifierRegClassSub,
@ -221,44 +232,48 @@ pub(crate) struct InvalidAsmTemplateModifierRegClass {
#[derive(Subdiagnostic)]
pub(crate) enum InvalidAsmTemplateModifierRegClassSub {
#[note(ast_lowering_support_modifiers)]
#[note(
"the `{$class_name}` register class supports the following template modifiers: {$modifiers}"
)]
SupportModifier { class_name: Symbol, modifiers: String },
#[note(ast_lowering_does_not_support_modifiers)]
#[note("the `{$class_name}` register class does not support template modifiers")]
DoesNotSupportModifier { class_name: Symbol },
}
#[derive(Diagnostic)]
#[diag(ast_lowering_invalid_asm_template_modifier_const)]
#[diag("asm template modifiers are not allowed for `const` arguments")]
pub(crate) struct InvalidAsmTemplateModifierConst {
#[primary_span]
#[label(ast_lowering_template_modifier)]
#[label("template modifier")]
pub placeholder_span: Span,
#[label(ast_lowering_argument)]
#[label("argument")]
pub op_span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_invalid_asm_template_modifier_sym)]
#[diag("asm template modifiers are not allowed for `sym` arguments")]
pub(crate) struct InvalidAsmTemplateModifierSym {
#[primary_span]
#[label(ast_lowering_template_modifier)]
#[label("template modifier")]
pub placeholder_span: Span,
#[label(ast_lowering_argument)]
#[label("argument")]
pub op_span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_invalid_asm_template_modifier_label)]
#[diag("asm template modifiers are not allowed for `label` arguments")]
pub(crate) struct InvalidAsmTemplateModifierLabel {
#[primary_span]
#[label(ast_lowering_template_modifier)]
#[label("template modifier")]
pub placeholder_span: Span,
#[label(ast_lowering_argument)]
#[label("argument")]
pub op_span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_register_class_only_clobber)]
#[diag(
"register class `{$reg_class_name}` can only be used as a clobber, not as an input or output"
)]
pub(crate) struct RegisterClassOnlyClobber {
#[primary_span]
pub op_span: Span,
@ -266,7 +281,7 @@ pub(crate) struct RegisterClassOnlyClobber {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_register_class_only_clobber_stable)]
#[diag("register class `{$reg_class_name}` can only be used as a clobber in stable")]
pub(crate) struct RegisterClassOnlyClobberStable {
#[primary_span]
pub op_span: Span,
@ -274,27 +289,27 @@ pub(crate) struct RegisterClassOnlyClobberStable {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_register_conflict)]
#[diag("register `{$reg1_name}` conflicts with register `{$reg2_name}`")]
pub(crate) struct RegisterConflict<'a> {
#[primary_span]
#[label(ast_lowering_register1)]
#[label("register `{$reg1_name}`")]
pub op_span1: Span,
#[label(ast_lowering_register2)]
#[label("register `{$reg2_name}`")]
pub op_span2: Span,
pub reg1_name: &'a str,
pub reg2_name: &'a str,
#[help]
#[help("use `lateout` instead of `out` to avoid conflict")]
pub in_out: Option<Span>,
}
#[derive(Diagnostic)]
#[help]
#[diag(ast_lowering_sub_tuple_binding)]
#[help("remove this and bind each tuple field independently")]
#[diag("`{$ident_name} @` is not allowed in a {$ctx}")]
pub(crate) struct SubTupleBinding<'a> {
#[primary_span]
#[label]
#[label("this is only allowed in slice patterns")]
#[suggestion(
ast_lowering_sub_tuple_binding_suggestion,
"if you don't need to use the contents of {$ident}, discard the tuple's remaining fields",
style = "verbose",
code = "..",
applicability = "maybe-incorrect"
@ -306,63 +321,67 @@ pub(crate) struct SubTupleBinding<'a> {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_extra_double_dot)]
#[diag("`..` can only be used once per {$ctx} pattern")]
pub(crate) struct ExtraDoubleDot<'a> {
#[primary_span]
#[label]
#[label("can only be used once per {$ctx} pattern")]
pub span: Span,
#[label(ast_lowering_previously_used_here)]
#[label("previously used here")]
pub prev_span: Span,
pub ctx: &'a str,
}
#[derive(Diagnostic)]
#[note]
#[diag(ast_lowering_misplaced_double_dot)]
#[note("only allowed in tuple, tuple struct, and slice patterns")]
#[diag("`..` patterns are not allowed here")]
pub(crate) struct MisplacedDoubleDot {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_match_arm_with_no_body)]
#[diag("`match` arm with no body")]
pub(crate) struct MatchArmWithNoBody {
#[primary_span]
pub span: Span,
#[suggestion(code = " => todo!(),", applicability = "has-placeholders")]
#[suggestion(
"add a body after the pattern",
code = " => todo!(),",
applicability = "has-placeholders"
)]
pub suggestion: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_never_pattern_with_body)]
#[diag("a never pattern is always unreachable")]
pub(crate) struct NeverPatternWithBody {
#[primary_span]
#[label]
#[suggestion(code = "", applicability = "maybe-incorrect")]
#[label("this will never be executed")]
#[suggestion("remove this expression", code = "", applicability = "maybe-incorrect")]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_never_pattern_with_guard)]
#[diag("a guard on a never pattern will never be run")]
pub(crate) struct NeverPatternWithGuard {
#[primary_span]
#[suggestion(code = "", applicability = "maybe-incorrect")]
#[suggestion("remove this guard", code = "", applicability = "maybe-incorrect")]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_arbitrary_expression_in_pattern)]
#[diag("arbitrary expressions aren't allowed in patterns")]
pub(crate) struct ArbitraryExpressionInPattern {
#[primary_span]
pub span: Span,
#[note(ast_lowering_pattern_from_macro_note)]
#[note("the `expr` fragment specifier forces the metavariable's content to be an expression")]
pub pattern_from_macro_note: bool,
#[help(ast_lowering_const_block_in_pattern_help)]
#[help("use a named `const`-item or an `if`-guard (`x if x == const {\"{ ... }\"}`) instead")]
pub const_block_in_pattern_help: bool,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_inclusive_range_with_no_end)]
#[diag("inclusive range with no end")]
pub(crate) struct InclusiveRangeWithNoEnd {
#[primary_span]
pub span: Span,
@ -370,7 +389,7 @@ pub(crate) struct InclusiveRangeWithNoEnd {
#[derive(Subdiagnostic)]
#[multipart_suggestion(
ast_lowering_bad_return_type_notation_output_suggestion,
"use the right argument notation and remove the return type",
applicability = "machine-applicable",
style = "verbose"
)]
@ -384,26 +403,36 @@ pub(crate) struct RTNSuggestion {
#[derive(Diagnostic)]
pub(crate) enum BadReturnTypeNotation {
#[diag(ast_lowering_bad_return_type_notation_inputs)]
#[diag("argument types not allowed with return type notation")]
Inputs {
#[primary_span]
#[suggestion(code = "(..)", applicability = "machine-applicable", style = "verbose")]
#[suggestion(
"remove the input types",
code = "(..)",
applicability = "machine-applicable",
style = "verbose"
)]
span: Span,
},
#[diag(ast_lowering_bad_return_type_notation_output)]
#[diag("return type not allowed with return type notation")]
Output {
#[primary_span]
span: Span,
#[subdiagnostic]
suggestion: RTNSuggestion,
},
#[diag(ast_lowering_bad_return_type_notation_needs_dots)]
#[diag("return type notation arguments must be elided with `..`")]
NeedsDots {
#[primary_span]
#[suggestion(code = "(..)", applicability = "machine-applicable", style = "verbose")]
#[suggestion(
"use the correct syntax by adding `..` to the arguments",
code = "(..)",
applicability = "machine-applicable",
style = "verbose"
)]
span: Span,
},
#[diag(ast_lowering_bad_return_type_notation_position)]
#[diag("return type notation not allowed in this position yet")]
Position {
#[primary_span]
span: Span,
@ -411,14 +440,14 @@ pub(crate) enum BadReturnTypeNotation {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_generic_param_default_in_binder)]
#[diag("defaults for generic parameters are not allowed in `for<...>` binders")]
pub(crate) struct GenericParamDefaultInBinder {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_async_bound_not_on_trait)]
#[diag("`async` bound modifier only allowed on trait, not `{$descr}`")]
pub(crate) struct AsyncBoundNotOnTrait {
#[primary_span]
pub span: Span,
@ -426,30 +455,37 @@ pub(crate) struct AsyncBoundNotOnTrait {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_async_bound_only_for_fn_traits)]
#[diag("`async` bound modifier only allowed on `Fn`/`FnMut`/`FnOnce` traits")]
pub(crate) struct AsyncBoundOnlyForFnTraits {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_no_precise_captures_on_apit)]
#[diag("`use<...>` precise capturing syntax not allowed in argument-position `impl Trait`")]
pub(crate) struct NoPreciseCapturesOnApit {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_yield_in_closure)]
#[diag("`yield` can only be used in `#[coroutine]` closures, or `gen` blocks")]
pub(crate) struct YieldInClosure {
#[primary_span]
pub span: Span,
#[suggestion(code = "#[coroutine] ", applicability = "maybe-incorrect", style = "verbose")]
#[suggestion(
"use `#[coroutine]` to make this closure a coroutine",
code = "#[coroutine] ",
applicability = "maybe-incorrect",
style = "verbose"
)]
pub suggestion: Option<Span>,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_invalid_legacy_const_generic_arg)]
#[diag(
"invalid argument to a legacy const generic: cannot have const blocks, closures, async blocks or items"
)]
pub(crate) struct InvalidLegacyConstGenericArg {
#[primary_span]
pub span: Span,
@ -459,7 +495,7 @@ pub(crate) struct InvalidLegacyConstGenericArg {
#[derive(Subdiagnostic)]
#[multipart_suggestion(
ast_lowering_invalid_legacy_const_generic_arg_suggestion,
"try using a const generic argument instead",
applicability = "maybe-incorrect"
)]
pub(crate) struct UseConstGenericArg {
@ -472,21 +508,21 @@ pub(crate) struct UseConstGenericArg {
}
#[derive(Diagnostic)]
#[diag(ast_lowering_union_default_field_values)]
#[diag("unions cannot have default field values")]
pub(crate) struct UnionWithDefault {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_delegation_unresolved_callee)]
#[diag("failed to resolve delegation callee")]
pub(crate) struct UnresolvedDelegationCallee {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_lowering_delegation_cycle_in_signature_resolution)]
#[diag("encountered a cycle during delegation signature resolution")]
pub(crate) struct CycleInDelegationSignatureResolution {
#[primary_span]
pub span: Span,

View file

@ -5,6 +5,7 @@ use std::sync::Arc;
use rustc_ast::*;
use rustc_ast_pretty::pprust::expr_to_string;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::inline_fluent;
use rustc_hir as hir;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::{DefKind, Res};
@ -28,9 +29,7 @@ use super::{
GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode, ResolverAstLoweringExt,
};
use crate::errors::{InvalidLegacyConstGenericArg, UseConstGenericArg, YieldInClosure};
use crate::{
AllowReturnTypeNotation, FnDeclKind, ImplTraitPosition, TryBlockScope, fluent_generated,
};
use crate::{AllowReturnTypeNotation, FnDeclKind, ImplTraitPosition, TryBlockScope};
struct WillCreateDefIdsVisitor {}
@ -1703,7 +1702,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
&self.tcx.sess,
sym::yield_expr,
span,
fluent_generated::ast_lowering_yield,
inline_fluent!("yield syntax is experimental"),
)
.emit();
}

View file

@ -88,8 +88,6 @@ mod pat;
mod path;
pub mod stability;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
struct LoweringContext<'a, 'hir> {
tcx: TyCtxt<'hir>,
resolver: &'a mut ResolverAstLowering,

View file

@ -1,12 +1,16 @@
use std::path::PathBuf;
use rustc_ast::{LitIntType, LitKind, MetaItemLit};
use rustc_hir::attrs::{BorrowckGraphvizFormatKind, RustcLayoutType, RustcMirKind};
use rustc_hir::attrs::{
BorrowckGraphvizFormatKind, RustcCleanAttribute, RustcCleanQueries, RustcLayoutType,
RustcMirKind,
};
use rustc_session::errors;
use rustc_span::Symbol;
use super::prelude::*;
use super::util::parse_single_integer;
use crate::session_diagnostics::RustcScalableVectorCountOutOfRange;
use crate::session_diagnostics::{AttributeRequiresOpt, RustcScalableVectorCountOutOfRange};
pub(crate) struct RustcMainParser;
@ -234,7 +238,7 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcLintUntrackedQueryInformationPa
pub(crate) struct RustcObjectLifetimeDefaultParser;
impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser {
const PATH: &[rustc_span::Symbol] = &[sym::rustc_object_lifetime_default];
const PATH: &[Symbol] = &[sym::rustc_object_lifetime_default];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
@ -271,7 +275,7 @@ impl<S: Stage> SingleAttributeParser<S> for RustcSimdMonomorphizeLaneLimitParser
pub(crate) struct RustcScalableVectorParser;
impl<S: Stage> SingleAttributeParser<S> for RustcScalableVectorParser {
const PATH: &[rustc_span::Symbol] = &[sym::rustc_scalable_vector];
const PATH: &[Symbol] = &[sym::rustc_scalable_vector];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
@ -344,7 +348,7 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcOffloadKernelParser {
pub(crate) struct RustcLayoutParser;
impl<S: Stage> CombineAttributeParser<S> for RustcLayoutParser {
const PATH: &[rustc_span::Symbol] = &[sym::rustc_layout];
const PATH: &[Symbol] = &[sym::rustc_layout];
type Item = RustcLayoutType;
@ -401,7 +405,7 @@ impl<S: Stage> CombineAttributeParser<S> for RustcLayoutParser {
pub(crate) struct RustcMirParser;
impl<S: Stage> CombineAttributeParser<S> for RustcMirParser {
const PATH: &[rustc_span::Symbol] = &[sym::rustc_mir];
const PATH: &[Symbol] = &[sym::rustc_mir];
type Item = RustcMirKind;
@ -497,3 +501,223 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcNonConstTraitMethodParser {
]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNonConstTraitMethod;
}
pub(crate) struct RustcCleanParser;
impl<S: Stage> CombineAttributeParser<S> for RustcCleanParser {
const PATH: &[Symbol] = &[sym::rustc_clean];
type Item = RustcCleanAttribute;
const CONVERT: ConvertFn<Self::Item> = |items, _| AttributeKind::RustcClean(items);
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
// tidy-alphabetical-start
Allow(Target::AssocConst),
Allow(Target::AssocTy),
Allow(Target::Const),
Allow(Target::Enum),
Allow(Target::Expression),
Allow(Target::Field),
Allow(Target::Fn),
Allow(Target::ForeignMod),
Allow(Target::Impl { of_trait: false }),
Allow(Target::Impl { of_trait: true }),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Mod),
Allow(Target::Static),
Allow(Target::Struct),
Allow(Target::Trait),
Allow(Target::TyAlias),
Allow(Target::Union),
// tidy-alphabetical-end
]);
const TEMPLATE: AttributeTemplate =
template!(List: &[r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#]);
fn extend(
cx: &mut AcceptContext<'_, '_, S>,
args: &ArgParser,
) -> impl IntoIterator<Item = Self::Item> {
if !cx.cx.sess.opts.unstable_opts.query_dep_graph {
cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" });
}
let Some(list) = args.list() else {
cx.expected_list(cx.attr_span, args);
return None;
};
let mut except = None;
let mut loaded_from_disk = None;
let mut cfg = None;
for item in list.mixed() {
let Some((value, name)) =
item.meta_item().and_then(|m| Option::zip(m.args().name_value(), m.ident()))
else {
cx.expected_name_value(item.span(), None);
continue;
};
let value_span = value.value_span;
let Some(value) = value.value_as_str() else {
cx.expected_string_literal(value_span, None);
continue;
};
match name.name {
sym::cfg if cfg.is_some() => {
cx.duplicate_key(item.span(), sym::cfg);
}
sym::cfg => {
cfg = Some(value);
}
sym::except if except.is_some() => {
cx.duplicate_key(item.span(), sym::except);
}
sym::except => {
let entries =
value.as_str().split(',').map(|s| Symbol::intern(s.trim())).collect();
except = Some(RustcCleanQueries { entries, span: value_span });
}
sym::loaded_from_disk if loaded_from_disk.is_some() => {
cx.duplicate_key(item.span(), sym::loaded_from_disk);
}
sym::loaded_from_disk => {
let entries =
value.as_str().split(',').map(|s| Symbol::intern(s.trim())).collect();
loaded_from_disk = Some(RustcCleanQueries { entries, span: value_span });
}
_ => {
cx.expected_specific_argument(
name.span,
&[sym::cfg, sym::except, sym::loaded_from_disk],
);
}
}
}
let Some(cfg) = cfg else {
cx.expected_specific_argument(list.span, &[sym::cfg]);
return None;
};
Some(RustcCleanAttribute { span: cx.attr_span, cfg, except, loaded_from_disk })
}
}
pub(crate) struct RustcIfThisChangedParser;
impl<S: Stage> SingleAttributeParser<S> for RustcIfThisChangedParser {
const PATH: &[Symbol] = &[sym::rustc_if_this_changed];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
// tidy-alphabetical-start
Allow(Target::AssocConst),
Allow(Target::AssocTy),
Allow(Target::Const),
Allow(Target::Enum),
Allow(Target::Expression),
Allow(Target::Field),
Allow(Target::Fn),
Allow(Target::ForeignMod),
Allow(Target::Impl { of_trait: false }),
Allow(Target::Impl { of_trait: true }),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Mod),
Allow(Target::Static),
Allow(Target::Struct),
Allow(Target::Trait),
Allow(Target::TyAlias),
Allow(Target::Union),
// tidy-alphabetical-end
]);
const TEMPLATE: AttributeTemplate = template!(Word, List: &["DepNode"]);
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
if !cx.cx.sess.opts.unstable_opts.query_dep_graph {
cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" });
}
match args {
ArgParser::NoArgs => Some(AttributeKind::RustcIfThisChanged(cx.attr_span, None)),
ArgParser::List(list) => {
let Some(item) = list.single() else {
cx.expected_single_argument(list.span);
return None;
};
let Some(ident) = item.meta_item().and_then(|item| item.ident()) else {
cx.expected_identifier(item.span());
return None;
};
Some(AttributeKind::RustcIfThisChanged(cx.attr_span, Some(ident.name)))
}
ArgParser::NameValue(_) => {
cx.expected_list_or_no_args(cx.inner_span);
None
}
}
}
}
pub(crate) struct RustcThenThisWouldNeedParser;
impl<S: Stage> CombineAttributeParser<S> for RustcThenThisWouldNeedParser {
const PATH: &[Symbol] = &[sym::rustc_then_this_would_need];
type Item = Ident;
const CONVERT: ConvertFn<Self::Item> =
|items, span| AttributeKind::RustcThenThisWouldNeed(span, items);
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
// tidy-alphabetical-start
Allow(Target::AssocConst),
Allow(Target::AssocTy),
Allow(Target::Const),
Allow(Target::Enum),
Allow(Target::Expression),
Allow(Target::Field),
Allow(Target::Fn),
Allow(Target::ForeignMod),
Allow(Target::Impl { of_trait: false }),
Allow(Target::Impl { of_trait: true }),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Mod),
Allow(Target::Static),
Allow(Target::Struct),
Allow(Target::Trait),
Allow(Target::TyAlias),
Allow(Target::Union),
// tidy-alphabetical-end
]);
const TEMPLATE: AttributeTemplate = template!(List: &["DepNode"]);
fn extend(
cx: &mut AcceptContext<'_, '_, S>,
args: &ArgParser,
) -> impl IntoIterator<Item = Self::Item> {
if !cx.cx.sess.opts.unstable_opts.query_dep_graph {
cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" });
}
let Some(item) = args.list().and_then(|l| l.single()) else {
cx.expected_single_argument(cx.inner_span);
return None;
};
let Some(ident) = item.meta_item().and_then(|item| item.ident()) else {
cx.expected_identifier(item.span());
return None;
};
Some(ident)
}
}

View file

@ -113,3 +113,30 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcVarianceOfOpaquesParser {
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcVarianceOfOpaques;
}
pub(crate) struct ReexportTestHarnessMainParser;
impl<S: Stage> SingleAttributeParser<S> for ReexportTestHarnessMainParser {
const PATH: &[Symbol] = &[sym::reexport_test_harness_main];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
let Some(nv) = args.name_value() else {
cx.expected_name_value(
args.span().unwrap_or(cx.inner_span),
Some(sym::reexport_test_harness_main),
);
return None;
};
let Some(name) = nv.value_as_str() else {
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
return None;
};
Some(AttributeKind::ReexportTestHarnessMain(name))
}
}

View file

@ -153,8 +153,10 @@ attribute_parsers!(
Combine<ForceTargetFeatureParser>,
Combine<LinkParser>,
Combine<ReprParser>,
Combine<RustcCleanParser>,
Combine<RustcLayoutParser>,
Combine<RustcMirParser>,
Combine<RustcThenThisWouldNeedParser>,
Combine<TargetFeatureParser>,
Combine<UnstableFeatureBoundParser>,
// tidy-alphabetical-end
@ -188,9 +190,11 @@ attribute_parsers!(
Single<PatternComplexityLimitParser>,
Single<ProcMacroDeriveParser>,
Single<RecursionLimitParser>,
Single<ReexportTestHarnessMainParser>,
Single<RustcAllocatorZeroedVariantParser>,
Single<RustcBuiltinMacroParser>,
Single<RustcForceInlineParser>,
Single<RustcIfThisChangedParser>,
Single<RustcLayoutScalarValidRangeEndParser>,
Single<RustcLayoutScalarValidRangeStartParser>,
Single<RustcLegacyConstGenericsParser>,

View file

@ -532,6 +532,14 @@ pub(crate) struct RustcScalableVectorCountOutOfRange {
pub n: u128,
}
#[derive(Diagnostic)]
#[diag("attribute requires {$opt} to be enabled")]
pub(crate) struct AttributeRequiresOpt {
#[primary_span]
pub span: Span,
pub opt: &'static str,
}
pub(crate) enum AttributeParseErrorReason<'a> {
ExpectedNoArgs,
ExpectedStringLiteral {

View file

@ -347,7 +347,6 @@ pub(crate) struct OffloadKernelGlobals<'ll> {
pub offload_sizes: &'ll llvm::Value,
pub memtransfer_types: &'ll llvm::Value,
pub region_id: &'ll llvm::Value,
pub offload_entry: &'ll llvm::Value,
}
fn gen_tgt_data_mappers<'ll>(
@ -468,8 +467,12 @@ pub(crate) fn gen_define_handling<'ll>(
let c_section_name = CString::new("llvm_offload_entries").unwrap();
llvm::set_section(offload_entry, &c_section_name);
let result =
OffloadKernelGlobals { offload_sizes, memtransfer_types, region_id, offload_entry };
cx.add_compiler_used_global(offload_entry);
let result = OffloadKernelGlobals { offload_sizes, memtransfer_types, region_id };
// FIXME(Sa4dUs): use this global for constant offload sizes
cx.add_compiler_used_global(result.offload_sizes);
cx.offload_kernel_cache.borrow_mut().insert(symbol, result);
@ -532,8 +535,7 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
offload_dims: &OffloadKernelDims<'ll>,
) {
let cx = builder.cx;
let OffloadKernelGlobals { offload_sizes, offload_entry, memtransfer_types, region_id } =
offload_data;
let OffloadKernelGlobals { memtransfer_types, region_id, .. } = offload_data;
let OffloadKernelDims { num_workgroups, threads_per_block, workgroup_dims, thread_dims } =
offload_dims;
@ -548,20 +550,6 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
let num_args = types.len() as u64;
let bb = builder.llbb();
// FIXME(Sa4dUs): dummy loads are a temp workaround, we should find a proper way to prevent these
// variables from being optimized away
for val in [offload_sizes, offload_entry] {
unsafe {
let dummy = llvm::LLVMBuildLoad2(
&builder.llbuilder,
llvm::LLVMTypeOf(val),
val,
b"dummy\0".as_ptr() as *const _,
);
llvm::LLVMSetVolatile(dummy, llvm::TRUE);
}
}
// Step 0)
unsafe {
llvm::LLVMRustPositionBuilderPastAllocas(&builder.llbuilder, builder.llfn());

View file

@ -18,7 +18,6 @@ rustc_ast = { path = "../rustc_ast" }
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
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,397 +0,0 @@
codegen_ssa_L4Bender_exporting_symbols_unimplemented = exporting symbols not implemented yet for L4Bender
codegen_ssa_aarch64_softfloat_neon = enabling the `neon` target feature on the current target is unsound due to ABI issues
codegen_ssa_add_native_library = failed to add native library {$library_path}: {$error}
codegen_ssa_aix_strip_not_used = using host's `strip` binary to cross-compile to AIX which is not guaranteed to work
codegen_ssa_archive_build_failure = failed to build archive at `{$path}`: {$error}
codegen_ssa_binary_output_to_tty = option `-o` or `--emit` is used to write binary output type `{$shorthand}` to stdout, but stdout is a tty
codegen_ssa_bpf_staticlib_not_supported = linking static libraries is not supported for BPF
codegen_ssa_cgu_not_recorded =
CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded
codegen_ssa_check_installed_visual_studio = please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.
codegen_ssa_compiler_builtins_cannot_call =
`compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `{$caller}` to `{$callee}`
codegen_ssa_copy_path = could not copy {$from} to {$to}: {$error}
codegen_ssa_copy_path_buf = unable to copy {$source_file} to {$output_path}: {$error}
codegen_ssa_cpu_required = target requires explicitly specifying a cpu with `-C target-cpu`
codegen_ssa_create_temp_dir = couldn't create a temp dir: {$error}
codegen_ssa_dlltool_fail_import_library =
dlltool could not create import library with {$dlltool_path} {$dlltool_args}:
{$stdout}
{$stderr}
codegen_ssa_dynamic_linking_with_lto =
cannot prefer dynamic linking when performing LTO
.note = only 'staticlib', 'bin', and 'cdylib' outputs are supported with LTO
codegen_ssa_error_calling_dlltool =
error calling dlltool '{$dlltool_path}': {$error}
codegen_ssa_error_creating_import_library =
error creating import library for {$lib_name}: {$error}
codegen_ssa_error_creating_remark_dir = failed to create remark directory: {$error}
codegen_ssa_error_writing_def_file =
error writing .DEF file: {$error}
codegen_ssa_extern_funcs_not_found = some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
codegen_ssa_extract_bundled_libs_archive_member = failed to get data from archive member '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_convert_name = failed to convert name '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_mmap_file = failed to mmap file '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_open_file = failed to open file '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_parse_archive = failed to parse archive '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_read_entry = failed to read entry '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_write_file = failed to write file '{$rlib}': {$error}
codegen_ssa_failed_to_get_layout = failed to get layout for {$ty}: {$err}
codegen_ssa_failed_to_write = failed to write {$path}: {$error}
codegen_ssa_feature_not_valid = the feature named `{$feature}` is not valid for this target
.label = `{$feature}` is not valid for this target
.help = consider removing the leading `+` in the feature name
codegen_ssa_field_associated_value_expected = associated value expected for `{$name}`
codegen_ssa_forbidden_ctarget_feature =
target feature `{$feature}` cannot be {$enabled} with `-Ctarget-feature`: {$reason}
.note = this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
codegen_ssa_forbidden_ctarget_feature_issue = for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
codegen_ssa_forbidden_target_feature_attr =
target feature `{$feature}` cannot be enabled with `#[target_feature]`: {$reason}
codegen_ssa_ignoring_emit_path = ignoring emit path because multiple .{$extension} files were produced
codegen_ssa_ignoring_output = ignoring -o because multiple .{$extension} files were produced
codegen_ssa_incorrect_cgu_reuse_type =
CGU-reuse for `{$cgu_user_name}` is `{$actual_reuse}` but should be {$at_least ->
[one] {"at least "}
*[other] {""}
}`{$expected_reuse}`
codegen_ssa_insufficient_vs_code_product = VS Code is a different product, and is not sufficient.
codegen_ssa_invalid_monomorphization_basic_float_type = invalid monomorphization of `{$name}` intrinsic: expected basic float type, found `{$ty}`
codegen_ssa_invalid_monomorphization_basic_integer_or_ptr_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer or pointer type, found `{$ty}`
codegen_ssa_invalid_monomorphization_basic_integer_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`
codegen_ssa_invalid_monomorphization_cannot_return = invalid monomorphization of `{$name}` intrinsic: cannot return `{$ret_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
codegen_ssa_invalid_monomorphization_cast_wide_pointer = invalid monomorphization of `{$name}` intrinsic: cannot cast wide pointer `{$ty}`
codegen_ssa_invalid_monomorphization_expected_element_type = invalid monomorphization of `{$name}` intrinsic: expected element type `{$expected_element}` of second argument `{$second_arg}` to be a pointer to the element type `{$in_elem}` of the first argument `{$in_ty}`, found `{$expected_element}` != `{$mutability} {$in_elem}`
codegen_ssa_invalid_monomorphization_expected_pointer = invalid monomorphization of `{$name}` intrinsic: expected pointer, got `{$ty}`
codegen_ssa_invalid_monomorphization_expected_return_type = invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_ty}`, found `{$ret_ty}`
codegen_ssa_invalid_monomorphization_expected_usize = invalid monomorphization of `{$name}` intrinsic: expected `usize`, got `{$ty}`
codegen_ssa_invalid_monomorphization_expected_vector_element_type = invalid monomorphization of `{$name}` intrinsic: expected element type `{$expected_element}` of vector type `{$vector_type}` to be a signed or unsigned integer type
codegen_ssa_invalid_monomorphization_float_to_int_unchecked = invalid monomorphization of `float_to_int_unchecked` intrinsic: expected basic float type, found `{$ty}`
codegen_ssa_invalid_monomorphization_floating_point_type = invalid monomorphization of `{$name}` intrinsic: `{$in_ty}` is not a floating-point type
codegen_ssa_invalid_monomorphization_floating_point_vector = invalid monomorphization of `{$name}` intrinsic: unsupported element type `{$f_ty}` of floating-point vector `{$in_ty}`
codegen_ssa_invalid_monomorphization_inserted_type = invalid monomorphization of `{$name}` intrinsic: expected inserted type `{$in_elem}` (element of input `{$in_ty}`), found `{$out_ty}`
codegen_ssa_invalid_monomorphization_invalid_bitmask = invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{$mask_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
codegen_ssa_invalid_monomorphization_mask_wrong_element_type = invalid monomorphization of `{$name}` intrinsic: expected mask element type to be an integer, found `{$ty}`
codegen_ssa_invalid_monomorphization_mismatched_lengths = invalid monomorphization of `{$name}` intrinsic: mismatched lengths: mask length `{$m_len}` != other vector length `{$v_len}`
codegen_ssa_invalid_monomorphization_non_scalable_type = invalid monomorphization of `{$name}` intrinsic: expected non-scalable type, found scalable type `{$ty}`
codegen_ssa_invalid_monomorphization_return_element = invalid monomorphization of `{$name}` intrinsic: expected return element type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}` with element type `{$out_ty}`
codegen_ssa_invalid_monomorphization_return_integer_type = invalid monomorphization of `{$name}` intrinsic: expected return type with integer elements, found `{$ret_ty}` with non-integer `{$out_ty}`
codegen_ssa_invalid_monomorphization_return_length = invalid monomorphization of `{$name}` intrinsic: expected return type of length {$in_len}, found `{$ret_ty}` with length {$out_len}
codegen_ssa_invalid_monomorphization_return_length_input_type = invalid monomorphization of `{$name}` intrinsic: expected return type with length {$in_len} (same as input type `{$in_ty}`), found `{$ret_ty}` with length {$out_len}
codegen_ssa_invalid_monomorphization_return_type = invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}`
codegen_ssa_invalid_monomorphization_second_argument_length = invalid monomorphization of `{$name}` intrinsic: expected second argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len}
codegen_ssa_invalid_monomorphization_simd_argument = invalid monomorphization of `{$name}` intrinsic: expected SIMD argument type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_first = invalid monomorphization of `{$name}` intrinsic: expected SIMD first type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_index_out_of_bounds = invalid monomorphization of `{$name}` intrinsic: SIMD index #{$arg_idx} is out of bounds (limit {$total_len})
codegen_ssa_invalid_monomorphization_simd_input = invalid monomorphization of `{$name}` intrinsic: expected SIMD input type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_return = invalid monomorphization of `{$name}` intrinsic: expected SIMD return type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_second = invalid monomorphization of `{$name}` intrinsic: expected SIMD second type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_shuffle = invalid monomorphization of `{$name}` intrinsic: simd_shuffle index must be a SIMD vector of `u32`, got `{$ty}`
codegen_ssa_invalid_monomorphization_simd_third = invalid monomorphization of `{$name}` intrinsic: expected SIMD third type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_third_argument_length = invalid monomorphization of `{$name}` intrinsic: expected third argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len}
codegen_ssa_invalid_monomorphization_unrecognized_intrinsic = invalid monomorphization of `{$name}` intrinsic: unrecognized intrinsic `{$name}`
codegen_ssa_invalid_monomorphization_unsupported_cast = invalid monomorphization of `{$name}` intrinsic: unsupported cast from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}` with element `{$out_elem}`
codegen_ssa_invalid_monomorphization_unsupported_operation = invalid monomorphization of `{$name}` intrinsic: unsupported operation on `{$in_ty}` with element `{$in_elem}`
codegen_ssa_invalid_monomorphization_unsupported_symbol = invalid monomorphization of `{$name}` intrinsic: unsupported {$symbol} from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}`
codegen_ssa_invalid_monomorphization_unsupported_symbol_of_size = invalid monomorphization of `{$name}` intrinsic: unsupported {$symbol} from `{$in_ty}` with element `{$in_elem}` of size `{$size}` to `{$ret_ty}`
codegen_ssa_ld64_unimplemented_modifier = `as-needed` modifier not implemented yet for ld64
codegen_ssa_lib_def_write_failure = failed to write lib.def file: {$error}
codegen_ssa_link_exe_status_stack_buffer_overrun = 0xc0000409 is `STATUS_STACK_BUFFER_OVERRUN`
.abort_note = this may have been caused by a program abort and not a stack buffer overrun
.event_log_note = consider checking the Application Event Log for Windows Error Reporting events to see the fail fast error code
codegen_ssa_link_exe_unexpected_error = `link.exe` returned an unexpected error
codegen_ssa_link_script_unavailable = can only use link script when linking with GNU-like linker
codegen_ssa_link_script_write_failure = failed to write link script to {$path}: {$error}
codegen_ssa_linker_file_stem = couldn't extract file stem from specified linker
codegen_ssa_linker_not_found = linker `{$linker_path}` not found
.note = {$error}
codegen_ssa_linker_output = {$inner}
codegen_ssa_linker_unsupported_modifier = `as-needed` modifier not supported for current linker
codegen_ssa_linking_failed = linking with `{$linker_path}` failed: {$exit_status}
codegen_ssa_lto_disallowed = lto can only be run for executables, cdylibs and static library outputs
codegen_ssa_lto_dylib = lto cannot be used for `dylib` crate type without `-Zdylib-lto`
codegen_ssa_lto_proc_macro = lto cannot be used for `proc-macro` crate type without `-Zdylib-lto`
codegen_ssa_malformed_cgu_name =
found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case).
codegen_ssa_missing_cpp_build_tool_component = or a necessary component may be missing from the "C++ build tools" workload
codegen_ssa_missing_features = add the missing features in a `target_feature` attribute
codegen_ssa_missing_query_depgraph =
found CGU-reuse attribute but `-Zquery-dep-graph` was not specified
codegen_ssa_msvc_missing_linker = the msvc targets depend on the msvc linker but `link.exe` was not found
codegen_ssa_multiple_external_func_decl = multiple declarations of external function `{$function}` from library `{$library_name}` have different calling conventions
codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple times
.help = did you use `#[no_mangle]` on `fn main`? Use `#![no_main]` to suppress the usual Rust-generated entry point
codegen_ssa_no_field = no field `{$name}`
codegen_ssa_no_module_named =
no module named `{$user_path}` (mangled: {$cgu_name}). available modules: {$cgu_names}
codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}
codegen_ssa_no_saved_object_file = cached cgu {$cgu_name} should have an object file, but doesn't
codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status}
.note = {$output}
codegen_ssa_read_file = failed to read file: {$message}
codegen_ssa_repair_vs_build_tools = the Visual Studio build tools may need to be repaired using the Visual Studio installer
codegen_ssa_requires_rust_abi = `#[track_caller]` requires Rust ABI
codegen_ssa_rlib_archive_build_failure = failed to build archive from rlib at `{$path}`: {$error}
codegen_ssa_rlib_incompatible_dependency_formats = `{$ty1}` and `{$ty2}` do not have equivalent dependency formats (`{$list1}` vs `{$list2}`)
codegen_ssa_rlib_missing_format = could not find formats for rlibs
codegen_ssa_rlib_not_found = could not find rlib for: `{$crate_name}`
codegen_ssa_rlib_only_rmeta_found = could not find rlib for: `{$crate_name}`, found rmeta (metadata) file
codegen_ssa_select_cpp_build_tool_workload = in the Visual Studio installer, ensure the "C++ build tools" workload is selected
codegen_ssa_self_contained_linker_missing = the self-contained linker was requested, but it wasn't found in the target's sysroot, or in rustc's sysroot
codegen_ssa_shuffle_indices_evaluation = could not evaluate shuffle_indices at compile time
codegen_ssa_specify_libraries_to_link = use the `-l` flag to specify native libraries to link
codegen_ssa_static_library_native_artifacts = link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.
codegen_ssa_static_library_native_artifacts_to_file = native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms.
codegen_ssa_stripping_debug_info_failed = stripping debug info with `{$util}` failed: {$status}
.note = {$output}
codegen_ssa_symbol_file_write_failure = failed to write symbols file: {$error}
codegen_ssa_target_feature_disable_or_enable =
the target features {$features} must all be either enabled or disabled together
codegen_ssa_target_feature_safe_trait = `#[target_feature(..)]` cannot be applied to safe trait method
.label = cannot be applied to safe trait method
.label_def = not an `unsafe` function
codegen_ssa_thorin_decompress_data = failed to decompress compressed section
codegen_ssa_thorin_duplicate_unit = duplicate split compilation unit ({$unit})
codegen_ssa_thorin_empty_unit = unit {$unit} in input DWARF object with no data
codegen_ssa_thorin_gimli_read = {$error}
codegen_ssa_thorin_gimli_write = {$error}
codegen_ssa_thorin_incompatible_index_version = incompatible `{$section}` index version: found version {$actual}, expected version {$format}
codegen_ssa_thorin_invalid_input_kind = input is not an archive or elf object
codegen_ssa_thorin_io = {$error}
codegen_ssa_thorin_missing_dwo_name = missing path attribute to DWARF object ({$id})
codegen_ssa_thorin_missing_referenced_unit = unit {$unit} referenced by executable was not found
codegen_ssa_thorin_missing_required_section = input object missing required section `{$section}`
codegen_ssa_thorin_mixed_input_encodings = input objects have mixed encodings
codegen_ssa_thorin_multiple_debug_info_section = multiple `.debug_info.dwo` sections
codegen_ssa_thorin_multiple_debug_types_section = multiple `.debug_types.dwo` sections in a package
codegen_ssa_thorin_multiple_relocations = multiple relocations for section `{$section}` at offset {$offset}
codegen_ssa_thorin_no_compilation_units = input object has no compilation units
codegen_ssa_thorin_no_die = no top-level debugging information entry in compilation/type unit
codegen_ssa_thorin_not_output_object_created = no output object was created from inputs
codegen_ssa_thorin_not_split_unit = regular compilation unit in object (missing dwo identifier)
codegen_ssa_thorin_object_read = {$error}
codegen_ssa_thorin_object_write = {$error}
codegen_ssa_thorin_offset_at_index = read offset at index {$index} of `.debug_str_offsets.dwo` section
codegen_ssa_thorin_parse_archive_member = failed to parse archive member
codegen_ssa_thorin_parse_index = failed to parse `{$section}` index section
codegen_ssa_thorin_parse_input_archive_file = failed to parse input archive file
codegen_ssa_thorin_parse_input_file_kind = failed to parse input file kind
codegen_ssa_thorin_parse_input_object_file = failed to parse input object file
codegen_ssa_thorin_parse_unit = failed to parse unit
codegen_ssa_thorin_parse_unit_abbreviations = failed to parse unit abbreviations
codegen_ssa_thorin_parse_unit_attribute = failed to parse unit attribute
codegen_ssa_thorin_parse_unit_header = failed to parse unit header
codegen_ssa_thorin_read_input_failure = failed to read input file
codegen_ssa_thorin_relocation_with_invalid_symbol = relocation with invalid symbol for section `{$section}` at offset {$offset}
codegen_ssa_thorin_row_not_in_index = row {$row} found in index's hash table not present in index
codegen_ssa_thorin_section_not_in_row = section not found in unit's row in index
codegen_ssa_thorin_section_without_name = section without name at offset {$offset}
codegen_ssa_thorin_str_at_offset = read string at offset {$offset} of `.debug_str.dwo` section
codegen_ssa_thorin_top_level_die_not_unit = top-level debugging information entry is not a compilation/type unit
codegen_ssa_thorin_unit_not_in_index = unit {$unit} from input package is not in its index
codegen_ssa_thorin_unsupported_relocation = unsupported relocation for section {$section} at offset {$offset}
codegen_ssa_unable_to_exe_linker = could not exec the linker `{$linker_path}`
.note = {$error}
.command_note = {$command_formatted}
codegen_ssa_unable_to_run = unable to run `{$util}`: {$error}
codegen_ssa_unable_to_run_dsymutil = unable to run `dsymutil`: {$error}
codegen_ssa_unable_to_write_debugger_visualizer = unable to write debugger visualizer file `{$path}`: {$error}
codegen_ssa_unknown_archive_kind =
don't know how to build archive of type: {$kind}
codegen_ssa_unknown_ctarget_feature =
unknown and unstable feature specified for `-Ctarget-feature`: `{$feature}`
.note = it is still passed through to the codegen backend, but use of this feature might be unsound and the behavior of this feature can change in the future
.possible_feature = you might have meant: `{$rust_feature}`
.consider_filing_feature_request = consider filing a feature request
codegen_ssa_unknown_ctarget_feature_prefix =
unknown feature specified for `-Ctarget-feature`: `{$feature}`
.note = features must begin with a `+` to enable or `-` to disable it
codegen_ssa_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
codegen_ssa_unstable_ctarget_feature =
unstable feature specified for `-Ctarget-feature`: `{$feature}`
.note = this feature is not stably supported; its behavior can change in the future
codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target
codegen_ssa_use_cargo_directive = use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
codegen_ssa_version_script_write_failure = failed to write version script: {$error}
codegen_ssa_visual_studio_not_installed = you may need to install Visual Studio build tools with the "C++ build tools" workload
codegen_ssa_xcrun_about =
the SDK is needed by the linker to know where to find symbols in system libraries and for embedding the SDK version in the final object file
codegen_ssa_xcrun_command_line_tools_insufficient =
when compiling for iOS, tvOS, visionOS or watchOS, you need a full installation of Xcode
codegen_ssa_xcrun_failed_invoking = invoking `{$command_formatted}` to find {$sdk_name}.sdk failed: {$error}
codegen_ssa_xcrun_found_developer_dir = found active developer directory at "{$developer_dir}"
# `xcrun` already outputs a message about missing Xcode installation, so we only augment it with details about env vars.
codegen_ssa_xcrun_no_developer_dir =
pass the path of an Xcode installation via the DEVELOPER_DIR environment variable, or an SDK with the SDKROOT environment variable
codegen_ssa_xcrun_sdk_path_warning = output of `xcrun` while finding {$sdk_name}.sdk
.note = {$stderr}
codegen_ssa_xcrun_unsuccessful = failed running `{$command_formatted}` to find {$sdk_name}.sdk
.note = {$stdout}{$stderr}

View file

@ -3,6 +3,7 @@ use std::path::PathBuf;
use std::process::Command;
use itertools::Itertools;
use rustc_errors::inline_fluent;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
use rustc_session::Session;
pub(super) use rustc_target::spec::apple::OSVersion;
@ -10,7 +11,6 @@ use rustc_target::spec::{Arch, Env, Os, Target};
use tracing::debug;
use crate::errors::{XcrunError, XcrunSdkPathWarning};
use crate::fluent_generated as fluent;
#[cfg(test)]
mod tests;
@ -185,19 +185,21 @@ pub(super) fn get_sdk_root(sess: &Session) -> Option<PathBuf> {
// FIXME(madsmtm): Make this a lint, to allow deny warnings to work.
// (Or fix <https://github.com/rust-lang/rust/issues/21204>).
let mut diag = sess.dcx().create_warn(err);
diag.note(fluent::codegen_ssa_xcrun_about);
diag.note(inline_fluent!("the SDK is needed by the linker to know where to find symbols in system libraries and for embedding the SDK version in the final object file"));
// Recognize common error cases, and give more Rust-specific error messages for those.
if let Some(developer_dir) = xcode_select_developer_dir() {
diag.arg("developer_dir", &developer_dir);
diag.note(fluent::codegen_ssa_xcrun_found_developer_dir);
diag.note(inline_fluent!(
"found active developer directory at \"{$developer_dir}\""
));
if developer_dir.as_os_str().to_string_lossy().contains("CommandLineTools") {
if sdk_name != "MacOSX" {
diag.help(fluent::codegen_ssa_xcrun_command_line_tools_insufficient);
diag.help(inline_fluent!("when compiling for iOS, tvOS, visionOS or watchOS, you need a full installation of Xcode"));
}
}
} else {
diag.help(fluent::codegen_ssa_xcrun_no_developer_dir);
diag.help(inline_fluent!("pass the path of an Xcode installation via the DEVELOPER_DIR environment variable, or an SDK with the SDKROOT environment variable"));
}
diag.emit();

View file

@ -663,7 +663,7 @@ fn link_dwarf_object(sess: &Session, cg_results: &CodegenResults, executable_out
}
#[derive(LintDiagnostic)]
#[diag(codegen_ssa_linker_output)]
#[diag("{$inner}")]
/// Translating this is kind of useless. We don't pass translation flags to the linker, so we'd just
/// end up with inconsistent languages within the same diagnostic.
struct LinkerOutput {

File diff suppressed because it is too large Load diff

View file

@ -55,8 +55,6 @@ pub mod size_of_val;
pub mod target_features;
pub mod traits;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub struct ModuleCodegen<M> {
/// The name of the module. When the crate may be saved between
/// compilations, incremental compilation requires that name be

View file

@ -995,12 +995,14 @@ cfg_select! {
}
unix => {
pub fn get_resident_set_size() -> Option<usize> {
use libc::{sysconf, _SC_PAGESIZE};
let field = 1;
let contents = fs::read("/proc/self/statm").ok()?;
let contents = String::from_utf8(contents).ok()?;
let s = contents.split_whitespace().nth(field)?;
let npages = s.parse::<usize>().ok()?;
Some(npages * 4096)
// SAFETY: `sysconf(_SC_PAGESIZE)` has no side effects and is safe to call.
Some(npages * unsafe { sysconf(_SC_PAGESIZE) } as usize)
}
}
_ => {

View file

@ -9,7 +9,6 @@ anstyle = "1.0.13"
jiff = { version = "0.2.5", default-features = false, features = ["std"] }
rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" }
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
rustc_ast_passes = { path = "../rustc_ast_passes" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_borrowck = { path = "../rustc_borrowck" }
@ -22,7 +21,6 @@ rustc_expand = { path = "../rustc_expand" }
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_index = { path = "../rustc_index" }
rustc_interface = { path = "../rustc_interface" }
rustc_lexer = { path = "../rustc_lexer" }

View file

@ -20,7 +20,7 @@ use std::fs::{self, File};
use std::io::{self, IsTerminal, Read, Write};
use std::panic::{self, PanicHookInfo};
use std::path::{Path, PathBuf};
use std::process::{self, Command, Stdio};
use std::process::{Command, ExitCode, Stdio, Termination};
use std::sync::OnceLock;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Instant;
@ -114,25 +114,18 @@ pub fn default_translator() -> Translator {
pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
// tidy-alphabetical-start
rustc_ast_lowering::DEFAULT_LOCALE_RESOURCE,
rustc_ast_passes::DEFAULT_LOCALE_RESOURCE,
rustc_borrowck::DEFAULT_LOCALE_RESOURCE,
rustc_builtin_macros::DEFAULT_LOCALE_RESOURCE,
rustc_codegen_ssa::DEFAULT_LOCALE_RESOURCE,
rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
rustc_errors::DEFAULT_LOCALE_RESOURCE,
rustc_expand::DEFAULT_LOCALE_RESOURCE,
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
rustc_hir_typeck::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_transform::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_passes::DEFAULT_LOCALE_RESOURCE,
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
// tidy-alphabetical-end
];
@ -1404,10 +1397,10 @@ fn parse_crate_attrs<'a>(sess: &'a Session) -> PResult<'a, ast::AttrVec> {
/// Variant of `catch_fatal_errors` for the `interface::Result` return type
/// that also computes the exit code.
pub fn catch_with_exit_code(f: impl FnOnce()) -> i32 {
pub fn catch_with_exit_code<T: Termination>(f: impl FnOnce() -> T) -> ExitCode {
match catch_fatal_errors(f) {
Ok(()) => EXIT_SUCCESS,
_ => EXIT_FAILURE,
Ok(status) => status.report(),
_ => ExitCode::FAILURE,
}
}
@ -1692,7 +1685,7 @@ pub fn install_ctrlc_handler() {
.expect("Unable to install ctrlc handler");
}
pub fn main() -> ! {
pub fn main() -> ExitCode {
let start_time = Instant::now();
let start_rss = get_resident_set_size();
@ -1712,5 +1705,5 @@ pub fn main() -> ! {
print_time_passes_entry("total", start_time.elapsed(), start_rss, end_rss, format);
}
process::exit(exit_code)
exit_code
}

View file

@ -16,7 +16,6 @@ rustc_attr_parsing = { path = "../rustc_attr_parsing" }
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_hir = { path = "../rustc_hir" }
rustc_lexer = { path = "../rustc_lexer" }
rustc_lint_defs = { path = "../rustc_lint_defs" }

View file

@ -1,207 +0,0 @@
expand_attributes_on_expressions_experimental =
attributes on expressions are experimental
.help_outer_doc = `///` is used for outer documentation comments; for a plain comment, use `//`
.help_inner_doc = `//!` is used for inner documentation comments; for a plain comment, use `//` by removing the `!` or inserting a space in between them: `// !`
expand_cfg_attr_no_attributes = `#[cfg_attr]` does not expand to any attributes
expand_count_repetition_misplaced =
`count` can not be placed inside the innermost repetition
expand_crate_name_in_cfg_attr =
`crate_name` within an `#![cfg_attr]` attribute is forbidden
expand_crate_type_in_cfg_attr =
`crate_type` within an `#![cfg_attr]` attribute is forbidden
expand_custom_attribute_panicked =
custom attribute panicked
.help = message: {$message}
expand_duplicate_matcher_binding = duplicate matcher binding
.label = duplicate binding
.label2 = previous binding
expand_empty_delegation_mac =
empty {$kind} delegation is not supported
expand_expected_paren_or_brace =
expected `(` or `{"{"}`, found `{$token}`
expand_explain_doc_comment_inner =
inner doc comments expand to `#![doc = "..."]`, which is what this macro attempted to match
expand_explain_doc_comment_outer =
outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match
expand_expr_repeat_no_syntax_vars =
attempted to repeat an expression containing no syntax variables matched as repeating at this depth
expand_feature_not_allowed =
the feature `{$name}` is not in the list of allowed features
expand_feature_removed =
feature has been removed
.label = feature has been removed
.note = removed in {$removed_rustc_version}{$pull_note}
.reason = {$reason}
expand_file_modules_in_proc_macro_input_are_unstable =
file modules in proc macro input are unstable
expand_glob_delegation_outside_impls =
glob delegation is only supported in impls
expand_glob_delegation_traitless_qpath =
qualified path without a trait in glob delegation
expand_incomplete_parse =
macro expansion ignores {$descr} and any tokens following
.label = caused by the macro expansion here
.note = the usage of `{$macro_path}!` is likely invalid in {$kind_name} context
.suggestion_add_semi = you might be missing a semicolon here
expand_invalid_cfg_expected_syntax = expected syntax is
expand_invalid_cfg_multiple_predicates = multiple `cfg` predicates are specified
expand_invalid_cfg_no_parens = `cfg` is not followed by parentheses
expand_invalid_cfg_no_predicate = `cfg` predicate is not specified
expand_invalid_cfg_predicate_literal = `cfg` predicate key cannot be a literal
expand_invalid_fragment_specifier =
invalid fragment specifier `{$fragment}`
.help = {$help}
expand_macro_args_bad_delim = `{$rule_kw}` rule argument matchers require parentheses
expand_macro_args_bad_delim_sugg = the delimiters should be `(` and `)`
expand_macro_body_stability =
macros cannot have body stability attributes
.label = invalid body stability attribute
.label2 = body stability attribute affects this macro
expand_macro_call_unused_doc_comment = unused doc comment
.label = rustdoc does not generate documentation for macro invocations
.help = to document an item produced by a macro, the macro must produce the documentation as part of its expansion
expand_macro_const_stability =
macros cannot have const stability attributes
.label = invalid const stability attribute
.label2 = const stability attribute affects this macro
expand_macro_expands_to_match_arm = macros cannot expand to match arms
expand_malformed_feature_attribute =
malformed `feature` attribute input
.expected = expected just one word
expand_meta_var_dif_seq_matchers = {$msg}
expand_metavar_still_repeating = variable `{$ident}` is still repeating at this depth
.label = expected repetition
expand_metavariable_wrong_operator = meta-variable repeats with different Kleene operator
.binder_label = expected repetition
.occurrence_label = conflicting repetition
expand_missing_fragment_specifier = missing fragment specifier
.note = fragment specifiers must be provided
.suggestion_add_fragspec = try adding a specifier here
.valid = {$valid}
expand_module_circular =
circular modules: {$modules}
expand_module_file_not_found =
file not found for module `{$name}`
.help = to create the module `{$name}`, create file "{$default_path}" or "{$secondary_path}"
.note = if there is a `mod {$name}` elsewhere in the crate already, import it with `use crate::...` instead
expand_module_in_block =
cannot declare a file module inside a block unless it has a path attribute
.help = maybe `use` the module `{$name}` instead of redeclaring it
.note = file modules are usually placed outside of blocks, at the top level of the file
expand_module_multiple_candidates =
file for module `{$name}` found at both "{$default_path}" and "{$secondary_path}"
.help = delete or rename one of them to remove the ambiguity
expand_must_repeat_once =
this must repeat at least once
expand_mve_extra_tokens =
unexpected trailing tokens
.label = for this metavariable expression
.range = the `{$name}` metavariable expression takes between {$min_or_exact_args} and {$max_args} arguments
.exact = the `{$name}` metavariable expression takes {$min_or_exact_args ->
[zero] no arguments
[one] a single argument
*[other] {$min_or_exact_args} arguments
}
.suggestion = try removing {$extra_count ->
[one] this token
*[other] these tokens
}
expand_mve_missing_paren =
expected `(`
.label = for this this metavariable expression
.unexpected = unexpected token
.note = metavariable expressions use function-like parentheses syntax
.suggestion = try adding parentheses
expand_mve_unrecognized_expr =
unrecognized metavariable expression
.label = not a valid metavariable expression
.note = valid metavariable expressions are {$valid_expr_list}
expand_mve_unrecognized_var =
variable `{$key}` is not recognized in meta-variable expression
expand_or_patterns_back_compat = the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
.suggestion = use pat_param to preserve semantics
expand_proc_macro_back_compat = using an old version of `{$crate_name}`
.note = older versions of the `{$crate_name}` crate no longer compile; please update to `{$crate_name}` v{$fixed_version}, or switch to one of the `{$crate_name}` alternatives
expand_proc_macro_derive_panicked =
proc-macro derive panicked
.help = message: {$message}
expand_proc_macro_derive_tokens =
proc-macro derive produced unparsable tokens
expand_proc_macro_panicked =
proc macro panicked
.help = message: {$message}
expand_recursion_limit_reached =
recursion limit reached while expanding `{$descr}`
.help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]` attribute to your crate (`{$crate_name}`)
expand_remove_expr_not_supported =
removing an expression is not supported in this position
expand_remove_node_not_supported =
removing {$descr} is not supported in this position
expand_resolve_relative_path =
cannot resolve relative path in non-file source `{$path}`
expand_trace_macro = trace_macro
expand_trailing_semi_macro = trailing semicolon in macro used in expression position
.note1 = macro invocations at the end of a block are treated as expressions
.note2 = to ignore the value produced by the macro, add a semicolon after the invocation of `{$name}`
expand_unknown_macro_variable = unknown macro variable `{$name}`
expand_unsupported_key_value =
key-value macro attributes are not supported
expand_unused_builtin_attribute = unused attribute `{$attr_name}`
.note = the built-in attribute `{$attr_name}` will be ignored, since it's applied to the macro invocation `{$macro_name}`
.suggestion = remove the attribute
expand_wrong_fragment_kind =
non-{$kind} macro in {$kind} position: {$name}

View file

@ -15,6 +15,7 @@ use rustc_attr_parsing::{
AttributeParser, CFG_TEMPLATE, EvalConfigResult, ShouldEmit, eval_config_entry, parse_cfg,
};
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_errors::inline_fluent;
use rustc_feature::{
ACCEPTED_LANG_FEATURES, EnabledLangFeature, EnabledLibFeature, Features, REMOVED_LANG_FEATURES,
UNSTABLE_LANG_FEATURES,
@ -432,14 +433,14 @@ impl<'a> StripUnconfigured<'a> {
&self.sess,
sym::stmt_expr_attributes,
attr.span,
crate::fluent_generated::expand_attributes_on_expressions_experimental,
inline_fluent!("attributes on expressions are experimental"),
);
if attr.is_doc_comment() {
err.help(if attr.style == AttrStyle::Outer {
crate::fluent_generated::expand_help_outer_doc
inline_fluent!("`///` is used for outer documentation comments; for a plain comment, use `//`")
} else {
crate::fluent_generated::expand_help_inner_doc
inline_fluent!("`//!` is used for inner documentation comments; for a plain comment, use `//` by removing the `!` or inserting a space in between them: `// !`")
});
}

View file

@ -7,32 +7,34 @@ use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, Symbol};
#[derive(LintDiagnostic)]
#[diag(expand_cfg_attr_no_attributes)]
#[diag("`#[cfg_attr]` does not expand to any attributes")]
pub(crate) struct CfgAttrNoAttributes;
#[derive(Diagnostic)]
#[diag(expand_expr_repeat_no_syntax_vars)]
#[diag(
"attempted to repeat an expression containing no syntax variables matched as repeating at this depth"
)]
pub(crate) struct NoSyntaxVarsExprRepeat {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_must_repeat_once)]
#[diag("this must repeat at least once")]
pub(crate) struct MustRepeatOnce {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_count_repetition_misplaced)]
#[diag("`count` can not be placed inside the innermost repetition")]
pub(crate) struct CountRepetitionMisplaced {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_metavar_still_repeating)]
#[diag("variable `{$ident}` is still repeating at this depth")]
pub(crate) struct MacroVarStillRepeating {
#[primary_span]
pub span: Span,
@ -40,24 +42,24 @@ pub(crate) struct MacroVarStillRepeating {
}
#[derive(LintDiagnostic)]
#[diag(expand_metavar_still_repeating)]
#[diag("variable `{$ident}` is still repeating at this depth")]
pub(crate) struct MetaVarStillRepeatingLint {
#[label]
#[label("expected repetition")]
pub label: Span,
pub ident: MacroRulesNormalizedIdent,
}
#[derive(LintDiagnostic)]
#[diag(expand_metavariable_wrong_operator)]
#[diag("meta-variable repeats with different Kleene operator")]
pub(crate) struct MetaVariableWrongOperator {
#[label(expand_binder_label)]
#[label("expected repetition")]
pub binder: Span,
#[label(expand_occurrence_label)]
#[label("conflicting repetition")]
pub occurrence: Span,
}
#[derive(Diagnostic)]
#[diag(expand_meta_var_dif_seq_matchers)]
#[diag("{$msg}")]
pub(crate) struct MetaVarsDifSeqMatchers {
#[primary_span]
pub span: Span,
@ -65,13 +67,13 @@ pub(crate) struct MetaVarsDifSeqMatchers {
}
#[derive(LintDiagnostic)]
#[diag(expand_unknown_macro_variable)]
#[diag("unknown macro variable `{$name}`")]
pub(crate) struct UnknownMacroVariable {
pub name: MacroRulesNormalizedIdent,
}
#[derive(Diagnostic)]
#[diag(expand_resolve_relative_path)]
#[diag("cannot resolve relative path in non-file source `{$path}`")]
pub(crate) struct ResolveRelativePath {
#[primary_span]
pub span: Span,
@ -79,31 +81,31 @@ pub(crate) struct ResolveRelativePath {
}
#[derive(Diagnostic)]
#[diag(expand_macro_const_stability)]
#[diag("macros cannot have const stability attributes")]
pub(crate) struct MacroConstStability {
#[primary_span]
#[label]
#[label("invalid const stability attribute")]
pub span: Span,
#[label(expand_label2)]
#[label("const stability attribute affects this macro")]
pub head_span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_macro_body_stability)]
#[diag("macros cannot have body stability attributes")]
pub(crate) struct MacroBodyStability {
#[primary_span]
#[label]
#[label("invalid body stability attribute")]
pub span: Span,
#[label(expand_label2)]
#[label("body stability attribute affects this macro")]
pub head_span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_feature_removed, code = E0557)]
#[note]
#[diag("feature has been removed", code = E0557)]
#[note("removed in {$removed_rustc_version}{$pull_note}")]
pub(crate) struct FeatureRemoved<'a> {
#[primary_span]
#[label]
#[label("feature has been removed")]
pub span: Span,
#[subdiagnostic]
pub reason: Option<FeatureRemovedReason<'a>>,
@ -112,13 +114,13 @@ pub(crate) struct FeatureRemoved<'a> {
}
#[derive(Subdiagnostic)]
#[note(expand_reason)]
#[note("{$reason}")]
pub(crate) struct FeatureRemovedReason<'a> {
pub reason: &'a str,
}
#[derive(Diagnostic)]
#[diag(expand_feature_not_allowed, code = E0725)]
#[diag("the feature `{$name}` is not in the list of allowed features", code = E0725)]
pub(crate) struct FeatureNotAllowed {
#[primary_span]
pub span: Span,
@ -126,8 +128,10 @@ pub(crate) struct FeatureNotAllowed {
}
#[derive(Diagnostic)]
#[diag(expand_recursion_limit_reached)]
#[help]
#[diag("recursion limit reached while expanding `{$descr}`")]
#[help(
"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
)]
pub(crate) struct RecursionLimitReached {
#[primary_span]
pub span: Span,
@ -137,7 +141,7 @@ pub(crate) struct RecursionLimitReached {
}
#[derive(Diagnostic)]
#[diag(expand_malformed_feature_attribute, code = E0556)]
#[diag("malformed `feature` attribute input", code = E0556)]
pub(crate) struct MalformedFeatureAttribute {
#[primary_span]
pub span: Span,
@ -147,12 +151,16 @@ pub(crate) struct MalformedFeatureAttribute {
#[derive(Subdiagnostic)]
pub(crate) enum MalformedFeatureAttributeHelp {
#[label(expand_expected)]
#[label("expected just one word")]
Label {
#[primary_span]
span: Span,
},
#[suggestion(expand_expected, code = "{suggestion}", applicability = "maybe-incorrect")]
#[suggestion(
"expected just one word",
code = "{suggestion}",
applicability = "maybe-incorrect"
)]
Suggestion {
#[primary_span]
span: Span,
@ -161,7 +169,7 @@ pub(crate) enum MalformedFeatureAttributeHelp {
}
#[derive(Diagnostic)]
#[diag(expand_remove_expr_not_supported)]
#[diag("removing an expression is not supported in this position")]
pub(crate) struct RemoveExprNotSupported {
#[primary_span]
pub span: Span,
@ -169,32 +177,32 @@ pub(crate) struct RemoveExprNotSupported {
#[derive(Diagnostic)]
pub(crate) enum InvalidCfg {
#[diag(expand_invalid_cfg_no_parens)]
#[diag("`cfg` is not followed by parentheses")]
NotFollowedByParens {
#[primary_span]
#[suggestion(
expand_invalid_cfg_expected_syntax,
"expected syntax is",
code = "cfg(/* predicate */)",
applicability = "has-placeholders"
)]
span: Span,
},
#[diag(expand_invalid_cfg_no_predicate)]
#[diag("`cfg` predicate is not specified")]
NoPredicate {
#[primary_span]
#[suggestion(
expand_invalid_cfg_expected_syntax,
"expected syntax is",
code = "cfg(/* predicate */)",
applicability = "has-placeholders"
)]
span: Span,
},
#[diag(expand_invalid_cfg_multiple_predicates)]
#[diag("multiple `cfg` predicates are specified")]
MultiplePredicates {
#[primary_span]
span: Span,
},
#[diag(expand_invalid_cfg_predicate_literal)]
#[diag("`cfg` predicate key cannot be a literal")]
PredicateLiteral {
#[primary_span]
span: Span,
@ -202,7 +210,7 @@ pub(crate) enum InvalidCfg {
}
#[derive(Diagnostic)]
#[diag(expand_wrong_fragment_kind)]
#[diag("non-{$kind} macro in {$kind} position: {$name}")]
pub(crate) struct WrongFragmentKind<'a> {
#[primary_span]
pub span: Span,
@ -211,28 +219,28 @@ pub(crate) struct WrongFragmentKind<'a> {
}
#[derive(Diagnostic)]
#[diag(expand_unsupported_key_value)]
#[diag("key-value macro attributes are not supported")]
pub(crate) struct UnsupportedKeyValue {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_incomplete_parse)]
#[note]
#[diag("macro expansion ignores {$descr} and any tokens following")]
#[note("the usage of `{$macro_path}!` is likely invalid in {$kind_name} context")]
pub(crate) struct IncompleteParse<'a> {
#[primary_span]
pub span: Span,
pub descr: String,
#[label]
#[label("caused by the macro expansion here")]
pub label_span: Span,
pub macro_path: &'a ast::Path,
pub kind_name: &'a str,
#[note(expand_macro_expands_to_match_arm)]
#[note("macros cannot expand to match arms")]
pub expands_to_match_arm: bool,
#[suggestion(
expand_suggestion_add_semi,
"you might be missing a semicolon here",
style = "verbose",
code = ";",
applicability = "maybe-incorrect"
@ -241,7 +249,7 @@ pub(crate) struct IncompleteParse<'a> {
}
#[derive(Diagnostic)]
#[diag(expand_remove_node_not_supported)]
#[diag("removing {$descr} is not supported in this position")]
pub(crate) struct RemoveNodeNotSupported {
#[primary_span]
pub span: Span,
@ -249,7 +257,7 @@ pub(crate) struct RemoveNodeNotSupported {
}
#[derive(Diagnostic)]
#[diag(expand_module_circular)]
#[diag("circular modules: {$modules}")]
pub(crate) struct ModuleCircular {
#[primary_span]
pub span: Span,
@ -257,8 +265,8 @@ pub(crate) struct ModuleCircular {
}
#[derive(Diagnostic)]
#[diag(expand_module_in_block)]
#[note]
#[diag("cannot declare a file module inside a block unless it has a path attribute")]
#[note("file modules are usually placed outside of blocks, at the top level of the file")]
pub(crate) struct ModuleInBlock {
#[primary_span]
pub span: Span,
@ -267,7 +275,7 @@ pub(crate) struct ModuleInBlock {
}
#[derive(Subdiagnostic)]
#[help(expand_help)]
#[help("maybe `use` the module `{$name}` instead of redeclaring it")]
pub(crate) struct ModuleInBlockName {
#[primary_span]
pub span: Span,
@ -275,9 +283,11 @@ pub(crate) struct ModuleInBlockName {
}
#[derive(Diagnostic)]
#[diag(expand_module_file_not_found, code = E0583)]
#[help]
#[note]
#[diag("file not found for module `{$name}`", code = E0583)]
#[help("to create the module `{$name}`, create file \"{$default_path}\" or \"{$secondary_path}\"")]
#[note(
"if there is a `mod {$name}` elsewhere in the crate already, import it with `use crate::...` instead"
)]
pub(crate) struct ModuleFileNotFound {
#[primary_span]
pub span: Span,
@ -287,8 +297,8 @@ pub(crate) struct ModuleFileNotFound {
}
#[derive(Diagnostic)]
#[diag(expand_module_multiple_candidates, code = E0761)]
#[help]
#[diag("file for module `{$name}` found at both \"{$default_path}\" and \"{$secondary_path}\"", code = E0761)]
#[help("delete or rename one of them to remove the ambiguity")]
pub(crate) struct ModuleMultipleCandidates {
#[primary_span]
pub span: Span,
@ -298,14 +308,14 @@ pub(crate) struct ModuleMultipleCandidates {
}
#[derive(Diagnostic)]
#[diag(expand_trace_macro)]
#[diag("trace_macro")]
pub(crate) struct TraceMacro {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_proc_macro_panicked)]
#[diag("proc macro panicked")]
pub(crate) struct ProcMacroPanicked {
#[primary_span]
pub span: Span,
@ -314,13 +324,13 @@ pub(crate) struct ProcMacroPanicked {
}
#[derive(Subdiagnostic)]
#[help(expand_help)]
#[help("message: {$message}")]
pub(crate) struct ProcMacroPanickedHelp {
pub message: String,
}
#[derive(Diagnostic)]
#[diag(expand_proc_macro_derive_panicked)]
#[diag("proc-macro derive panicked")]
pub(crate) struct ProcMacroDerivePanicked {
#[primary_span]
pub span: Span,
@ -329,13 +339,13 @@ pub(crate) struct ProcMacroDerivePanicked {
}
#[derive(Subdiagnostic)]
#[help(expand_help)]
#[help("message: {$message}")]
pub(crate) struct ProcMacroDerivePanickedHelp {
pub message: String,
}
#[derive(Diagnostic)]
#[diag(expand_custom_attribute_panicked)]
#[diag("custom attribute panicked")]
pub(crate) struct CustomAttributePanicked {
#[primary_span]
pub span: Span,
@ -344,46 +354,46 @@ pub(crate) struct CustomAttributePanicked {
}
#[derive(Subdiagnostic)]
#[help(expand_help)]
#[help("message: {$message}")]
pub(crate) struct CustomAttributePanickedHelp {
pub message: String,
}
#[derive(Diagnostic)]
#[diag(expand_proc_macro_derive_tokens)]
#[diag("proc-macro derive produced unparsable tokens")]
pub(crate) struct ProcMacroDeriveTokens {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_duplicate_matcher_binding)]
#[diag("duplicate matcher binding")]
pub(crate) struct DuplicateMatcherBinding {
#[primary_span]
#[label]
#[label("duplicate binding")]
pub span: Span,
#[label(expand_label2)]
#[label("previous binding")]
pub prev: Span,
}
#[derive(LintDiagnostic)]
#[diag(expand_duplicate_matcher_binding)]
#[diag("duplicate matcher binding")]
pub(crate) struct DuplicateMatcherBindingLint {
#[label]
#[label("duplicate binding")]
pub span: Span,
#[label(expand_label2)]
#[label("previous binding")]
pub prev: Span,
}
#[derive(Diagnostic)]
#[diag(expand_missing_fragment_specifier)]
#[note]
#[help(expand_valid)]
#[diag("missing fragment specifier")]
#[note("fragment specifiers must be provided")]
#[help("{$valid}")]
pub(crate) struct MissingFragmentSpecifier {
#[primary_span]
pub span: Span,
#[suggestion(
expand_suggestion_add_fragspec,
"try adding a specifier here",
style = "verbose",
code = ":spec",
applicability = "maybe-incorrect"
@ -393,8 +403,8 @@ pub(crate) struct MissingFragmentSpecifier {
}
#[derive(Diagnostic)]
#[diag(expand_invalid_fragment_specifier)]
#[help]
#[diag("invalid fragment specifier `{$fragment}`")]
#[help("{$help}")]
pub(crate) struct InvalidFragmentSpecifier {
#[primary_span]
pub span: Span,
@ -403,7 +413,7 @@ pub(crate) struct InvalidFragmentSpecifier {
}
#[derive(Diagnostic)]
#[diag(expand_expected_paren_or_brace)]
#[diag("expected `(` or `{\"{\"}`, found `{$token}`")]
pub(crate) struct ExpectedParenOrBrace<'a> {
#[primary_span]
pub span: Span,
@ -411,7 +421,7 @@ pub(crate) struct ExpectedParenOrBrace<'a> {
}
#[derive(Diagnostic)]
#[diag(expand_empty_delegation_mac)]
#[diag("empty {$kind} delegation is not supported")]
pub(crate) struct EmptyDelegationMac {
#[primary_span]
pub span: Span,
@ -419,28 +429,28 @@ pub(crate) struct EmptyDelegationMac {
}
#[derive(Diagnostic)]
#[diag(expand_glob_delegation_outside_impls)]
#[diag("glob delegation is only supported in impls")]
pub(crate) struct GlobDelegationOutsideImpls {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_crate_name_in_cfg_attr)]
#[diag("`crate_name` within an `#![cfg_attr]` attribute is forbidden")]
pub(crate) struct CrateNameInCfgAttr {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_crate_type_in_cfg_attr)]
#[diag("`crate_type` within an `#![cfg_attr]` attribute is forbidden")]
pub(crate) struct CrateTypeInCfgAttr {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_glob_delegation_traitless_qpath)]
#[diag("qualified path without a trait in glob delegation")]
pub(crate) struct GlobDelegationTraitlessQpath {
#[primary_span]
pub span: Span,
@ -449,8 +459,10 @@ pub(crate) struct GlobDelegationTraitlessQpath {
// This used to be the `proc_macro_back_compat` lint (#83125). It was later
// turned into a hard error.
#[derive(Diagnostic)]
#[diag(expand_proc_macro_back_compat)]
#[note]
#[diag("using an old version of `{$crate_name}`")]
#[note(
"older versions of the `{$crate_name}` crate no longer compile; please update to `{$crate_name}` v{$fixed_version}, or switch to one of the `{$crate_name}` alternatives"
)]
pub(crate) struct ProcMacroBackCompat {
pub crate_name: String,
pub fixed_version: String,
@ -461,20 +473,35 @@ mod metavar_exprs {
use super::*;
#[derive(Diagnostic, Default)]
#[diag(expand_mve_extra_tokens)]
#[diag("unexpected trailing tokens")]
pub(crate) struct MveExtraTokens {
#[primary_span]
#[suggestion(code = "", applicability = "machine-applicable")]
#[suggestion(
"try removing {$extra_count ->
[one] this token
*[other] these tokens
}",
code = "",
applicability = "machine-applicable"
)]
pub span: Span,
#[label]
#[label("for this metavariable expression")]
pub ident_span: Span,
pub extra_count: usize,
// The rest is only used for specific diagnostics and can be default if neither
// `note` is `Some`.
#[note(expand_exact)]
#[note(
"the `{$name}` metavariable expression takes {$min_or_exact_args ->
[zero] no arguments
[one] a single argument
*[other] {$min_or_exact_args} arguments
}"
)]
pub exact_args_note: Option<()>,
#[note(expand_range)]
#[note(
"the `{$name}` metavariable expression takes between {$min_or_exact_args} and {$max_args} arguments"
)]
pub range_args_note: Option<()>,
pub min_or_exact_args: usize,
pub max_args: usize,
@ -482,30 +509,34 @@ mod metavar_exprs {
}
#[derive(Diagnostic)]
#[note]
#[diag(expand_mve_missing_paren)]
#[note("metavariable expressions use function-like parentheses syntax")]
#[diag("expected `(`")]
pub(crate) struct MveMissingParen {
#[primary_span]
#[label]
#[label("for this this metavariable expression")]
pub ident_span: Span,
#[label(expand_unexpected)]
#[label("unexpected token")]
pub unexpected_span: Option<Span>,
#[suggestion(code = "( /* ... */ )", applicability = "has-placeholders")]
#[suggestion(
"try adding parentheses",
code = "( /* ... */ )",
applicability = "has-placeholders"
)]
pub insert_span: Option<Span>,
}
#[derive(Diagnostic)]
#[note]
#[diag(expand_mve_unrecognized_expr)]
#[note("valid metavariable expressions are {$valid_expr_list}")]
#[diag("unrecognized metavariable expression")]
pub(crate) struct MveUnrecognizedExpr {
#[primary_span]
#[label]
#[label("not a valid metavariable expression")]
pub span: Span,
pub valid_expr_list: &'static str,
}
#[derive(Diagnostic)]
#[diag(expand_mve_unrecognized_var)]
#[diag("variable `{$key}` is not recognized in meta-variable expression")]
pub(crate) struct MveUnrecognizedVar {
#[primary_span]
pub span: Span,
@ -514,7 +545,7 @@ mod metavar_exprs {
}
#[derive(Diagnostic)]
#[diag(expand_macro_args_bad_delim)]
#[diag("`{$rule_kw}` rule argument matchers require parentheses")]
pub(crate) struct MacroArgsBadDelim {
#[primary_span]
pub span: Span,
@ -524,7 +555,10 @@ pub(crate) struct MacroArgsBadDelim {
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(expand_macro_args_bad_delim_sugg, applicability = "machine-applicable")]
#[multipart_suggestion(
"the delimiters should be `(` and `)`",
applicability = "machine-applicable"
)]
pub(crate) struct MacroArgsBadDelimSugg {
#[suggestion_part(code = "(")]
pub open: Span,
@ -533,37 +567,54 @@ pub(crate) struct MacroArgsBadDelimSugg {
}
#[derive(LintDiagnostic)]
#[diag(expand_macro_call_unused_doc_comment)]
#[help]
#[diag("unused doc comment")]
#[help(
"to document an item produced by a macro, the macro must produce the documentation as part of its expansion"
)]
pub(crate) struct MacroCallUnusedDocComment {
#[label]
#[label("rustdoc does not generate documentation for macro invocations")]
pub span: Span,
}
#[derive(LintDiagnostic)]
#[diag(expand_or_patterns_back_compat)]
#[diag(
"the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro"
)]
pub(crate) struct OrPatternsBackCompat {
#[suggestion(code = "{suggestion}", applicability = "machine-applicable")]
#[suggestion(
"use pat_param to preserve semantics",
code = "{suggestion}",
applicability = "machine-applicable"
)]
pub span: Span,
pub suggestion: String,
}
#[derive(LintDiagnostic)]
#[diag(expand_trailing_semi_macro)]
#[diag("trailing semicolon in macro used in expression position")]
pub(crate) struct TrailingMacro {
#[note(expand_note1)]
#[note(expand_note2)]
#[note("macro invocations at the end of a block are treated as expressions")]
#[note(
"to ignore the value produced by the macro, add a semicolon after the invocation of `{$name}`"
)]
pub is_trailing: bool,
pub name: Ident,
}
#[derive(LintDiagnostic)]
#[diag(expand_unused_builtin_attribute)]
#[diag("unused attribute `{$attr_name}`")]
pub(crate) struct UnusedBuiltinAttribute {
#[note]
#[note(
"the built-in attribute `{$attr_name}` will be ignored, since it's applied to the macro invocation `{$macro_name}`"
)]
pub invoc_span: Span,
pub attr_name: Symbol,
pub macro_name: String,
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
#[suggestion(
"remove the attribute",
code = "",
applicability = "machine-applicable",
style = "tool-only"
)]
pub attr_span: Span,
}

View file

@ -19,7 +19,7 @@ use rustc_attr_parsing::{
};
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::PResult;
use rustc_errors::{PResult, inline_fluent};
use rustc_feature::Features;
use rustc_hir::Target;
use rustc_hir::def::MacroKinds;
@ -42,7 +42,6 @@ use crate::errors::{
RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported, UnsupportedKeyValue,
WrongFragmentKind,
};
use crate::fluent_generated;
use crate::mbe::diagnostics::annotate_err_with_kind;
use crate::module::{
DirOwnership, ParsedExternalMod, mod_dir_path, mod_file_path_from_attr, parse_external_mod,
@ -1052,7 +1051,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
self.sess,
sym::proc_macro_hygiene,
item.span,
fluent_generated::expand_file_modules_in_proc_macro_input_are_unstable,
inline_fluent!("file modules in proc macro input are unstable"),
)
.emit();
}

View file

@ -26,5 +26,3 @@ pub mod proc_macro;
pub fn provide(providers: &mut rustc_middle::query::Providers) {
providers.derive_macro_expansion = proc_macro::provide_derive_macro_expansion;
}
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -302,12 +302,16 @@ pub(crate) fn annotate_err_with_kind(err: &mut Diag<'_>, kind: AstFragmentKind,
#[derive(Subdiagnostic)]
enum ExplainDocComment {
#[label(expand_explain_doc_comment_inner)]
#[label(
"inner doc comments expand to `#![doc = \"...\"]`, which is what this macro attempted to match"
)]
Inner {
#[primary_span]
span: Span,
},
#[label(expand_explain_doc_comment_outer)]
#[label(
"outer doc comments expand to `#[doc = \"...\"]`, which is what this macro attempted to match"
)]
Outer {
#[primary_span]
span: Span,

View file

@ -716,6 +716,23 @@ pub enum BorrowckGraphvizFormatKind {
TwoPhase,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
pub struct RustcCleanAttribute {
pub span: Span,
pub cfg: Symbol,
pub except: Option<RustcCleanQueries>,
pub loaded_from_disk: Option<RustcCleanQueries>,
}
/// Represents the `except=` or `loaded_from_disk=` argument of `#[rustc_clean]`
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
pub struct RustcCleanQueries {
pub entries: ThinVec<Symbol>,
pub span: Span,
}
/// Represents parsed *built-in* inert attributes.
///
/// ## Overview
@ -992,6 +1009,9 @@ pub enum AttributeKind {
/// Represents [`#[recursion_limit]`](https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute)
RecursionLimit { attr_span: Span, limit_span: Span, limit: Limit },
/// Represents `#[reexport_test_harness_main]`
ReexportTestHarnessMain(Symbol),
/// Represents [`#[repr]`](https://doc.rust-lang.org/stable/reference/type-layout.html#representations).
Repr { reprs: ThinVec<(ReprAttr, Span)>, first_span: Span },
@ -1022,6 +1042,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_builtin_macro]`.
RustcBuiltinMacro { builtin_name: Option<Symbol>, helper_attrs: ThinVec<Symbol>, span: Span },
/// Represents `#[rustc_clean]`
RustcClean(ThinVec<RustcCleanAttribute>),
/// Represents `#[rustc_coherence_is_core]`
RustcCoherenceIsCore(Span),
@ -1077,6 +1100,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_hidden_type_of_opaques]`
RustcHiddenTypeOfOpaques,
/// Represents `#[rustc_if_this_changed]`
RustcIfThisChanged(Span, Option<Symbol>),
/// Represents `#[rustc_layout]`
RustcLayout(ThinVec<RustcLayoutType>),
@ -1178,6 +1204,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_std_internal_symbol]`.
RustcStdInternalSymbol(Span),
/// Represents `#[rustc_then_this_would_need]`
RustcThenThisWouldNeed(Span, ThinVec<Ident>),
/// Represents `#[rustc_unsafe_specialization_marker]`.
RustcUnsafeSpecializationMarker(Span),

View file

@ -87,6 +87,7 @@ impl AttributeKind {
ProcMacroDerive { .. } => No,
ProfilerRuntime => No,
RecursionLimit { .. } => No,
ReexportTestHarnessMain(..) => No,
Repr { .. } => No,
RustcAllocator => No,
RustcAllocatorZeroed => No,
@ -96,6 +97,7 @@ impl AttributeKind {
RustcAsPtr(..) => Yes,
RustcBodyStability { .. } => No,
RustcBuiltinMacro { .. } => Yes,
RustcClean { .. } => No,
RustcCoherenceIsCore(..) => No,
RustcCoinductive(..) => No,
RustcConfusables { .. } => Yes,
@ -112,6 +114,7 @@ impl AttributeKind {
RustcDynIncompatibleTrait(..) => No,
RustcHasIncoherentInherentImpls => Yes,
RustcHiddenTypeOfOpaques => No,
RustcIfThisChanged(..) => No,
RustcLayout(..) => No,
RustcLayoutScalarValidRangeEnd(..) => Yes,
RustcLayoutScalarValidRangeStart(..) => Yes,
@ -144,6 +147,7 @@ impl AttributeKind {
RustcSkipDuringMethodDispatch { .. } => No,
RustcSpecializationTrait(..) => No,
RustcStdInternalSymbol(..) => No,
RustcThenThisWouldNeed(..) => No,
RustcUnsafeSpecializationMarker(..) => No,
RustcVariance => No,
RustcVarianceOfOpaques => No,

View file

@ -6,7 +6,7 @@ use rustc_abi::Align;
use rustc_ast::attr::data_structures::CfgEntry;
use rustc_ast::attr::version::RustcVersion;
use rustc_ast::token::{CommentKind, DocFragmentKind};
use rustc_ast::{AttrStyle, IntTy, UintTy};
use rustc_ast::{AttrId, AttrStyle, IntTy, UintTy};
use rustc_ast_pretty::pp::Printer;
use rustc_data_structures::fx::FxIndexMap;
use rustc_span::def_id::DefId;
@ -179,7 +179,7 @@ macro_rules! print_tup {
}
print_tup!(A B C D E F G H);
print_skip!(Span, (), ErrorGuaranteed);
print_skip!(Span, (), ErrorGuaranteed, AttrId);
print_disp!(u8, u16, u128, usize, bool, NonZero<u32>, Limit);
print_debug!(
Symbol,

View file

@ -10,7 +10,6 @@ rustc_abi = { path = "../rustc_abi" }
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_hir_analysis = { path = "../rustc_hir_analysis" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" }

View file

@ -1,315 +0,0 @@
hir_typeck_abi_cannot_be_called =
functions with the {$abi} ABI cannot be called
.note = an `extern {$abi}` function can only be called using inline assembly
hir_typeck_add_missing_parentheses_in_range = you must surround the range in parentheses to call its `{$func_name}` function
hir_typeck_add_return_type_add = try adding a return type
hir_typeck_add_return_type_missing_here = a return type might be missing here
hir_typeck_address_of_temporary_taken = cannot take address of a temporary
.label = temporary value
hir_typeck_arg_mismatch_indeterminate = argument type mismatch was detected, but rustc had trouble determining where
.note = we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new
hir_typeck_as_deref_suggestion = consider using `as_deref` here
hir_typeck_base_expression_double_dot = base expression required after `..`
hir_typeck_base_expression_double_dot_add_expr = add a base expression here
hir_typeck_base_expression_double_dot_enable_default_field_values =
add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields
hir_typeck_base_expression_double_dot_remove = remove the `..` as all the fields are already present
hir_typeck_break_inside_closure =
`{$name}` inside of a closure
.label = cannot `{$name}` inside of a closure
.closure_label = enclosing closure
hir_typeck_break_inside_coroutine =
`{$name}` inside `{$kind}` {$source}
.label = cannot `{$name}` inside `{$kind}` {$source}
.coroutine_label = enclosing `{$kind}` {$source}
hir_typeck_break_non_loop =
`break` with value from a `{$kind}` loop
.label = can only break with a value inside `loop` or breakable block
.label2 = you can't `break` with a value in a `{$kind}` loop
.suggestion = use `break` on its own without a value inside this `{$kind}` loop
.break_expr_suggestion = alternatively, you might have meant to use the available loop label
hir_typeck_candidate_trait_note = `{$trait_name}` defines an item `{$item_name}`{$action_or_ty ->
[NONE] {""}
[implement] , perhaps you need to implement it
*[other] , perhaps you need to restrict type parameter `{$action_or_ty}` with it
}
hir_typeck_cannot_cast_to_bool = cannot cast `{$expr_ty}` as `bool`
.suggestion = compare with zero instead
.help = compare with zero instead
.label = unsupported cast
hir_typeck_cant_dereference = type `{$ty}` cannot be dereferenced
hir_typeck_cant_dereference_label = can't be dereferenced
hir_typeck_cast_enum_drop = cannot cast enum `{$expr_ty}` into integer `{$cast_ty}` because it implements `Drop`
hir_typeck_cast_thin_pointer_to_wide_pointer = cannot cast thin pointer `{$expr_ty}` to wide pointer `{$cast_ty}`
.teach_help = Thin pointers are "simple" pointers: they are purely a reference to a
memory address.
Wide pointers are pointers referencing "Dynamically Sized Types" (also
called DST). DST don't have a statically known size, therefore they can
only exist behind some kind of pointers that contain additional
information. Slices and trait objects are DSTs. In the case of slices,
the additional information the wide pointer holds is their size.
To fix this error, don't try to cast directly between thin and wide
pointers.
For more information about casts, take a look at The Book:
https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions",
hir_typeck_cast_unknown_pointer = cannot cast {$to ->
[true] to
*[false] from
} a pointer of an unknown kind
.label_to = needs more type information
.note = the type information given here is insufficient to check whether the pointer cast is valid
.label_from = the type information given here is insufficient to check whether the pointer cast is valid
hir_typeck_const_continue_bad_label =
`#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`
hir_typeck_continue_labeled_block =
`continue` pointing to a labeled block
.label = labeled blocks cannot be `continue`'d
.block_label = labeled block the `continue` points to
hir_typeck_convert_to_str = try converting the passed type into a `&str`
hir_typeck_convert_using_method = try using `{$sugg}` to convert `{$found}` to `{$expected}`
hir_typeck_ctor_is_private = tuple struct constructor `{$def}` is private
hir_typeck_dependency_on_unit_never_type_fallback = this function depends on never type fallback being `()`
.note = in edition 2024, the requirement `{$obligation}` will fail
.help = specify the types explicitly
hir_typeck_deref_is_empty = this expression `Deref`s to `{$deref_ty}` which implements `is_empty`
hir_typeck_expected_array_or_slice = expected an array or slice, found `{$ty}`
hir_typeck_expected_array_or_slice_label = pattern cannot match with input type `{$ty}`
hir_typeck_expected_default_return_type = expected `()` because of default return type
hir_typeck_expected_return_type = expected `{$expected}` because of return type
hir_typeck_explicit_destructor = explicit use of destructor method
.label = explicit destructor calls not allowed
.suggestion = consider using `drop` function
hir_typeck_field_multiply_specified_in_initializer =
field `{$ident}` specified more than once
.label = used more than once
.previous_use_label = first use of `{$ident}`
hir_typeck_fn_item_to_variadic_function = can't pass a function item to a variadic function
.suggestion = use a function pointer instead
.help = a function item is zero-sized and needs to be cast into a function pointer to be used in FFI
.note = for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html
hir_typeck_fru_expr = this expression does not end in a comma...
hir_typeck_fru_expr2 = ... so this is interpreted as a `..` range expression, instead of functional record update syntax
hir_typeck_fru_note = this expression may have been misinterpreted as a `..` range expression
hir_typeck_fru_suggestion =
to set the remaining fields{$expr ->
[NONE]{""}
*[other] {" "}from `{$expr}`
}, separate the last named field with a comma
hir_typeck_functional_record_update_on_non_struct =
functional record update syntax requires a struct
hir_typeck_gpu_kernel_abi_cannot_be_called =
functions with the "gpu-kernel" ABI cannot be called
.note = an `extern "gpu-kernel"` function must be launched on the GPU by the runtime
hir_typeck_help_set_edition_cargo = set `edition = "{$edition}"` in `Cargo.toml`
hir_typeck_help_set_edition_standalone = pass `--edition {$edition}` to `rustc`
hir_typeck_int_to_fat = cannot cast `{$expr_ty}` to a pointer that {$known_wide ->
[true] is
*[false] may be
} wide
hir_typeck_int_to_fat_label = creating a `{$cast_ty}` requires both an address and {$metadata}
hir_typeck_int_to_fat_label_nightly = consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
hir_typeck_invalid_callee = expected function, found {$found}
hir_typeck_invalid_defined = `{$path}` defined here
hir_typeck_invalid_defined_kind = {$kind} `{$path}` defined here
hir_typeck_invalid_fn_defined = `{$func}` defined here returns `{$ty}`
hir_typeck_invalid_local = `{$local_name}` has type `{$ty}`
hir_typeck_lossy_provenance_int2ptr =
strict provenance disallows casting integer `{$expr_ty}` to pointer `{$cast_ty}`
.suggestion = use `.with_addr()` to adjust a valid pointer in the same allocation, to this address
.help = if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::with_exposed_provenance()` instead
hir_typeck_lossy_provenance_ptr2int =
under strict provenance it is considered bad style to cast pointer `{$expr_ty}` to integer `{$cast_ty}`
.suggestion = use `.addr()` to obtain the address of a pointer
.help = if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_provenance()` instead
hir_typeck_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty}`
hir_typeck_naked_asm_outside_naked_fn =
the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`
hir_typeck_naked_functions_asm_block =
naked functions must contain a single `naked_asm!` invocation
.label_multiple_asm = multiple `naked_asm!` invocations are not allowed in naked functions
.label_non_asm = not allowed in naked functions
hir_typeck_naked_functions_must_naked_asm =
the `asm!` macro is not allowed in naked functions
.label = consider using the `naked_asm!` macro instead
hir_typeck_never_type_fallback_flowing_into_unsafe_call = never type fallback affects this call to an `unsafe` function
.help = specify the type explicitly
hir_typeck_never_type_fallback_flowing_into_unsafe_deref = never type fallback affects this raw pointer dereference
.help = specify the type explicitly
hir_typeck_never_type_fallback_flowing_into_unsafe_method = never type fallback affects this call to an `unsafe` method
.help = specify the type explicitly
hir_typeck_never_type_fallback_flowing_into_unsafe_path = never type fallback affects this `unsafe` function
.help = specify the type explicitly
hir_typeck_never_type_fallback_flowing_into_unsafe_union_field = never type fallback affects this union access
.help = specify the type explicitly
hir_typeck_no_associated_item = no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty}`{$trait_missing_method ->
[true] {""}
*[other] {" "}in the current scope
}
hir_typeck_no_field_on_type = no field `{$field}` on type `{$ty}`
hir_typeck_no_field_on_variant = no field named `{$field}` on enum variant `{$container}::{$ident}`
hir_typeck_no_field_on_variant_enum = this enum variant...
hir_typeck_no_field_on_variant_field = ...does not have this field
hir_typeck_no_patterns =
patterns not allowed in naked function parameters
hir_typeck_note_caller_chooses_ty_for_ty_param = the caller chooses a type for `{$ty_param_name}` which can be different from `{$found_ty}`
hir_typeck_note_edition_guide = for more on editions, read https://doc.rust-lang.org/edition-guide
hir_typeck_option_result_asref = use `{$def_path}::as_ref` to convert `{$expected_ty}` to `{$expr_ty}`
hir_typeck_option_result_cloned = use `{$def_path}::cloned` to clone the value inside the `{$def_path}`
hir_typeck_option_result_copied = use `{$def_path}::copied` to copy the value inside the `{$def_path}`
hir_typeck_outside_loop =
`{$name}` outside of a loop{$is_break ->
[true] {" or labeled block"}
*[false] {""}
}
.label = cannot `{$name}` outside of a loop{$is_break ->
[true] {" or labeled block"}
*[false] {""}
}
hir_typeck_outside_loop_suggestion = consider labeling this block to be able to break within it
hir_typeck_params_not_allowed =
referencing function parameters is not allowed in naked functions
.help = follow the calling convention in asm block to use parameters
hir_typeck_pass_to_variadic_function = can't pass `{$ty}` to variadic function
.suggestion = cast the value to `{$cast_ty}`
.teach_help = certain types, like `{$ty}`, must be cast before passing them to a variadic function to match the implicit cast that a C compiler would perform as part of C's numeric promotion rules
hir_typeck_project_on_non_pin_project_type = cannot project on type that is not `#[pin_v2]`
.note = type defined here
.suggestion = add `#[pin_v2]` here
hir_typeck_ptr_cast_add_auto_to_object = cannot add {$traits_len ->
[1] auto trait {$traits}
*[other] auto traits {$traits}
} to dyn bound via pointer cast
.note = this could allow UB elsewhere
.help = use `transmute` if you're sure this is sound
.label = unsupported cast
hir_typeck_register_type_unstable =
type `{$ty}` cannot be used with this register class in stable
hir_typeck_remove_semi_for_coerce = you might have meant to return the `match` expression
hir_typeck_remove_semi_for_coerce_expr = this could be implicitly returned but it is a statement, not a tail expression
hir_typeck_remove_semi_for_coerce_ret = the `match` arms can conform to this return type
hir_typeck_remove_semi_for_coerce_semi = the `match` is a statement because of this semicolon, consider removing it
hir_typeck_remove_semi_for_coerce_suggestion = remove this semicolon
hir_typeck_replace_comma_with_semicolon = replace the comma with a semicolon to create {$descr}
hir_typeck_return_stmt_outside_of_fn_body =
{$statement_kind} statement outside of function body
.encl_body_label = the {$statement_kind} is part of this body...
.encl_fn_label = ...not the enclosing function body
hir_typeck_rpit_box_return_expr = if you change the return type to expect trait objects, box the returned expressions
hir_typeck_rpit_change_return_type = you could change the return type to be a boxed trait object
hir_typeck_rustcall_incorrect_args =
functions with the "rust-call" ABI must take a single non-self tuple argument
hir_typeck_self_ctor_from_outer_item = can't reference `Self` constructor from outer item
.label = the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference
.suggestion = replace `Self` with the actual type
hir_typeck_self_ctor_from_outer_item_inner_item = `Self` used in this inner item
hir_typeck_slicing_suggestion = consider slicing here
hir_typeck_struct_expr_non_exhaustive =
cannot create non-exhaustive {$what} using struct expression
hir_typeck_suggest_boxing_note = for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
hir_typeck_suggest_boxing_when_appropriate = store this in the heap by calling `Box::new`
hir_typeck_suggest_ptr_null_mut = consider using `core::ptr::null_mut` instead
hir_typeck_supertrait_item_multiple_shadowee = items from several supertraits are shadowed: {$traits}
hir_typeck_supertrait_item_shadowee = item from `{$supertrait}` is shadowed by a subtrait item
hir_typeck_supertrait_item_shadower = item from `{$subtrait}` shadows a supertrait item
hir_typeck_supertrait_item_shadowing = trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait
hir_typeck_trivial_cast = trivial {$numeric ->
[true] numeric cast
*[false] cast
}: `{$expr_ty}` as `{$cast_ty}`
.help = cast can be replaced by coercion; this might require a temporary variable
hir_typeck_union_pat_dotdot = `..` cannot be used in union patterns
hir_typeck_union_pat_multiple_fields = union patterns should have exactly one field
hir_typeck_unlabeled_cf_in_while_condition =
`break` or `continue` with no label in the condition of a `while` loop
.label = unlabeled `{$cf_type}` in the condition of a `while` loop
hir_typeck_unlabeled_in_labeled_block =
unlabeled `{$cf_type}` inside of a labeled block
.label = `{$cf_type}` statements that would diverge to or through a labeled block need to bear a label
hir_typeck_use_is_empty =
consider using the `is_empty` method on `{$expr_ty}` to determine if it contains anything
hir_typeck_yield_expr_outside_of_coroutine =
yield expression outside of coroutine literal

View file

@ -2,7 +2,7 @@ use std::iter;
use rustc_abi::{CanonAbi, ExternAbi};
use rustc_ast::util::parser::ExprPrecedence;
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey};
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey, inline_fluent};
use rustc_hir::def::{self, CtorKind, Namespace, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::{self as hir, HirId, LangItem};
@ -25,8 +25,8 @@ use tracing::{debug, instrument};
use super::method::MethodCallee;
use super::method::probe::ProbeScope;
use super::{Expectation, FnCtxt, TupleArgumentsFlag};
use crate::errors;
use crate::method::TreatNotYetDefinedOpaques;
use crate::{errors, fluent_generated};
/// Checks that it is legal to call methods of the trait corresponding
/// to `trait_id` (this only cares about the trait, not the specific
@ -832,12 +832,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(Some((_, kind, path)), _) => {
err.arg("kind", kind);
err.arg("path", path);
Some(fluent_generated::hir_typeck_invalid_defined_kind)
Some(inline_fluent!("{$kind} `{$path}` defined here"))
}
(_, Some(hir::QPath::Resolved(_, path))) => {
self.tcx.sess.source_map().span_to_snippet(path.span).ok().map(|p| {
err.arg("func", p);
fluent_generated::hir_typeck_invalid_fn_defined
inline_fluent!("`{$func}` defined here returns `{$ty}`")
})
}
_ => {
@ -846,15 +846,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// type definitions themselves, but rather variables *of* that type.
Res::Local(hir_id) => {
err.arg("local_name", self.tcx.hir_name(hir_id));
Some(fluent_generated::hir_typeck_invalid_local)
Some(inline_fluent!("`{$local_name}` has type `{$ty}`"))
}
Res::Def(kind, def_id) if kind.ns() == Some(Namespace::ValueNS) => {
err.arg("path", self.tcx.def_path_str(def_id));
Some(fluent_generated::hir_typeck_invalid_defined)
Some(inline_fluent!("`{$path}` defined here"))
}
_ => {
err.arg("path", callee_ty);
Some(fluent_generated::hir_typeck_invalid_defined)
Some(inline_fluent!("`{$path}` defined here"))
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@ use core::iter;
use hir::def_id::LocalDefId;
use rustc_ast::util::parser::ExprPrecedence;
use rustc_data_structures::packed::Pu128;
use rustc_errors::{Applicability, Diag, MultiSpan, listify};
use rustc_errors::{Applicability, Diag, MultiSpan, inline_fluent, listify};
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::lang_items::LangItem;
use rustc_hir::{
@ -33,10 +33,10 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _
use tracing::{debug, instrument};
use super::FnCtxt;
use crate::errors;
use crate::fn_ctxt::rustc_span::BytePos;
use crate::method::probe;
use crate::method::probe::{IsSuggestion, Mode, ProbeScope};
use crate::{errors, fluent_generated as fluent};
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub(crate) fn body_fn_sig(&self) -> Option<ty::FnSig<'tcx>> {
@ -482,7 +482,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let sugg = prefix_wrap(".map(|x| x.as_str())");
err.span_suggestion_verbose(
expr.span.shrink_to_hi(),
fluent::hir_typeck_convert_to_str,
inline_fluent!("try converting the passed type into a `&str`"),
sugg,
Applicability::MachineApplicable,
);

View file

@ -67,8 +67,6 @@ use crate::expectation::Expectation;
use crate::fn_ctxt::LoweredTy;
use crate::gather_locals::GatherLocalsVisitor;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
#[macro_export]
macro_rules! type_error_struct {
($dcx:expr, $span:expr, $typ:expr, $code:expr, $($message:tt)*) => ({

View file

@ -6,7 +6,6 @@ edition = "2024"
[dependencies]
# tidy-alphabetical-start
rand = "0.9.0"
rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fs_util = { path = "../rustc_fs_util" }
@ -18,6 +17,5 @@ rustc_middle = { path = "../rustc_middle" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
thin-vec = "0.2.12"
tracing = "0.1"
# tidy-alphabetical-end

View file

@ -5,7 +5,7 @@
//! annotations. These annotations can be used to test whether paths
//! exist in the graph. These checks run after codegen, so they view the
//! the final state of the dependency graph. Note that there are
//! similar assertions found in `persist::dirty_clean` which check the
//! similar assertions found in `persist::clean` which check the
//! **initial** state of the dependency graph, just after it has been
//! loaded from disk.
//!
@ -39,14 +39,16 @@ use std::io::Write;
use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::graph::linked_graph::{Direction, INCOMING, NodeIndex, OUTGOING};
use rustc_hir::Attribute;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
use rustc_hir::intravisit::{self, Visitor};
use rustc_middle::bug;
use rustc_middle::dep_graph::{
DepGraphQuery, DepKind, DepNode, DepNodeExt, DepNodeFilter, EdgeFilter, dep_kinds,
};
use rustc_middle::hir::nested_filter;
use rustc_middle::ty::TyCtxt;
use rustc_middle::{bug, span_bug};
use rustc_span::{Span, Symbol, sym};
use tracing::debug;
use {rustc_graphviz as dot, rustc_hir as hir};
@ -105,29 +107,13 @@ struct IfThisChanged<'tcx> {
}
impl<'tcx> IfThisChanged<'tcx> {
fn argument(&self, attr: &hir::Attribute) -> Option<Symbol> {
let mut value = None;
for list_item in attr.meta_item_list().unwrap_or_default() {
match list_item.ident() {
Some(ident) if list_item.is_word() && value.is_none() => value = Some(ident.name),
_ =>
// FIXME better-encapsulate meta_item (don't directly access `node`)
{
span_bug!(list_item.span(), "unexpected meta-item {:?}", list_item)
}
}
}
value
}
fn process_attrs(&mut self, def_id: LocalDefId) {
let def_path_hash = self.tcx.def_path_hash(def_id.to_def_id());
let hir_id = self.tcx.local_def_id_to_hir_id(def_id);
let attrs = self.tcx.hir_attrs(hir_id);
for attr in attrs {
if attr.has_name(sym::rustc_if_this_changed) {
let dep_node_interned = self.argument(attr);
let dep_node = match dep_node_interned {
if let Attribute::Parsed(AttributeKind::RustcIfThisChanged(span, dep_node)) = *attr {
let dep_node = match dep_node {
None => DepNode::from_def_path_hash(
self.tcx,
def_path_hash,
@ -136,36 +122,29 @@ impl<'tcx> IfThisChanged<'tcx> {
Some(n) => {
match DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash) {
Ok(n) => n,
Err(()) => self.tcx.dcx().emit_fatal(errors::UnrecognizedDepNode {
span: attr.span(),
name: n,
}),
Err(()) => self
.tcx
.dcx()
.emit_fatal(errors::UnrecognizedDepNode { span, name: n }),
}
}
};
self.if_this_changed.push((attr.span(), def_id.to_def_id(), dep_node));
} else if attr.has_name(sym::rustc_then_this_would_need) {
let dep_node_interned = self.argument(attr);
let dep_node = match dep_node_interned {
Some(n) => {
match DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash) {
Ok(n) => n,
Err(()) => self.tcx.dcx().emit_fatal(errors::UnrecognizedDepNode {
span: attr.span(),
name: n,
}),
}
}
None => {
self.tcx.dcx().emit_fatal(errors::MissingDepNode { span: attr.span() });
}
};
self.then_this_would_need.push((
attr.span(),
dep_node_interned.unwrap(),
hir_id,
dep_node,
));
self.if_this_changed.push((span, def_id.to_def_id(), dep_node));
} else if let Attribute::Parsed(AttributeKind::RustcThenThisWouldNeed(
_,
ref dep_nodes,
)) = *attr
{
for &n in dep_nodes {
let Ok(dep_node) =
DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash)
else {
self.tcx
.dcx()
.emit_fatal(errors::UnrecognizedDepNode { span: n.span, name: n.name });
};
self.then_this_would_need.push((n.span, n.name, hir_id, dep_node));
}
}
}
}

View file

@ -1,7 +1,7 @@
use std::path::{Path, PathBuf};
use rustc_macros::Diagnostic;
use rustc_span::{Ident, Span, Symbol};
use rustc_span::{Span, Symbol};
#[derive(Diagnostic)]
#[diag("unrecognized `DepNode` variant: {$name}")]
@ -11,13 +11,6 @@ pub(crate) struct UnrecognizedDepNode {
pub name: Symbol,
}
#[derive(Diagnostic)]
#[diag("missing `DepNode` variant")]
pub(crate) struct MissingDepNode {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("no `#[rustc_if_this_changed]` annotation detected")]
pub(crate) struct MissingIfThisChanged {
@ -106,42 +99,12 @@ pub(crate) struct NotLoaded<'a> {
pub dep_node_str: &'a str,
}
#[derive(Diagnostic)]
#[diag("unknown `rustc_clean` argument")]
pub(crate) struct UnknownRustcCleanArgument {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("no cfg attribute")]
pub(crate) struct NoCfg {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("associated value expected for `{$ident}`")]
pub(crate) struct AssociatedValueExpectedFor {
#[primary_span]
pub span: Span,
pub ident: Ident,
}
#[derive(Diagnostic)]
#[diag("expected an associated value")]
pub(crate) struct AssociatedValueExpected {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("found unchecked `#[rustc_clean]` attribute")]
pub(crate) struct UncheckedClean {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("unable to delete old {$name} at `{$path}`: {$err}")]
pub(crate) struct DeleteOld<'a> {

View file

@ -19,26 +19,22 @@
//! Errors are reported if we are in the suitable configuration but
//! the required condition is not met.
use rustc_ast::{self as ast, MetaItemInner};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::unord::UnordSet;
use rustc_hir::attrs::{AttributeKind, RustcCleanAttribute};
use rustc_hir::def_id::LocalDefId;
use rustc_hir::{
Attribute, ImplItemKind, ItemKind as HirItem, Node as HirNode, TraitItemKind, intravisit,
Attribute, ImplItemKind, ItemKind as HirItem, Node as HirNode, TraitItemKind, find_attr,
intravisit,
};
use rustc_middle::dep_graph::{DepNode, DepNodeExt, dep_kind_from_label, label_strs};
use rustc_middle::hir::nested_filter;
use rustc_middle::ty::TyCtxt;
use rustc_span::{Span, Symbol, sym};
use thin_vec::ThinVec;
use rustc_span::{Span, Symbol};
use tracing::debug;
use crate::errors;
const LOADED_FROM_DISK: Symbol = sym::loaded_from_disk;
const EXCEPT: Symbol = sym::except;
const CFG: Symbol = sym::cfg;
// Base and Extra labels to build up the labels
/// For typedef, constants, and statics
@ -127,14 +123,14 @@ const LABELS_ADT: &[&[&str]] = &[BASE_HIR, BASE_STRUCT];
type Labels = UnordSet<String>;
/// Represents the requested configuration by rustc_clean/dirty
/// Represents the requested configuration by rustc_clean
struct Assertion {
clean: Labels,
dirty: Labels,
loaded_from_disk: Labels,
}
pub(crate) fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
pub(crate) fn check_clean_annotations(tcx: TyCtxt<'_>) {
if !tcx.sess.opts.unstable_opts.query_dep_graph {
return;
}
@ -145,24 +141,24 @@ pub(crate) fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
}
tcx.dep_graph.with_ignore(|| {
let mut dirty_clean_visitor = DirtyCleanVisitor { tcx, checked_attrs: Default::default() };
let mut clean_visitor = CleanVisitor { tcx, checked_attrs: Default::default() };
let crate_items = tcx.hir_crate_items(());
for id in crate_items.free_items() {
dirty_clean_visitor.check_item(id.owner_id.def_id);
clean_visitor.check_item(id.owner_id.def_id);
}
for id in crate_items.trait_items() {
dirty_clean_visitor.check_item(id.owner_id.def_id);
clean_visitor.check_item(id.owner_id.def_id);
}
for id in crate_items.impl_items() {
dirty_clean_visitor.check_item(id.owner_id.def_id);
clean_visitor.check_item(id.owner_id.def_id);
}
for id in crate_items.foreign_items() {
dirty_clean_visitor.check_item(id.owner_id.def_id);
clean_visitor.check_item(id.owner_id.def_id);
}
let mut all_attrs = FindAllAttrs { tcx, found_attrs: vec![] };
@ -171,67 +167,62 @@ pub(crate) fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
// Note that we cannot use the existing "unused attribute"-infrastructure
// here, since that is running before codegen. This is also the reason why
// all codegen-specific attributes are `AssumedUsed` in rustc_ast::feature_gate.
all_attrs.report_unchecked_attrs(dirty_clean_visitor.checked_attrs);
all_attrs.report_unchecked_attrs(clean_visitor.checked_attrs);
})
}
struct DirtyCleanVisitor<'tcx> {
struct CleanVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
checked_attrs: FxHashSet<ast::AttrId>,
checked_attrs: FxHashSet<Span>,
}
impl<'tcx> DirtyCleanVisitor<'tcx> {
/// Possibly "deserialize" the attribute into a clean/dirty assertion
fn assertion_maybe(&mut self, item_id: LocalDefId, attr: &Attribute) -> Option<Assertion> {
assert!(attr.has_name(sym::rustc_clean));
if !check_config(self.tcx, attr) {
// skip: not the correct `cfg=`
return None;
}
let assertion = self.assertion_auto(item_id, attr);
Some(assertion)
impl<'tcx> CleanVisitor<'tcx> {
/// Convert the attribute to an [`Assertion`] if the relevant cfg is active
fn assertion_maybe(
&mut self,
item_id: LocalDefId,
attr: &RustcCleanAttribute,
) -> Option<Assertion> {
self.tcx
.sess
.psess
.config
.contains(&(attr.cfg, None))
.then(|| self.assertion_auto(item_id, attr))
}
/// Gets the "auto" assertion on pre-validated attr, along with the `except` labels.
fn assertion_auto(&mut self, item_id: LocalDefId, attr: &Attribute) -> Assertion {
let (name, mut auto) = self.auto_labels(item_id, attr);
fn assertion_auto(&mut self, item_id: LocalDefId, attr: &RustcCleanAttribute) -> Assertion {
let (name, mut auto) = self.auto_labels(item_id, attr.span);
let except = self.except(attr);
let loaded_from_disk = self.loaded_from_disk(attr);
for e in except.items().into_sorted_stable_ord() {
if !auto.remove(e) {
self.tcx.dcx().emit_fatal(errors::AssertionAuto { span: attr.span(), name, e });
self.tcx.dcx().emit_fatal(errors::AssertionAuto { span: attr.span, name, e });
}
}
Assertion { clean: auto, dirty: except, loaded_from_disk }
}
/// `loaded_from_disk=` attribute value
fn loaded_from_disk(&self, attr: &Attribute) -> Labels {
for item in attr.meta_item_list().unwrap_or_else(ThinVec::new) {
if item.has_name(LOADED_FROM_DISK) {
let value = expect_associated_value(self.tcx, &item);
return self.resolve_labels(&item, value);
}
}
// If `loaded_from_disk=` is not specified, don't assert anything
Labels::default()
fn loaded_from_disk(&self, attr: &RustcCleanAttribute) -> Labels {
attr.loaded_from_disk
.as_ref()
.map(|queries| self.resolve_labels(&queries.entries, queries.span))
.unwrap_or_default()
}
/// `except=` attribute value
fn except(&self, attr: &Attribute) -> Labels {
for item in attr.meta_item_list().unwrap_or_else(ThinVec::new) {
if item.has_name(EXCEPT) {
let value = expect_associated_value(self.tcx, &item);
return self.resolve_labels(&item, value);
}
}
// if no `label` or `except` is given, only the node's group are asserted
Labels::default()
fn except(&self, attr: &RustcCleanAttribute) -> Labels {
attr.except
.as_ref()
.map(|queries| self.resolve_labels(&queries.entries, queries.span))
.unwrap_or_default()
}
/// Return all DepNode labels that should be asserted for this item.
/// index=0 is the "name" used for error messages
fn auto_labels(&mut self, item_id: LocalDefId, attr: &Attribute) -> (&'static str, Labels) {
fn auto_labels(&mut self, item_id: LocalDefId, span: Span) -> (&'static str, Labels) {
let node = self.tcx.hir_node_by_def_id(item_id);
let (name, labels) = match node {
HirNode::Item(item) => {
@ -282,7 +273,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
HirItem::Impl { .. } => ("ItemKind::Impl", LABELS_IMPL),
_ => self.tcx.dcx().emit_fatal(errors::UndefinedCleanDirtyItem {
span: attr.span(),
span,
kind: format!("{:?}", item.kind),
}),
}
@ -297,31 +288,31 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
ImplItemKind::Type(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
},
_ => self.tcx.dcx().emit_fatal(errors::UndefinedCleanDirty {
span: attr.span(),
kind: format!("{node:?}"),
}),
_ => self
.tcx
.dcx()
.emit_fatal(errors::UndefinedCleanDirty { span, kind: format!("{node:?}") }),
};
let labels =
Labels::from_iter(labels.iter().flat_map(|s| s.iter().map(|l| (*l).to_string())));
(name, labels)
}
fn resolve_labels(&self, item: &MetaItemInner, value: Symbol) -> Labels {
fn resolve_labels(&self, values: &[Symbol], span: Span) -> Labels {
let mut out = Labels::default();
for label in value.as_str().split(',') {
let label = label.trim();
if DepNode::has_label_string(label) {
if out.contains(label) {
for label in values {
let label_str = label.as_str();
if DepNode::has_label_string(label_str) {
if out.contains(label_str) {
self.tcx
.dcx()
.emit_fatal(errors::RepeatedDepNodeLabel { span: item.span(), label });
.emit_fatal(errors::RepeatedDepNodeLabel { span, label: label_str });
}
out.insert(label.to_string());
out.insert(label_str.to_string());
} else {
self.tcx
.dcx()
.emit_fatal(errors::UnrecognizedDepNodeLabel { span: item.span(), label });
.emit_fatal(errors::UnrecognizedDepNodeLabel { span, label: label_str });
}
}
out
@ -360,11 +351,18 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
fn check_item(&mut self, item_id: LocalDefId) {
let item_span = self.tcx.def_span(item_id.to_def_id());
let def_path_hash = self.tcx.def_path_hash(item_id.to_def_id());
for attr in self.tcx.get_attrs(item_id, sym::rustc_clean) {
let Some(attr) =
find_attr!(self.tcx.get_all_attrs(item_id), AttributeKind::RustcClean(attr) => attr)
else {
return;
};
for attr in attr {
let Some(assertion) = self.assertion_maybe(item_id, attr) else {
continue;
};
self.checked_attrs.insert(attr.id());
self.checked_attrs.insert(attr.span);
for label in assertion.clean.items().into_sorted_stable_ord() {
let dep_node = DepNode::from_label_string(self.tcx, label, def_path_hash).unwrap();
self.assert_clean(item_span, dep_node);
@ -400,61 +398,24 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
}
}
/// Given a `#[rustc_clean]` attribute, scan for a `cfg="foo"` attribute and check whether we have
/// a cfg flag called `foo`.
fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool {
debug!("check_config(attr={:?})", attr);
let config = &tcx.sess.psess.config;
debug!("check_config: config={:?}", config);
let mut cfg = None;
for item in attr.meta_item_list().unwrap_or_else(ThinVec::new) {
if item.has_name(CFG) {
let value = expect_associated_value(tcx, &item);
debug!("check_config: searching for cfg {:?}", value);
cfg = Some(config.contains(&(value, None)));
} else if !(item.has_name(EXCEPT) || item.has_name(LOADED_FROM_DISK)) {
tcx.dcx().emit_err(errors::UnknownRustcCleanArgument { span: item.span() });
}
}
match cfg {
None => tcx.dcx().emit_fatal(errors::NoCfg { span: attr.span() }),
Some(c) => c,
}
}
fn expect_associated_value(tcx: TyCtxt<'_>, item: &MetaItemInner) -> Symbol {
if let Some(value) = item.value_str() {
value
} else if let Some(ident) = item.ident() {
tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
} else {
tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
}
}
/// A visitor that collects all `#[rustc_clean]` attributes from
/// the HIR. It is used to verify that we really ran checks for all annotated
/// nodes.
struct FindAllAttrs<'tcx> {
tcx: TyCtxt<'tcx>,
found_attrs: Vec<&'tcx Attribute>,
found_attrs: Vec<&'tcx RustcCleanAttribute>,
}
impl<'tcx> FindAllAttrs<'tcx> {
fn is_active_attr(&mut self, attr: &Attribute) -> bool {
if attr.has_name(sym::rustc_clean) && check_config(self.tcx, attr) {
return true;
}
false
fn is_active_attr(&self, attr: &RustcCleanAttribute) -> bool {
self.tcx.sess.psess.config.contains(&(attr.cfg, None))
}
fn report_unchecked_attrs(&self, mut checked_attrs: FxHashSet<ast::AttrId>) {
fn report_unchecked_attrs(&self, mut checked_attrs: FxHashSet<Span>) {
for attr in &self.found_attrs {
if !checked_attrs.contains(&attr.id()) {
self.tcx.dcx().emit_err(errors::UncheckedClean { span: attr.span() });
checked_attrs.insert(attr.id());
if !checked_attrs.contains(&attr.span) {
self.tcx.dcx().emit_err(errors::UncheckedClean { span: attr.span });
checked_attrs.insert(attr.span);
}
}
}
@ -468,8 +429,12 @@ impl<'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
}
fn visit_attribute(&mut self, attr: &'tcx Attribute) {
if self.is_active_attr(attr) {
self.found_attrs.push(attr);
if let Attribute::Parsed(AttributeKind::RustcClean(attrs)) = attr {
for attr in attrs {
if self.is_active_attr(attr) {
self.found_attrs.push(attr);
}
}
}
}
}

View file

@ -2,8 +2,8 @@
//! into the given directory. At the same time, it also hashes the
//! various HIR nodes.
mod clean;
mod data;
mod dirty_clean;
mod file_format;
mod fs;
mod load;

View file

@ -14,7 +14,7 @@ use tracing::debug;
use super::data::*;
use super::fs::*;
use super::{dirty_clean, file_format, work_product};
use super::{clean, file_format, work_product};
use crate::assert_dep_graph::assert_dep_graph;
use crate::errors;
@ -42,7 +42,7 @@ pub(crate) fn save_dep_graph(tcx: TyCtxt<'_>) {
let staging_dep_graph_path = staging_dep_graph_path(sess);
sess.time("assert_dep_graph", || assert_dep_graph(tcx));
sess.time("check_dirty_clean", || dirty_clean::check_dirty_clean_annotations(tcx));
sess.time("check_clean", || clean::check_clean_annotations(tcx));
join(
move || {

View file

@ -15,7 +15,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_pretty = { path = "../rustc_hir_pretty" }

View file

@ -1,240 +0,0 @@
metadata_async_drop_types_in_dependency =
found async drop types in dependency `{$extern_crate}`, but async_drop feature is disabled for `{$local_crate}`
.help = if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used
metadata_bad_panic_strategy =
the linked panic runtime `{$runtime}` is not compiled with this crate's panic strategy `{$strategy}`
metadata_binary_output_to_tty =
option `-o` or `--emit` is used to write binary output type `metadata` to stdout, but stdout is a tty
metadata_cannot_find_crate =
can't find crate for `{$crate_name}`{$add_info}
metadata_cant_find_crate =
can't find crate
metadata_compiler_missing_profiler =
the compiler may have been built without the profiler runtime
metadata_conflicting_alloc_error_handler =
the `#[alloc_error_handler]` in {$other_crate_name} conflicts with allocation error handler in: {$crate_name}
metadata_conflicting_global_alloc =
the `#[global_allocator]` in {$other_crate_name} conflicts with global allocator in: {$crate_name}
metadata_consider_adding_std =
consider adding the standard library to the sysroot with `x build library --target {$locator_triple}`
metadata_consider_building_std =
consider building the standard library from source with `cargo build -Zbuild-std`
metadata_consider_downloading_target =
consider downloading the target with `rustup target add {$locator_triple}`
metadata_crate_dep_multiple =
cannot satisfy dependencies so `{$crate_name}` only shows up once
.help = having upstream crates all available in one format will likely make this go away
metadata_crate_dep_not_static =
`{$crate_name}` was unavailable as a static crate, preventing fully static linking
metadata_crate_dep_rustc_driver =
`feature(rustc_private)` is needed to link to the compiler's `rustc_driver` library
metadata_crate_location_unknown_type =
extern location for {$crate_name} is of an unknown type: {$path}
metadata_crate_not_compiler_builtins =
the crate `{$crate_name}` resolved as `compiler_builtins` but is not `#![compiler_builtins]`
metadata_crate_not_panic_runtime =
the crate `{$crate_name}` is not a panic runtime
metadata_dl_error =
{$path}{$err}
metadata_empty_renaming_target =
an empty renaming target was specified for library `{$lib_name}`
metadata_extern_location_not_exist =
extern location for {$crate_name} does not exist: {$location}
metadata_extern_location_not_file =
extern location for {$crate_name} is not a file: {$location}
metadata_fail_create_file_encoder =
failed to create file encoder: {$err}
metadata_fail_write_file =
failed to write to `{$path}`: {$err}
metadata_failed_copy_to_stdout =
failed to copy {$filename} to stdout: {$err}
metadata_failed_create_encoded_metadata =
failed to create encoded metadata from file: {$err}
metadata_failed_create_file =
failed to create the file {$filename}: {$err}
metadata_failed_create_tempdir =
couldn't create a temp dir: {$err}
metadata_failed_write_error =
failed to write {$filename}: {$err}
metadata_found_crate_versions =
the following crate versions were found:{$found_crates}
metadata_found_staticlib =
found staticlib `{$crate_name}` instead of rlib or dylib{$add_info}
.help = please recompile that crate using --crate-type lib
metadata_full_metadata_not_found =
only metadata stub found for `{$flavor}` dependency `{$crate_name}`
please provide path to the corresponding .rmeta file with full metadata
metadata_global_alloc_required =
no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait
metadata_incompatible_panic_in_drop_strategy =
the crate `{$crate_name}` is compiled with the panic-in-drop strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}`
metadata_incompatible_rustc =
found crate `{$crate_name}` compiled by an incompatible version of rustc{$add_info}
.help = please recompile that crate using this compiler ({$rustc_version}) (consider running `cargo clean` first)
metadata_incompatible_target_modifiers =
mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`
.note = `{$flag_name_prefixed}={$local_value}` in this crate is incompatible with `{$flag_name_prefixed}={$extern_value}` in dependency `{$extern_crate}`
.help = the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
metadata_incompatible_target_modifiers_help_allow = if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error
metadata_incompatible_target_modifiers_help_fix = set `{$flag_name_prefixed}={$extern_value}` in this crate or `{$flag_name_prefixed}={$local_value}` in `{$extern_crate}`
metadata_incompatible_target_modifiers_help_fix_l_missed = set `{$flag_name_prefixed}={$extern_value}` in this crate or unset `{$flag_name_prefixed}` in `{$extern_crate}`
metadata_incompatible_target_modifiers_help_fix_r_missed = unset `{$flag_name_prefixed}` in this crate or set `{$flag_name_prefixed}={$local_value}` in `{$extern_crate}`
metadata_incompatible_target_modifiers_l_missed =
mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`
.note = unset `{$flag_name_prefixed}` in this crate is incompatible with `{$flag_name_prefixed}={$extern_value}` in dependency `{$extern_crate}`
.help = the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
metadata_incompatible_target_modifiers_r_missed =
mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`
.note = `{$flag_name_prefixed}={$local_value}` in this crate is incompatible with unset `{$flag_name_prefixed}` in dependency `{$extern_crate}`
.help = the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
metadata_incompatible_with_immediate_abort =
the crate `{$crate_name}` was compiled with a panic strategy which is incompatible with `immediate-abort`
metadata_incompatible_with_immediate_abort_core =
the crate `core` was compiled with a panic strategy which is incompatible with `immediate-abort`
.help = consider building the standard library from source with `cargo build -Zbuild-std`
metadata_install_missing_components =
maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`
metadata_invalid_meta_files =
found invalid metadata files for crate `{$crate_name}`{$add_info}
metadata_lib_filename_form =
file name should be lib*.rlib or {$dll_prefix}*{$dll_suffix}
metadata_lib_framework_apple =
library kind `framework` is only supported on Apple targets
metadata_lib_required =
crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form
metadata_link_ordinal_raw_dylib =
`#[link_ordinal]` is only supported if link kind is `raw-dylib`
metadata_missing_native_library =
could not find native static library `{$libname}`, perhaps an -L flag is missing?
metadata_multiple_candidates =
multiple candidates for `{$flavor}` dependency `{$crate_name}` found
metadata_multiple_renamings =
multiple renamings were specified for library `{$lib_name}`
metadata_newer_crate_version =
found possibly newer version of crate `{$crate_name}`{$add_info}
.note = perhaps that crate needs to be recompiled?
metadata_no_crate_with_triple =
couldn't find crate `{$crate_name}` with expected target triple {$locator_triple}{$add_info}
metadata_no_link_mod_override =
overriding linking modifiers from command line is not supported
metadata_no_multiple_alloc_error_handler =
cannot define multiple allocation error handlers
.label = cannot define a new allocation error handler
metadata_no_multiple_global_alloc =
cannot define multiple global allocators
.label = cannot define a new global allocator
metadata_no_panic_strategy =
the crate `{$crate_name}` does not have the panic strategy `{$strategy}`
metadata_no_transitive_needs_dep =
the crate `{$crate_name}` cannot depend on a crate that needs {$needs_crate_name}, but it depends on `{$deps_crate_name}`
metadata_non_ascii_name =
cannot load a crate with a non-ascii name `{$crate_name}`
metadata_not_profiler_runtime =
the crate `{$crate_name}` is not a profiler runtime
metadata_only_provide_library_name = only provide the library name `{$suggested_name}`, not the full filename
metadata_prev_alloc_error_handler =
previous allocation error handler defined here
metadata_prev_global_alloc =
previous global allocator defined here
metadata_raw_dylib_malformed =
link name must be well-formed if link kind is `raw-dylib`
metadata_raw_dylib_unsupported_abi =
ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
metadata_renaming_no_link =
renaming of the library `{$lib_name}` was specified, however this crate contains no `#[link(...)]` attributes referencing this library
metadata_required_panic_strategy =
the crate `{$crate_name}` requires panic strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}`
metadata_rlib_required =
crate `{$crate_name}` required to be available in rlib format, but was not found in this form
metadata_rustc_lib_required =
crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form
.note = only .rmeta files are distributed for `rustc_private` crates other than `rustc_driver`
.help = try adding `extern crate rustc_driver;` at the top level of this crate
metadata_stable_crate_id_collision =
found crates (`{$crate_name0}` and `{$crate_name1}`) with colliding StableCrateId values
metadata_std_required =
`std` is required by `{$current_crate}` because it does not declare `#![no_std]`
metadata_symbol_conflicts_current =
the current crate is indistinguishable from one of its dependencies: it has the same crate-name `{$crate_name}` and was compiled with the same `-C metadata` arguments, so this will result in symbol conflicts between the two
metadata_target_no_std_support =
the `{$locator_triple}` target may not support the standard library
metadata_target_not_installed =
the `{$locator_triple}` target may not be installed
metadata_two_panic_runtimes =
cannot link together two panic runtimes: {$prev_name} and {$cur_name}
metadata_unknown_target_modifier_unsafe_allowed = unknown target modifier `{$flag_name}`, requested by `-Cunsafe-allow-abi-mismatch={$flag_name}`
metadata_wasm_c_abi =
older versions of the `wasm-bindgen` crate are incompatible with current versions of Rust; please update to `wasm-bindgen` v0.2.88

View file

@ -2,38 +2,43 @@ use std::io::Error;
use std::path::{Path, PathBuf};
use rustc_errors::codes::*;
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, inline_fluent};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol, sym};
use rustc_target::spec::{PanicStrategy, TargetTuple};
use crate::fluent_generated as fluent;
use crate::locator::CrateFlavor;
#[derive(Diagnostic)]
#[diag(metadata_rlib_required)]
#[diag(
"crate `{$crate_name}` required to be available in rlib format, but was not found in this form"
)]
pub struct RlibRequired {
pub crate_name: Symbol,
}
#[derive(Diagnostic)]
#[diag(metadata_lib_required)]
#[diag(
"crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form"
)]
pub struct LibRequired<'a> {
pub crate_name: Symbol,
pub kind: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_rustc_lib_required)]
#[help]
#[diag(
"crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form"
)]
#[help("try adding `extern crate rustc_driver;` at the top level of this crate")]
pub struct RustcLibRequired<'a> {
pub crate_name: Symbol,
pub kind: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_crate_dep_multiple)]
#[help]
#[diag("cannot satisfy dependencies so `{$crate_name}` only shows up once")]
#[help("having upstream crates all available in one format will likely make this go away")]
pub struct CrateDepMultiple {
pub crate_name: Symbol,
#[subdiagnostic]
@ -43,32 +48,36 @@ pub struct CrateDepMultiple {
}
#[derive(Subdiagnostic)]
#[note(metadata_crate_dep_not_static)]
#[note("`{$crate_name}` was unavailable as a static crate, preventing fully static linking")]
pub struct NonStaticCrateDep {
/// It's different from `crate_name` in main Diagnostic.
pub crate_name_: Symbol,
}
#[derive(Subdiagnostic)]
#[help(metadata_crate_dep_rustc_driver)]
#[help("`feature(rustc_private)` is needed to link to the compiler's `rustc_driver` library")]
pub struct RustcDriverHelp;
#[derive(Diagnostic)]
#[diag(metadata_two_panic_runtimes)]
#[diag("cannot link together two panic runtimes: {$prev_name} and {$cur_name}")]
pub struct TwoPanicRuntimes {
pub prev_name: Symbol,
pub cur_name: Symbol,
}
#[derive(Diagnostic)]
#[diag(metadata_bad_panic_strategy)]
#[diag(
"the linked panic runtime `{$runtime}` is not compiled with this crate's panic strategy `{$strategy}`"
)]
pub struct BadPanicStrategy {
pub runtime: Symbol,
pub strategy: PanicStrategy,
}
#[derive(Diagnostic)]
#[diag(metadata_required_panic_strategy)]
#[diag(
"the crate `{$crate_name}` requires panic strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}`"
)]
pub struct RequiredPanicStrategy {
pub crate_name: Symbol,
pub found_strategy: PanicStrategy,
@ -76,17 +85,23 @@ pub struct RequiredPanicStrategy {
}
#[derive(Diagnostic)]
#[diag(metadata_incompatible_with_immediate_abort)]
#[diag(
"the crate `{$crate_name}` was compiled with a panic strategy which is incompatible with `immediate-abort`"
)]
pub struct IncompatibleWithImmediateAbort {
pub crate_name: Symbol,
}
#[derive(Diagnostic)]
#[diag(metadata_incompatible_with_immediate_abort_core)]
#[diag(
"the crate `core` was compiled with a panic strategy which is incompatible with `immediate-abort`"
)]
pub struct IncompatibleWithImmediateAbortCore;
#[derive(Diagnostic)]
#[diag(metadata_incompatible_panic_in_drop_strategy)]
#[diag(
"the crate `{$crate_name}` is compiled with the panic-in-drop strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}`"
)]
pub struct IncompatiblePanicInDropStrategy {
pub crate_name: Symbol,
pub found_strategy: PanicStrategy,
@ -94,126 +109,138 @@ pub struct IncompatiblePanicInDropStrategy {
}
#[derive(Diagnostic)]
#[diag(metadata_link_ordinal_raw_dylib)]
#[diag("`#[link_ordinal]` is only supported if link kind is `raw-dylib`")]
pub struct LinkOrdinalRawDylib {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_lib_framework_apple)]
#[diag("library kind `framework` is only supported on Apple targets")]
pub struct LibFrameworkApple;
#[derive(Diagnostic)]
#[diag(metadata_empty_renaming_target)]
#[diag("an empty renaming target was specified for library `{$lib_name}`")]
pub struct EmptyRenamingTarget<'a> {
pub lib_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_renaming_no_link)]
#[diag(
"renaming of the library `{$lib_name}` was specified, however this crate contains no `#[link(...)]` attributes referencing this library"
)]
pub struct RenamingNoLink<'a> {
pub lib_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_multiple_renamings)]
#[diag("multiple renamings were specified for library `{$lib_name}`")]
pub struct MultipleRenamings<'a> {
pub lib_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_no_link_mod_override)]
#[diag("overriding linking modifiers from command line is not supported")]
pub struct NoLinkModOverride {
#[primary_span]
pub span: Option<Span>,
}
#[derive(Diagnostic)]
#[diag(metadata_raw_dylib_unsupported_abi)]
#[diag("ABI not supported by `#[link(kind = \"raw-dylib\")]` on this architecture")]
pub struct RawDylibUnsupportedAbi {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_fail_create_file_encoder)]
#[diag("failed to create file encoder: {$err}")]
pub struct FailCreateFileEncoder {
pub err: Error,
}
#[derive(Diagnostic)]
#[diag(metadata_fail_write_file)]
#[diag("failed to write to `{$path}`: {$err}")]
pub struct FailWriteFile<'a> {
pub path: &'a Path,
pub err: Error,
}
#[derive(Diagnostic)]
#[diag(metadata_crate_not_panic_runtime)]
#[diag("the crate `{$crate_name}` is not a panic runtime")]
pub struct CrateNotPanicRuntime {
pub crate_name: Symbol,
}
#[derive(Diagnostic)]
#[diag(metadata_crate_not_compiler_builtins)]
#[diag(
"the crate `{$crate_name}` resolved as `compiler_builtins` but is not `#![compiler_builtins]`"
)]
pub struct CrateNotCompilerBuiltins {
pub crate_name: Symbol,
}
#[derive(Diagnostic)]
#[diag(metadata_no_panic_strategy)]
#[diag("the crate `{$crate_name}` does not have the panic strategy `{$strategy}`")]
pub struct NoPanicStrategy {
pub crate_name: Symbol,
pub strategy: PanicStrategy,
}
#[derive(Diagnostic)]
#[diag(metadata_not_profiler_runtime)]
#[diag("the crate `{$crate_name}` is not a profiler runtime")]
pub struct NotProfilerRuntime {
pub crate_name: Symbol,
}
#[derive(Diagnostic)]
#[diag(metadata_no_multiple_global_alloc)]
#[diag("cannot define multiple global allocators")]
pub struct NoMultipleGlobalAlloc {
#[primary_span]
#[label]
#[label("cannot define a new global allocator")]
pub span2: Span,
#[label(metadata_prev_global_alloc)]
#[label("previous global allocator defined here")]
pub span1: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_no_multiple_alloc_error_handler)]
#[diag("cannot define multiple allocation error handlers")]
pub struct NoMultipleAllocErrorHandler {
#[primary_span]
#[label]
#[label("cannot define a new allocation error handler")]
pub span2: Span,
#[label(metadata_prev_alloc_error_handler)]
#[label("previous allocation error handler defined here")]
pub span1: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_conflicting_global_alloc)]
#[diag(
"the `#[global_allocator]` in {$other_crate_name} conflicts with global allocator in: {$crate_name}"
)]
pub struct ConflictingGlobalAlloc {
pub crate_name: Symbol,
pub other_crate_name: Symbol,
}
#[derive(Diagnostic)]
#[diag(metadata_conflicting_alloc_error_handler)]
#[diag(
"the `#[alloc_error_handler]` in {$other_crate_name} conflicts with allocation error handler in: {$crate_name}"
)]
pub struct ConflictingAllocErrorHandler {
pub crate_name: Symbol,
pub other_crate_name: Symbol,
}
#[derive(Diagnostic)]
#[diag(metadata_global_alloc_required)]
#[diag(
"no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait"
)]
pub struct GlobalAllocRequired;
#[derive(Diagnostic)]
#[diag(metadata_no_transitive_needs_dep)]
#[diag(
"the crate `{$crate_name}` cannot depend on a crate that needs {$needs_crate_name}, but it depends on `{$deps_crate_name}`"
)]
pub struct NoTransitiveNeedsDep<'a> {
pub crate_name: Symbol,
pub needs_crate_name: &'a str,
@ -221,25 +248,27 @@ pub struct NoTransitiveNeedsDep<'a> {
}
#[derive(Diagnostic)]
#[diag(metadata_failed_write_error)]
#[diag("failed to write {$filename}: {$err}")]
pub struct FailedWriteError {
pub filename: PathBuf,
pub err: Error,
}
#[derive(Diagnostic)]
#[diag(metadata_failed_copy_to_stdout)]
#[diag("failed to copy {$filename} to stdout: {$err}")]
pub struct FailedCopyToStdout {
pub filename: PathBuf,
pub err: Error,
}
#[derive(Diagnostic)]
#[diag(metadata_binary_output_to_tty)]
#[diag(
"option `-o` or `--emit` is used to write binary output type `metadata` to stdout, but stdout is a tty"
)]
pub struct BinaryOutputToTty;
#[derive(Diagnostic)]
#[diag(metadata_missing_native_library)]
#[diag("could not find native static library `{$libname}`, perhaps an -L flag is missing?")]
pub struct MissingNativeLibrary<'a> {
libname: &'a str,
#[subdiagnostic]
@ -273,32 +302,32 @@ impl<'a> MissingNativeLibrary<'a> {
}
#[derive(Subdiagnostic)]
#[help(metadata_only_provide_library_name)]
#[help("only provide the library name `{$suggested_name}`, not the full filename")]
pub struct SuggestLibraryName<'a> {
suggested_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_failed_create_tempdir)]
#[diag("couldn't create a temp dir: {$err}")]
pub struct FailedCreateTempdir {
pub err: Error,
}
#[derive(Diagnostic)]
#[diag(metadata_failed_create_file)]
#[diag("failed to create the file {$filename}: {$err}")]
pub struct FailedCreateFile<'a> {
pub filename: &'a Path,
pub err: Error,
}
#[derive(Diagnostic)]
#[diag(metadata_failed_create_encoded_metadata)]
#[diag("failed to create encoded metadata from file: {$err}")]
pub struct FailedCreateEncodedMetadata {
pub err: Error,
}
#[derive(Diagnostic)]
#[diag(metadata_non_ascii_name)]
#[diag("cannot load a crate with a non-ascii name `{$crate_name}`")]
pub struct NonAsciiName {
#[primary_span]
pub span: Span,
@ -306,7 +335,7 @@ pub struct NonAsciiName {
}
#[derive(Diagnostic)]
#[diag(metadata_extern_location_not_exist)]
#[diag("extern location for {$crate_name} does not exist: {$location}")]
pub struct ExternLocationNotExist<'a> {
#[primary_span]
pub span: Span,
@ -315,7 +344,7 @@ pub struct ExternLocationNotExist<'a> {
}
#[derive(Diagnostic)]
#[diag(metadata_extern_location_not_file)]
#[diag("extern location for {$crate_name} is not a file: {$location}")]
pub struct ExternLocationNotFile<'a> {
#[primary_span]
pub span: Span,
@ -332,7 +361,11 @@ pub(crate) struct MultipleCandidates {
impl<G: EmissionGuarantee> Diagnostic<'_, G> for MultipleCandidates {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let mut diag = Diag::new(dcx, level, fluent::metadata_multiple_candidates);
let mut diag = Diag::new(
dcx,
level,
inline_fluent!("multiple candidates for `{$flavor}` dependency `{$crate_name}` found"),
);
diag.arg("crate_name", self.crate_name);
diag.arg("flavor", self.flavor);
diag.code(E0464);
@ -345,7 +378,9 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for MultipleCandidates {
}
#[derive(Diagnostic)]
#[diag(metadata_full_metadata_not_found)]
#[diag(
"only metadata stub found for `{$flavor}` dependency `{$crate_name}` please provide path to the corresponding .rmeta file with full metadata"
)]
pub(crate) struct FullMetadataNotFound {
#[primary_span]
pub span: Span,
@ -354,7 +389,7 @@ pub(crate) struct FullMetadataNotFound {
}
#[derive(Diagnostic)]
#[diag(metadata_symbol_conflicts_current, code = E0519)]
#[diag("the current crate is indistinguishable from one of its dependencies: it has the same crate-name `{$crate_name}` and was compiled with the same `-C metadata` arguments, so this will result in symbol conflicts between the two", code = E0519)]
pub struct SymbolConflictsCurrent {
#[primary_span]
pub span: Span,
@ -362,7 +397,7 @@ pub struct SymbolConflictsCurrent {
}
#[derive(Diagnostic)]
#[diag(metadata_stable_crate_id_collision)]
#[diag("found crates (`{$crate_name0}` and `{$crate_name1}`) with colliding StableCrateId values")]
pub struct StableCrateIdCollision {
#[primary_span]
pub span: Span,
@ -371,7 +406,7 @@ pub struct StableCrateIdCollision {
}
#[derive(Diagnostic)]
#[diag(metadata_dl_error)]
#[diag("{$path}{$err}")]
pub struct DlError {
#[primary_span]
pub span: Span,
@ -380,9 +415,9 @@ pub struct DlError {
}
#[derive(Diagnostic)]
#[diag(metadata_newer_crate_version, code = E0460)]
#[note]
#[note(metadata_found_crate_versions)]
#[diag("found possibly newer version of crate `{$crate_name}`{$add_info}", code = E0460)]
#[note("perhaps that crate needs to be recompiled?")]
#[note("the following crate versions were found:{$found_crates}")]
pub struct NewerCrateVersion {
#[primary_span]
pub span: Span,
@ -392,8 +427,8 @@ pub struct NewerCrateVersion {
}
#[derive(Diagnostic)]
#[diag(metadata_no_crate_with_triple, code = E0461)]
#[note(metadata_found_crate_versions)]
#[diag("couldn't find crate `{$crate_name}` with expected target triple {$locator_triple}{$add_info}", code = E0461)]
#[note("the following crate versions were found:{$found_crates}")]
pub struct NoCrateWithTriple<'a> {
#[primary_span]
pub span: Span,
@ -404,9 +439,9 @@ pub struct NoCrateWithTriple<'a> {
}
#[derive(Diagnostic)]
#[diag(metadata_found_staticlib, code = E0462)]
#[note(metadata_found_crate_versions)]
#[help]
#[diag("found staticlib `{$crate_name}` instead of rlib or dylib{$add_info}", code = E0462)]
#[note("the following crate versions were found:{$found_crates}")]
#[help("please recompile that crate using --crate-type lib")]
pub struct FoundStaticlib {
#[primary_span]
pub span: Span,
@ -416,9 +451,11 @@ pub struct FoundStaticlib {
}
#[derive(Diagnostic)]
#[diag(metadata_incompatible_rustc, code = E0514)]
#[note(metadata_found_crate_versions)]
#[help]
#[diag("found crate `{$crate_name}` compiled by an incompatible version of rustc{$add_info}", code = E0514)]
#[note("the following crate versions were found:{$found_crates}")]
#[help(
"please recompile that crate using this compiler ({$rustc_version}) (consider running `cargo clean` first)"
)]
pub struct IncompatibleRustc {
#[primary_span]
pub span: Span,
@ -438,7 +475,11 @@ pub struct InvalidMetadataFiles {
impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidMetadataFiles {
#[track_caller]
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let mut diag = Diag::new(dcx, level, fluent::metadata_invalid_meta_files);
let mut diag = Diag::new(
dcx,
level,
inline_fluent!("found invalid metadata files for crate `{$crate_name}`{$add_info}"),
);
diag.arg("crate_name", self.crate_name);
diag.arg("add_info", self.add_info);
diag.code(E0786);
@ -466,7 +507,11 @@ pub struct CannotFindCrate {
impl<G: EmissionGuarantee> Diagnostic<'_, G> for CannotFindCrate {
#[track_caller]
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let mut diag = Diag::new(dcx, level, fluent::metadata_cannot_find_crate);
let mut diag = Diag::new(
dcx,
level,
inline_fluent!("can't find crate for `{$crate_name}`{$add_info}"),
);
diag.arg("crate_name", self.crate_name);
diag.arg("current_crate", self.current_crate);
diag.arg("add_info", self.add_info);
@ -475,9 +520,11 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for CannotFindCrate {
diag.span(self.span);
if self.crate_name == sym::std || self.crate_name == sym::core {
if self.missing_core {
diag.note(fluent::metadata_target_not_installed);
diag.note(inline_fluent!("the `{$locator_triple}` target may not be installed"));
} else {
diag.note(fluent::metadata_target_no_std_support);
diag.note(inline_fluent!(
"the `{$locator_triple}` target may not support the standard library"
));
}
let has_precompiled_std = !self.is_tier_3;
@ -485,12 +532,14 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for CannotFindCrate {
if self.missing_core {
if env!("CFG_RELEASE_CHANNEL") == "dev" && !self.is_ui_testing {
// Note: Emits the nicer suggestion only for the dev channel.
diag.help(fluent::metadata_consider_adding_std);
diag.help(inline_fluent!("consider adding the standard library to the sysroot with `x build library --target {$locator_triple}`"));
} else if has_precompiled_std {
// NOTE: this suggests using rustup, even though the user may not have it installed.
// That's because they could choose to install it; or this may give them a hint which
// target they need to install from their distro.
diag.help(fluent::metadata_consider_downloading_target);
diag.help(inline_fluent!(
"consider downloading the target with `rustup target add {$locator_triple}`"
));
}
}
@ -499,25 +548,27 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for CannotFindCrate {
// If it's not a dummy, that means someone added `extern crate std` explicitly and
// `#![no_std]` won't help.
if !self.missing_core && self.span.is_dummy() {
diag.note(fluent::metadata_std_required);
diag.note(inline_fluent!("`std` is required by `{$current_crate}` because it does not declare `#![no_std]`"));
}
// Recommend -Zbuild-std even on stable builds for Tier 3 targets because
// it's the recommended way to use the target, the user should switch to nightly.
if self.is_nightly_build || !has_precompiled_std {
diag.help(fluent::metadata_consider_building_std);
diag.help(inline_fluent!("consider building the standard library from source with `cargo build -Zbuild-std`"));
}
} else if self.crate_name == self.profiler_runtime {
diag.note(fluent::metadata_compiler_missing_profiler);
diag.note(inline_fluent!(
"the compiler may have been built without the profiler runtime"
));
} else if self.crate_name.as_str().starts_with("rustc_") {
diag.help(fluent::metadata_install_missing_components);
diag.help(inline_fluent!("maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`"));
}
diag.span_label(self.span, fluent::metadata_cant_find_crate);
diag.span_label(self.span, inline_fluent!("can't find crate"));
diag
}
}
#[derive(Diagnostic)]
#[diag(metadata_crate_location_unknown_type)]
#[diag("extern location for {$crate_name} is of an unknown type: {$path}")]
pub struct CrateLocationUnknownType<'a> {
#[primary_span]
pub span: Span,
@ -526,7 +577,7 @@ pub struct CrateLocationUnknownType<'a> {
}
#[derive(Diagnostic)]
#[diag(metadata_lib_filename_form)]
#[diag("file name should be lib*.rlib or {$dll_prefix}*{$dll_suffix}")]
pub struct LibFilenameForm<'a> {
#[primary_span]
pub span: Span,
@ -535,18 +586,28 @@ pub struct LibFilenameForm<'a> {
}
#[derive(Diagnostic)]
#[diag(metadata_wasm_c_abi)]
#[diag(
"older versions of the `wasm-bindgen` crate are incompatible with current versions of Rust; please update to `wasm-bindgen` v0.2.88"
)]
pub(crate) struct WasmCAbi {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_incompatible_target_modifiers)]
#[help]
#[note]
#[help(metadata_incompatible_target_modifiers_help_fix)]
#[help(metadata_incompatible_target_modifiers_help_allow)]
#[diag("mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`")]
#[help(
"the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely"
)]
#[note(
"`{$flag_name_prefixed}={$local_value}` in this crate is incompatible with `{$flag_name_prefixed}={$extern_value}` in dependency `{$extern_crate}`"
)]
#[help(
"set `{$flag_name_prefixed}={$extern_value}` in this crate or `{$flag_name_prefixed}={$local_value}` in `{$extern_crate}`"
)]
#[help(
"if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error"
)]
pub struct IncompatibleTargetModifiers {
#[primary_span]
pub span: Span,
@ -559,11 +620,19 @@ pub struct IncompatibleTargetModifiers {
}
#[derive(Diagnostic)]
#[diag(metadata_incompatible_target_modifiers_l_missed)]
#[help]
#[note]
#[help(metadata_incompatible_target_modifiers_help_fix_l_missed)]
#[help(metadata_incompatible_target_modifiers_help_allow)]
#[diag("mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`")]
#[help(
"the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely"
)]
#[note(
"unset `{$flag_name_prefixed}` in this crate is incompatible with `{$flag_name_prefixed}={$extern_value}` in dependency `{$extern_crate}`"
)]
#[help(
"set `{$flag_name_prefixed}={$extern_value}` in this crate or unset `{$flag_name_prefixed}` in `{$extern_crate}`"
)]
#[help(
"if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error"
)]
pub struct IncompatibleTargetModifiersLMissed {
#[primary_span]
pub span: Span,
@ -575,11 +644,19 @@ pub struct IncompatibleTargetModifiersLMissed {
}
#[derive(Diagnostic)]
#[diag(metadata_incompatible_target_modifiers_r_missed)]
#[help]
#[note]
#[help(metadata_incompatible_target_modifiers_help_fix_r_missed)]
#[help(metadata_incompatible_target_modifiers_help_allow)]
#[diag("mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`")]
#[help(
"the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely"
)]
#[note(
"`{$flag_name_prefixed}={$local_value}` in this crate is incompatible with unset `{$flag_name_prefixed}` in dependency `{$extern_crate}`"
)]
#[help(
"unset `{$flag_name_prefixed}` in this crate or set `{$flag_name_prefixed}={$local_value}` in `{$extern_crate}`"
)]
#[help(
"if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error"
)]
pub struct IncompatibleTargetModifiersRMissed {
#[primary_span]
pub span: Span,
@ -591,7 +668,9 @@ pub struct IncompatibleTargetModifiersRMissed {
}
#[derive(Diagnostic)]
#[diag(metadata_unknown_target_modifier_unsafe_allowed)]
#[diag(
"unknown target modifier `{$flag_name}`, requested by `-Cunsafe-allow-abi-mismatch={$flag_name}`"
)]
pub struct UnknownTargetModifierUnsafeAllowed {
#[primary_span]
pub span: Span,
@ -599,8 +678,12 @@ pub struct UnknownTargetModifierUnsafeAllowed {
}
#[derive(Diagnostic)]
#[diag(metadata_async_drop_types_in_dependency)]
#[help]
#[diag(
"found async drop types in dependency `{$extern_crate}`, but async_drop feature is disabled for `{$local_crate}`"
)]
#[help(
"if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used"
)]
pub struct AsyncDropTypesInDependency {
#[primary_span]
pub span: Span,
@ -609,7 +692,7 @@ pub struct AsyncDropTypesInDependency {
}
#[derive(Diagnostic)]
#[diag(metadata_raw_dylib_malformed)]
#[diag("link name must be well-formed if link kind is `raw-dylib`")]
pub struct RawDylibMalformed {
#[primary_span]
pub span: Span,

View file

@ -34,5 +34,3 @@ pub use native_libs::{
try_find_native_static_library, walk_native_lib_search_dirs,
};
pub use rmeta::{EncodedMetadata, METADATA_HEADER, encode_metadata, rendered_const};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -1,11 +1,7 @@
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalModDefId, ModDefId};
use rustc_hir::def_id::DefId;
use rustc_hir::definitions::DefPathHash;
use rustc_hir::{HirId, ItemLocalId, OwnerId};
pub use rustc_query_system::dep_graph::DepNode;
use rustc_query_system::dep_graph::FingerprintStyle;
pub use rustc_query_system::dep_graph::dep_node::DepKind;
pub(crate) use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
use rustc_query_system::dep_graph::dep_node::DepKind;
use rustc_query_system::dep_graph::{DepContext, DepNode, FingerprintStyle};
use rustc_span::Symbol;
use crate::mir::mono::MonoItem;
@ -176,223 +172,3 @@ pub fn dep_kind_from_label(label: &str) -> DepKind {
dep_kind_from_label_string(label)
.unwrap_or_else(|_| panic!("Query label {label} does not exist"))
}
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for () {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::Unit
}
#[inline(always)]
fn to_fingerprint(&self, _: TyCtxt<'tcx>) -> Fingerprint {
Fingerprint::ZERO
}
#[inline(always)]
fn recover(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self> {
Some(())
}
}
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for DefId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
tcx.def_path_hash(*self).0
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
tcx.def_path_str(*self)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx)
}
}
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalDefId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
self.to_def_id().to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
self.to_def_id().to_debug_str(tcx)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.expect_local())
}
}
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for OwnerId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
self.to_def_id().to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
self.to_def_id().to_debug_str(tcx)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| OwnerId { def_id: id.expect_local() })
}
}
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for CrateNum {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
let def_id = self.as_def_id();
def_id.to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
tcx.crate_name(*self).to_string()
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.krate)
}
}
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId) {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::Opaque
}
// We actually would not need to specialize the implementation of this
// method but it's faster to combine the hashes than to instantiate a full
// hashing context and stable-hashing state.
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
let (def_id_0, def_id_1) = *self;
let def_path_hash_0 = tcx.def_path_hash(def_id_0);
let def_path_hash_1 = tcx.def_path_hash(def_id_1);
def_path_hash_0.0.combine(def_path_hash_1.0)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
let (def_id_0, def_id_1) = *self;
format!("({}, {})", tcx.def_path_debug_str(def_id_0), tcx.def_path_debug_str(def_id_1))
}
}
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::HirId
}
// We actually would not need to specialize the implementation of this
// method but it's faster to combine the hashes than to instantiate a full
// hashing context and stable-hashing state.
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
let HirId { owner, local_id } = *self;
let def_path_hash = tcx.def_path_hash(owner.to_def_id());
Fingerprint::new(
// `owner` is local, so is completely defined by the local hash
def_path_hash.local_hash(),
local_id.as_u32() as u64,
)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
let HirId { owner, local_id } = *self;
format!("{}.{}", tcx.def_path_str(owner), local_id.as_u32())
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
if tcx.fingerprint_style(dep_node.kind) == FingerprintStyle::HirId {
let (local_hash, local_id) = Fingerprint::from(dep_node.hash).split();
let def_path_hash = DefPathHash::new(tcx.stable_crate_id(LOCAL_CRATE), local_hash);
let def_id = tcx.def_path_hash_to_def_id(def_path_hash)?.expect_local();
let local_id = local_id
.as_u64()
.try_into()
.unwrap_or_else(|_| panic!("local id should be u32, found {local_id:?}"));
Some(HirId { owner: OwnerId { def_id }, local_id: ItemLocalId::from_u32(local_id) })
} else {
None
}
}
}
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for ModDefId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
self.to_def_id().to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
self.to_def_id().to_debug_str(tcx)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
DefId::recover(tcx, dep_node).map(ModDefId::new_unchecked)
}
}
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalModDefId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
self.to_def_id().to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
self.to_def_id().to_debug_str(tcx)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
LocalDefId::recover(tcx, dep_node).map(LocalModDefId::new_unchecked)
}
}

View file

@ -0,0 +1,228 @@
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalModDefId, ModDefId};
use rustc_hir::definitions::DefPathHash;
use rustc_hir::{HirId, ItemLocalId, OwnerId};
use rustc_query_system::dep_graph::{DepContext, DepNode, DepNodeKey, FingerprintStyle};
use crate::dep_graph::DepNodeExt;
use crate::ty::TyCtxt;
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for () {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::Unit
}
#[inline(always)]
fn to_fingerprint(&self, _: TyCtxt<'tcx>) -> Fingerprint {
Fingerprint::ZERO
}
#[inline(always)]
fn recover(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self> {
Some(())
}
}
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for DefId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
tcx.def_path_hash(*self).0
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
tcx.def_path_str(*self)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx)
}
}
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for LocalDefId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
self.to_def_id().to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
self.to_def_id().to_debug_str(tcx)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.expect_local())
}
}
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for OwnerId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
self.to_def_id().to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
self.to_def_id().to_debug_str(tcx)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| OwnerId { def_id: id.expect_local() })
}
}
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for CrateNum {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
let def_id = self.as_def_id();
def_id.to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
tcx.crate_name(*self).to_string()
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.krate)
}
}
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for (DefId, DefId) {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::Opaque
}
// We actually would not need to specialize the implementation of this
// method but it's faster to combine the hashes than to instantiate a full
// hashing context and stable-hashing state.
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
let (def_id_0, def_id_1) = *self;
let def_path_hash_0 = tcx.def_path_hash(def_id_0);
let def_path_hash_1 = tcx.def_path_hash(def_id_1);
def_path_hash_0.0.combine(def_path_hash_1.0)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
let (def_id_0, def_id_1) = *self;
format!("({}, {})", tcx.def_path_debug_str(def_id_0), tcx.def_path_debug_str(def_id_1))
}
}
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for HirId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::HirId
}
// We actually would not need to specialize the implementation of this
// method but it's faster to combine the hashes than to instantiate a full
// hashing context and stable-hashing state.
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
let HirId { owner, local_id } = *self;
let def_path_hash = tcx.def_path_hash(owner.to_def_id());
Fingerprint::new(
// `owner` is local, so is completely defined by the local hash
def_path_hash.local_hash(),
local_id.as_u32() as u64,
)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
let HirId { owner, local_id } = *self;
format!("{}.{}", tcx.def_path_str(owner), local_id.as_u32())
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
if tcx.fingerprint_style(dep_node.kind) == FingerprintStyle::HirId {
let (local_hash, local_id) = Fingerprint::from(dep_node.hash).split();
let def_path_hash = DefPathHash::new(tcx.stable_crate_id(LOCAL_CRATE), local_hash);
let def_id = tcx.def_path_hash_to_def_id(def_path_hash)?.expect_local();
let local_id = local_id
.as_u64()
.try_into()
.unwrap_or_else(|_| panic!("local id should be u32, found {local_id:?}"));
Some(HirId { owner: OwnerId { def_id }, local_id: ItemLocalId::from_u32(local_id) })
} else {
None
}
}
}
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for ModDefId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
self.to_def_id().to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
self.to_def_id().to_debug_str(tcx)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
DefId::recover(tcx, dep_node).map(ModDefId::new_unchecked)
}
}
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for LocalModDefId {
#[inline(always)]
fn fingerprint_style() -> FingerprintStyle {
FingerprintStyle::DefPathHash
}
#[inline(always)]
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
self.to_def_id().to_fingerprint(tcx)
}
#[inline(always)]
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
self.to_def_id().to_debug_str(tcx)
}
#[inline(always)]
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
LocalDefId::recover(tcx, dep_node).map(LocalModDefId::new_unchecked)
}
}

View file

@ -7,15 +7,17 @@ use crate::ty::{self, TyCtxt};
#[macro_use]
mod dep_node;
mod dep_node_key;
pub use dep_node::{DepKind, DepNode, DepNodeExt, dep_kind_from_label, dep_kinds, label_strs};
pub(crate) use dep_node::{make_compile_codegen_unit, make_compile_mono_item, make_metadata};
pub use rustc_query_system::dep_graph::debug::{DepNodeFilter, EdgeFilter};
pub use rustc_query_system::dep_graph::{
DepContext, DepGraphQuery, DepNodeIndex, Deps, SerializedDepGraph, SerializedDepNodeIndex,
TaskDepsRef, WorkProduct, WorkProductId, WorkProductMap, hash_result,
DepContext, DepGraphQuery, DepKind, DepNode, DepNodeIndex, Deps, SerializedDepGraph,
SerializedDepNodeIndex, TaskDepsRef, WorkProduct, WorkProductId, WorkProductMap, hash_result,
};
pub use self::dep_node::{DepNodeExt, dep_kind_from_label, dep_kinds, label_strs};
pub(crate) use self::dep_node::{make_compile_codegen_unit, make_compile_mono_item, make_metadata};
pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepsType>;
pub type DepKindVTable<'tcx> = rustc_query_system::dep_graph::DepKindVTable<TyCtxt<'tcx>>;

View file

@ -81,7 +81,6 @@ pub mod thir;
pub mod traits;
pub mod ty;
pub mod util;
mod values;
#[macro_use]
pub mod query;

View file

@ -1,7 +1,7 @@
//! Helper functions that serve as the immediate implementation of
//! `tcx.$query(..)` and its variations.
use rustc_query_system::dep_graph::{DepKind, DepNodeParams};
use rustc_query_system::dep_graph::{DepKind, DepNodeKey};
use rustc_query_system::query::{QueryCache, QueryMode, try_get_cached};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
@ -86,7 +86,7 @@ pub(crate) fn query_feed<'tcx, Cache>(
value: Cache::Value,
) where
Cache: QueryCache,
Cache::Key: DepNodeParams<TyCtxt<'tcx>>,
Cache::Key: DepNodeKey<TyCtxt<'tcx>>,
{
let format_value = query_vtable.format_value;

View file

@ -13,6 +13,7 @@ mod keys;
pub mod on_disk_cache;
#[macro_use]
pub mod plumbing;
pub mod values;
pub fn describe_as_module(def_id: impl Into<LocalDefId>, tcx: TyCtxt<'_>) -> String {
let def_id = def_id.into();

View file

@ -7,7 +7,6 @@ use rustc_errors::codes::*;
use rustc_errors::{Applicability, MultiSpan, pluralize, struct_span_code_err};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_query_system::Value;
use rustc_query_system::query::{CycleError, report_cycle};
use rustc_span::def_id::LocalDefId;
use rustc_span::{ErrorGuaranteed, Span};
@ -16,7 +15,27 @@ use crate::dep_graph::dep_kinds;
use crate::query::plumbing::CyclePlaceholder;
use crate::ty::{self, Representability, Ty, TyCtxt};
impl<'tcx> Value<TyCtxt<'tcx>> for Ty<'_> {
pub trait Value<'tcx>: Sized {
fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed)
-> Self;
}
impl<'tcx, T> Value<'tcx> for T {
default fn from_cycle_error(
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
_guar: ErrorGuaranteed,
) -> T {
tcx.sess.dcx().abort_if_errors();
bug!(
"<{} as Value>::from_cycle_error called without errors: {:#?}",
std::any::type_name::<T>(),
cycle_error.cycle,
);
}
}
impl<'tcx> Value<'tcx> for Ty<'_> {
fn from_cycle_error(tcx: TyCtxt<'tcx>, _: &CycleError, guar: ErrorGuaranteed) -> Self {
// SAFETY: This is never called when `Self` is not `Ty<'tcx>`.
// FIXME: Represent the above fact in the trait system somehow.
@ -24,13 +43,13 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Ty<'_> {
}
}
impl<'tcx> Value<TyCtxt<'tcx>> for Result<ty::EarlyBinder<'_, Ty<'_>>, CyclePlaceholder> {
impl<'tcx> Value<'tcx> for Result<ty::EarlyBinder<'_, Ty<'_>>, CyclePlaceholder> {
fn from_cycle_error(_tcx: TyCtxt<'tcx>, _: &CycleError, guar: ErrorGuaranteed) -> Self {
Err(CyclePlaceholder(guar))
}
}
impl<'tcx> Value<TyCtxt<'tcx>> for ty::SymbolName<'_> {
impl<'tcx> Value<'tcx> for ty::SymbolName<'_> {
fn from_cycle_error(tcx: TyCtxt<'tcx>, _: &CycleError, _guar: ErrorGuaranteed) -> Self {
// SAFETY: This is never called when `Self` is not `SymbolName<'tcx>`.
// FIXME: Represent the above fact in the trait system somehow.
@ -42,7 +61,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::SymbolName<'_> {
}
}
impl<'tcx> Value<TyCtxt<'tcx>> for ty::Binder<'_, ty::FnSig<'_>> {
impl<'tcx> Value<'tcx> for ty::Binder<'_, ty::FnSig<'_>> {
fn from_cycle_error(
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
@ -76,7 +95,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::Binder<'_, ty::FnSig<'_>> {
}
}
impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
impl<'tcx> Value<'tcx> for Representability {
fn from_cycle_error(
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
@ -112,7 +131,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
}
}
impl<'tcx> Value<TyCtxt<'tcx>> for ty::EarlyBinder<'_, Ty<'_>> {
impl<'tcx> Value<'tcx> for ty::EarlyBinder<'_, Ty<'_>> {
fn from_cycle_error(
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
@ -122,7 +141,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::EarlyBinder<'_, Ty<'_>> {
}
}
impl<'tcx> Value<TyCtxt<'tcx>> for ty::EarlyBinder<'_, ty::Binder<'_, ty::FnSig<'_>>> {
impl<'tcx> Value<'tcx> for ty::EarlyBinder<'_, ty::Binder<'_, ty::FnSig<'_>>> {
fn from_cycle_error(
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
@ -132,7 +151,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::EarlyBinder<'_, ty::Binder<'_, ty::FnSig<
}
}
impl<'tcx> Value<TyCtxt<'tcx>> for &[ty::Variance] {
impl<'tcx> Value<'tcx> for &[ty::Variance] {
fn from_cycle_error(
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
@ -180,7 +199,7 @@ fn search_for_cycle_permutation<Q, T>(
otherwise()
}
impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>> {
impl<'tcx, T> Value<'tcx> for Result<T, &'_ ty::layout::LayoutError<'_>> {
fn from_cycle_error(
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
@ -273,7 +292,7 @@ impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>>
// item_and_field_ids should form a cycle where each field contains the
// type in the next element in the list
pub fn recursive_type_error(
fn recursive_type_error(
tcx: TyCtxt<'_>,
mut item_and_field_ids: Vec<(LocalDefId, LocalDefId)>,
representable_ids: &FxHashSet<LocalDefId>,

View file

@ -13,7 +13,6 @@ rustc_ast = { path = "../rustc_ast" }
rustc_const_eval = { path = "../rustc_const_eval" }
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_infer = { path = "../rustc_infer" }

View file

@ -1,114 +0,0 @@
mir_transform_arithmetic_overflow = this arithmetic operation will overflow
mir_transform_asm_unwind_call = call to inline assembly that may unwind
mir_transform_const_defined_here = `const` item defined here
mir_transform_const_modify = attempting to modify a `const` item
.note = each usage of a `const` item creates a new temporary; the original `const` item will not be modified
mir_transform_const_mut_borrow = taking a mutable reference to a `const` item
.note = each usage of a `const` item creates a new temporary
.note2 = the mutable reference will refer to this temporary, not the original `const` item
.note3 = mutable reference created due to call to this method
mir_transform_ffi_unwind_call = call to {$foreign ->
[true] foreign function
*[false] function pointer
} with FFI-unwind ABI
mir_transform_fn_item_ref = taking a reference to a function item does not give a function pointer
.suggestion = cast `{$ident}` to obtain a function pointer
mir_transform_force_inline =
`{$callee}` could not be inlined into `{$caller}` but is required to be inlined
.call = ...`{$callee}` called here
.attr = inlining due to this annotation
.caller = within `{$caller}`...
.callee = `{$callee}` defined here
.note = could not be inlined due to: {$reason}
mir_transform_force_inline_attr =
`{$callee}` is incompatible with `#[rustc_force_inline]`
.attr = annotation here
.callee = `{$callee}` defined here
.note = incompatible due to: {$reason}
mir_transform_force_inline_justification =
`{$callee}` is required to be inlined to: {$sym}
mir_transform_maybe_string_interpolation = you might have meant to use string interpolation in this string literal
mir_transform_must_not_suspend = {$pre}`{$def_path}`{$post} held across a suspend point, but should not be
.label = the value is held across this suspend point
.note = {$reason}
.help = consider using a block (`{"{ ... }"}`) to shrink the value's scope, ending before the suspend point
mir_transform_operation_will_panic = this operation will panic at runtime
mir_transform_string_interpolation_only_works = string interpolation only works in `format!` invocations
mir_transform_tail_expr_drop_order = relative drop order changing in Rust 2024
.temporaries = in Rust 2024, this temporary value will be dropped first
.observers = in Rust 2024, this local variable or temporary value will be dropped second
.note_dtors =
dropping the temporary value runs this custom `Drop` impl, which we could not prove to be side-effect free
.note_observer_dtors =
dropping the local runs this custom `Drop` impl, which we could not prove to be side-effect free
.drop_location =
now the temporary value is dropped here, before the local variables in the block or statement
.note_epilogue = most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
.label_local_epilogue = {$is_dropped_first_edition_2024 ->
[true] up until Edition 2021 `{$name}` is dropped last but will be dropped earlier in Edition 2024
*[false] `{$name}` will be dropped later as of Edition 2024
}
mir_transform_tail_expr_dtor = {$dtor_kind ->
[dyn] `{$name}` may invoke a custom destructor because it contains a trait object
*[concrete] `{$name}` invokes this custom destructor
}
mir_transform_tail_expr_local = {$is_generated_name ->
[true] this value will be stored in a temporary; let us call it `{$name}`
*[false] `{$name}` calls a custom destructor
}
mir_transform_unaligned_packed_ref = reference to field of packed {$ty_descr} is unaligned
.note = this {$ty_descr} is {$align ->
[one] {""}
*[other] {"at most "}
}{$align}-byte aligned, but the type of this field may require higher alignment
.note_ub = creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
.help = copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
mir_transform_unconditional_recursion = function cannot return without recursing
.label = cannot return without recursing
.help = a `loop` may express intention better if this is on purpose
mir_transform_unconditional_recursion_call_site_label = recursive call site
mir_transform_unknown_pass_name = MIR pass `{$name}` is unknown and will be ignored
mir_transform_unused_assign = value assigned to `{$name}` is never read
.help = maybe it is overwritten before being read?
mir_transform_unused_assign_passed = value passed to `{$name}` is never read
.help = maybe it is overwritten before being read?
mir_transform_unused_assign_suggestion =
you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
mir_transform_unused_capture_maybe_capture_ref = value captured by `{$name}` is never read
.help = did you mean to capture by reference instead?
mir_transform_unused_var_assigned_only = variable `{$name}` is assigned to, but never used
.note = consider using `_{$name}` instead
mir_transform_unused_var_underscore = if this is intentional, prefix it with an underscore
mir_transform_unused_variable = unused variable: `{$name}`
mir_transform_unused_variable_args_in_macro = `{$name}` is captured in macro and introduced a unused variable
mir_transform_unused_variable_try_ignore = try ignoring the field
mir_transform_unused_variable_typo = you might have meant to pattern match on the similarly named {$kind} `{$item_name}`

View file

@ -1,5 +1,7 @@
use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintDiagnostic, Subdiagnostic};
use rustc_errors::{
Applicability, Diag, EmissionGuarantee, LintDiagnostic, Subdiagnostic, inline_fluent,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::mir::AssertKind;
use rustc_middle::query::Key;
@ -8,8 +10,6 @@ use rustc_session::lint::{self, Lint};
use rustc_span::def_id::DefId;
use rustc_span::{Ident, Span, Symbol};
use crate::fluent_generated as fluent;
/// Emit diagnostic for calls to `#[inline(always)]`-annotated functions with a
/// `#[target_feature]` attribute where the caller enables a different set of target features.
pub(crate) fn emit_inline_always_target_feature_diagnostic<'a, 'tcx>(
@ -51,22 +51,22 @@ pub(crate) fn emit_inline_always_target_feature_diagnostic<'a, 'tcx>(
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_unconditional_recursion)]
#[help]
#[diag("function cannot return without recursing")]
#[help("a `loop` may express intention better if this is on purpose")]
pub(crate) struct UnconditionalRecursion {
#[label]
#[label("cannot return without recursing")]
pub(crate) span: Span,
#[label(mir_transform_unconditional_recursion_call_site_label)]
#[label("recursive call site")]
pub(crate) call_sites: Vec<Span>,
}
#[derive(Diagnostic)]
#[diag(mir_transform_force_inline_attr)]
#[note]
#[diag("`{$callee}` is incompatible with `#[rustc_force_inline]`")]
#[note("incompatible due to: {$reason}")]
pub(crate) struct InvalidForceInline {
#[primary_span]
pub attr_span: Span,
#[label(mir_transform_callee)]
#[label("`{$callee}` defined here")]
pub callee_span: Span,
pub callee: String,
pub reason: &'static str,
@ -74,28 +74,39 @@ pub(crate) struct InvalidForceInline {
#[derive(LintDiagnostic)]
pub(crate) enum ConstMutate {
#[diag(mir_transform_const_modify)]
#[note]
#[diag("attempting to modify a `const` item")]
#[note(
"each usage of a `const` item creates a new temporary; the original `const` item will not be modified"
)]
Modify {
#[note(mir_transform_const_defined_here)]
#[note("`const` item defined here")]
konst: Span,
},
#[diag(mir_transform_const_mut_borrow)]
#[note]
#[note(mir_transform_note2)]
#[diag("taking a mutable reference to a `const` item")]
#[note("each usage of a `const` item creates a new temporary")]
#[note("the mutable reference will refer to this temporary, not the original `const` item")]
MutBorrow {
#[note(mir_transform_note3)]
#[note("mutable reference created due to call to this method")]
method_call: Option<Span>,
#[note(mir_transform_const_defined_here)]
#[note("`const` item defined here")]
konst: Span,
},
}
#[derive(Diagnostic)]
#[diag(mir_transform_unaligned_packed_ref, code = E0793)]
#[note]
#[note(mir_transform_note_ub)]
#[help]
#[diag("reference to field of packed {$ty_descr} is unaligned", code = E0793)]
#[note(
"this {$ty_descr} is {$align ->
[one] {\"\"}
*[other] {\"at most \"}
}{$align}-byte aligned, but the type of this field may require higher alignment"
)]
#[note(
"creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)"
)]
#[help(
"copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)"
)]
pub(crate) struct UnalignedPackedRef {
#[primary_span]
pub span: Span,
@ -104,7 +115,7 @@ pub(crate) struct UnalignedPackedRef {
}
#[derive(Diagnostic)]
#[diag(mir_transform_unknown_pass_name)]
#[diag("MIR pass `{$name}` is unknown and will be ignored")]
pub(crate) struct UnknownPassName<'a> {
pub(crate) name: &'a str,
}
@ -123,8 +134,12 @@ pub(crate) enum AssertLintKind {
impl<'a, P: std::fmt::Debug> LintDiagnostic<'a, ()> for AssertLint<P> {
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
diag.primary_message(match self.lint_kind {
AssertLintKind::ArithmeticOverflow => fluent::mir_transform_arithmetic_overflow,
AssertLintKind::UnconditionalPanic => fluent::mir_transform_operation_will_panic,
AssertLintKind::ArithmeticOverflow => {
inline_fluent!("this arithmetic operation will overflow")
}
AssertLintKind::UnconditionalPanic => {
inline_fluent!("this operation will panic at runtime")
}
});
let label = self.assert_kind.diagnostic_message();
self.assert_kind.add_args(&mut |name, value| {
@ -144,39 +159,53 @@ impl AssertLintKind {
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_asm_unwind_call)]
#[diag("call to inline assembly that may unwind")]
pub(crate) struct AsmUnwindCall {
#[label(mir_transform_asm_unwind_call)]
#[label("call to inline assembly that may unwind")]
pub span: Span,
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_ffi_unwind_call)]
#[diag(
"call to {$foreign ->
[true] foreign function
*[false] function pointer
} with FFI-unwind ABI"
)]
pub(crate) struct FfiUnwindCall {
#[label(mir_transform_ffi_unwind_call)]
#[label(
"call to {$foreign ->
[true] foreign function
*[false] function pointer
} with FFI-unwind ABI"
)]
pub span: Span,
pub foreign: bool,
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_fn_item_ref)]
#[diag("taking a reference to a function item does not give a function pointer")]
pub(crate) struct FnItemRef {
#[suggestion(code = "{sugg}", applicability = "unspecified")]
#[suggestion(
"cast `{$ident}` to obtain a function pointer",
code = "{sugg}",
applicability = "unspecified"
)]
pub span: Span,
pub sugg: String,
pub ident: Ident,
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_unused_capture_maybe_capture_ref)]
#[help]
#[diag("value captured by `{$name}` is never read")]
#[help("did you mean to capture by reference instead?")]
pub(crate) struct UnusedCaptureMaybeCaptureRef {
pub name: Symbol,
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_unused_var_assigned_only)]
#[note]
#[diag("variable `{$name}` is assigned to, but never used")]
#[note("consider using `_{$name}` instead")]
pub(crate) struct UnusedVarAssignedOnly {
pub name: Symbol,
#[subdiagnostic]
@ -184,17 +213,20 @@ pub(crate) struct UnusedVarAssignedOnly {
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_unused_assign)]
#[diag("value assigned to `{$name}` is never read")]
pub(crate) struct UnusedAssign {
pub name: Symbol,
#[subdiagnostic]
pub suggestion: Option<UnusedAssignSuggestion>,
#[help]
#[help("maybe it is overwritten before being read?")]
pub help: bool,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(mir_transform_unused_assign_suggestion, applicability = "maybe-incorrect")]
#[multipart_suggestion(
"you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding",
applicability = "maybe-incorrect"
)]
pub(crate) struct UnusedAssignSuggestion {
pub pre: &'static str,
#[suggestion_part(code = "{pre}mut ")]
@ -208,14 +240,14 @@ pub(crate) struct UnusedAssignSuggestion {
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_unused_assign_passed)]
#[help]
#[diag("value passed to `{$name}` is never read")]
#[help("maybe it is overwritten before being read?")]
pub(crate) struct UnusedAssignPassed {
pub name: Symbol,
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_unused_variable)]
#[diag("unused variable: `{$name}`")]
pub(crate) struct UnusedVariable {
pub name: Symbol,
#[subdiagnostic]
@ -226,10 +258,7 @@ pub(crate) struct UnusedVariable {
#[derive(Subdiagnostic)]
pub(crate) enum UnusedVariableSugg {
#[multipart_suggestion(
mir_transform_unused_variable_try_ignore,
applicability = "machine-applicable"
)]
#[multipart_suggestion("try ignoring the field", applicability = "machine-applicable")]
TryIgnore {
#[suggestion_part(code = "{name}: _")]
shorthands: Vec<Span>,
@ -239,7 +268,7 @@ pub(crate) enum UnusedVariableSugg {
},
#[multipart_suggestion(
mir_transform_unused_var_underscore,
"if this is intentional, prefix it with an underscore",
applicability = "machine-applicable"
)]
TryPrefix {
@ -250,7 +279,7 @@ pub(crate) enum UnusedVariableSugg {
typo: Option<PatternTypo>,
},
#[help(mir_transform_unused_variable_args_in_macro)]
#[help("`{$name}` is captured in macro and introduced a unused variable")]
NoSugg {
#[primary_span]
span: Span,
@ -266,10 +295,12 @@ impl Subdiagnostic for UnusedVariableStringInterp {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
diag.span_label(
self.lit,
crate::fluent_generated::mir_transform_maybe_string_interpolation,
inline_fluent!(
"you might have meant to use string interpolation in this string literal"
),
);
diag.multipart_suggestion(
crate::fluent_generated::mir_transform_string_interpolation_only_works,
inline_fluent!("string interpolation only works in `format!` invocations"),
vec![
(self.lit.shrink_to_lo(), String::from("format!(")),
(self.lit.shrink_to_hi(), String::from(")")),
@ -281,7 +312,7 @@ impl Subdiagnostic for UnusedVariableStringInterp {
#[derive(Subdiagnostic)]
#[multipart_suggestion(
mir_transform_unused_variable_typo,
"you might have meant to pattern match on the similarly named {$kind} `{$item_name}`",
style = "verbose",
applicability = "maybe-incorrect"
)]
@ -306,12 +337,17 @@ pub(crate) struct MustNotSupend<'a, 'tcx> {
// Needed for def_path_str
impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
diag.primary_message(fluent::mir_transform_must_not_suspend);
diag.span_label(self.yield_sp, fluent::_subdiag::label);
diag.primary_message(inline_fluent!(
"{$pre}`{$def_path}`{$post} held across a suspend point, but should not be"
));
diag.span_label(
self.yield_sp,
inline_fluent!("the value is held across this suspend point"),
);
if let Some(reason) = self.reason {
diag.subdiagnostic(reason);
}
diag.span_help(self.src_sp, fluent::_subdiag::help);
diag.span_help(self.src_sp, inline_fluent!("consider using a block (`{\"{ ... }\"}`) to shrink the value's scope, ending before the suspend point"));
diag.arg("pre", self.pre);
diag.arg("def_path", self.tcx.def_path_str(self.def_id));
diag.arg("post", self.post);
@ -319,7 +355,7 @@ impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> {
}
#[derive(Subdiagnostic)]
#[note(mir_transform_note)]
#[note("{$reason}")]
pub(crate) struct MustNotSuspendReason {
#[primary_span]
pub span: Span,
@ -327,17 +363,17 @@ pub(crate) struct MustNotSuspendReason {
}
#[derive(Diagnostic)]
#[diag(mir_transform_force_inline)]
#[note]
#[diag("`{$callee}` could not be inlined into `{$caller}` but is required to be inlined")]
#[note("could not be inlined due to: {$reason}")]
pub(crate) struct ForceInlineFailure {
#[label(mir_transform_caller)]
#[label("within `{$caller}`...")]
pub caller_span: Span,
#[label(mir_transform_callee)]
#[label("`{$callee}` defined here")]
pub callee_span: Span,
#[label(mir_transform_attr)]
#[label("annotation here")]
pub attr_span: Span,
#[primary_span]
#[label(mir_transform_call)]
#[label("...`{$callee}` called here")]
pub call_span: Span,
pub callee: String,
pub caller: String,
@ -347,7 +383,7 @@ pub(crate) struct ForceInlineFailure {
}
#[derive(Subdiagnostic)]
#[note(mir_transform_force_inline_justification)]
#[note("`{$callee}` is required to be inlined to: {$sym}")]
pub(crate) struct ForceInlineJustification {
pub sym: Symbol,
}

View file

@ -213,8 +213,6 @@ declare_passes! {
mod validate : Validator;
}
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub fn provide(providers: &mut Providers) {
coverage::query::provide(providers);
ffi_unwind_calls::provide(&mut providers.queries);

View file

@ -5,7 +5,7 @@ use std::rc::Rc;
use itertools::Itertools as _;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_errors::Subdiagnostic;
use rustc_errors::{Subdiagnostic, inline_fluent};
use rustc_hir::CRATE_HIR_ID;
use rustc_hir::def_id::LocalDefId;
use rustc_index::bit_set::MixedBitSet;
@ -499,13 +499,17 @@ fn assign_observables_names(
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_tail_expr_drop_order)]
#[diag("relative drop order changing in Rust 2024")]
struct TailExprDropOrderLint<'a> {
#[subdiagnostic]
local_labels: Vec<LocalLabel<'a>>,
#[label(mir_transform_drop_location)]
#[label(
"now the temporary value is dropped here, before the local variables in the block or statement"
)]
drop_span: Option<Span>,
#[note(mir_transform_note_epilogue)]
#[note(
"most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages"
)]
_epilogue: (),
}
@ -527,19 +531,32 @@ impl Subdiagnostic for LocalLabel<'_> {
diag.arg("is_generated_name", self.is_generated_name);
diag.remove_arg("is_dropped_first_edition_2024");
diag.arg("is_dropped_first_edition_2024", self.is_dropped_first_edition_2024);
let msg = diag.eagerly_translate(crate::fluent_generated::mir_transform_tail_expr_local);
let msg = diag.eagerly_translate(inline_fluent!(
"{$is_generated_name ->
[true] this value will be stored in a temporary; let us call it `{$name}`
*[false] `{$name}` calls a custom destructor
}"
));
diag.span_label(self.span, msg);
for dtor in self.destructors {
dtor.add_to_diag(diag);
}
let msg =
diag.eagerly_translate(crate::fluent_generated::mir_transform_label_local_epilogue);
diag.eagerly_translate(inline_fluent!("{$is_dropped_first_edition_2024 ->
[true] up until Edition 2021 `{$name}` is dropped last but will be dropped earlier in Edition 2024
*[false] `{$name}` will be dropped later as of Edition 2024
}"));
diag.span_label(self.span, msg);
}
}
#[derive(Subdiagnostic)]
#[note(mir_transform_tail_expr_dtor)]
#[note(
"{$dtor_kind ->
[dyn] `{$name}` may invoke a custom destructor because it contains a trait object
*[concrete] `{$name}` invokes this custom destructor
}"
)]
struct DestructorLabel<'a> {
#[primary_span]
span: Span,

View file

@ -441,8 +441,6 @@ passes_rustc_allow_const_fn_unstable =
passes_rustc_const_stable_indirect_pairing =
`const_stable_indirect` attribute does not make sense on `rustc_const_stable` function, its behavior is already implied
passes_rustc_dirty_clean =
attribute requires -Z query-dep-graph to be enabled
passes_rustc_force_inline_coro =
attribute cannot be applied to a `async`, `gen` or `async gen` function

View file

@ -284,6 +284,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::Pointee(..)
| AttributeKind::ProfilerRuntime
| AttributeKind::RecursionLimit { .. }
| AttributeKind::ReexportTestHarnessMain(..)
// handled below this loop and elsewhere
| AttributeKind::Repr { .. }
| AttributeKind::RustcAllocator
@ -292,6 +293,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::RustcAsPtr(..)
| AttributeKind::RustcBodyStability { .. }
| AttributeKind::RustcBuiltinMacro { .. }
| AttributeKind::RustcClean(..)
| AttributeKind::RustcCoherenceIsCore(..)
| AttributeKind::RustcCoinductive(..)
| AttributeKind::RustcConfusables { .. }
@ -307,6 +309,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::RustcDynIncompatibleTrait(..)
| AttributeKind::RustcHasIncoherentInherentImpls
| AttributeKind::RustcHiddenTypeOfOpaques
| AttributeKind::RustcIfThisChanged(..)
| AttributeKind::RustcLayout(..)
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
| AttributeKind::RustcLayoutScalarValidRangeStart(..)
@ -335,6 +338,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::RustcSkipDuringMethodDispatch { .. }
| AttributeKind::RustcSpecializationTrait(..)
| AttributeKind::RustcStdInternalSymbol (..)
| AttributeKind::RustcThenThisWouldNeed(..)
| AttributeKind::RustcUnsafeSpecializationMarker(..)
| AttributeKind::RustcVariance
| AttributeKind::RustcVarianceOfOpaques
@ -356,10 +360,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
[sym::diagnostic, sym::on_const, ..] => {
self.check_diagnostic_on_const(attr.span(), hir_id, target, item)
}
[sym::rustc_clean, ..]
| [sym::rustc_dirty, ..]
| [sym::rustc_if_this_changed, ..]
| [sym::rustc_then_this_would_need, ..] => self.check_rustc_dirty_clean(attr),
[sym::autodiff_forward, ..] | [sym::autodiff_reverse, ..] => {
self.check_autodiff(hir_id, attr, span, target)
}
@ -414,8 +414,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| sym::feature
| sym::register_tool
| sym::rustc_no_implicit_bounds
| sym::test_runner
| sym::reexport_test_harness_main,
| sym::test_runner,
..
] => {}
[name, rest@..] => {
@ -1260,14 +1259,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
}
/// Checks that the dep-graph debugging attributes are only present when the query-dep-graph
/// option is passed to the compiler.
fn check_rustc_dirty_clean(&self, attr: &Attribute) {
if !self.tcx.sess.opts.unstable_opts.query_dep_graph {
self.dcx().emit_err(errors::RustcDirtyClean { span: attr.span() });
}
}
/// Checks if the `#[repr]` attributes on `item` are valid.
fn check_repr(
&self,

View file

@ -217,13 +217,6 @@ pub(crate) struct RustcLegacyConstGenericsIndexExceed {
pub arg_count: usize,
}
#[derive(Diagnostic)]
#[diag(passes_rustc_dirty_clean)]
pub(crate) struct RustcDirtyClean {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(passes_repr_conflicting, code = E0566)]
pub(crate) struct ReprConflicting {

View file

@ -7,9 +7,11 @@ edition = "2024"
# tidy-alphabetical-start
measureme = "12.0.1"
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }
rustc_middle = { path = "../rustc_middle" }
rustc_query_system = { path = "../rustc_query_system" }
rustc_serialize = { path = "../rustc_serialize" }

View file

@ -0,0 +1,24 @@
use rustc_hir::limit::Limit;
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol};
#[derive(Diagnostic)]
#[help(
"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
)]
#[diag("queries overflow the depth limit!")]
pub(crate) struct QueryOverflow {
#[primary_span]
pub span: Span,
#[subdiagnostic]
pub note: QueryOverflowNote,
pub suggested_limit: Limit,
pub crate_name: Symbol,
}
#[derive(Subdiagnostic)]
#[note("query depth increased by {$depth} when {$desc}")]
pub(crate) struct QueryOverflowNote {
pub desc: String,
pub depth: usize,
}

View file

@ -19,8 +19,8 @@ use rustc_middle::queries::{
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::values::Value;
use rustc_middle::ty::TyCtxt;
use rustc_query_system::Value;
use rustc_query_system::dep_graph::SerializedDepNodeIndex;
use rustc_query_system::ich::StableHashingContext;
use rustc_query_system::query::{
@ -39,6 +39,8 @@ pub use crate::plumbing::{QueryCtxt, query_key_hash_verify_all};
mod profiling_support;
pub use self::profiling_support::alloc_self_profile_query_strings;
mod error;
#[derive(ConstParamTy)] // Allow this struct to be used for const-generic values.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct QueryFlags {

View file

@ -24,17 +24,17 @@ use rustc_middle::ty::codec::TyEncoder;
use rustc_middle::ty::print::with_reduced_queries;
use rustc_middle::ty::tls::{self, ImplicitCtxt};
use rustc_middle::ty::{self, TyCtxt};
use rustc_query_system::dep_graph::{DepNodeParams, FingerprintStyle, HasDepContext};
use rustc_query_system::dep_graph::{DepNodeKey, FingerprintStyle, HasDepContext};
use rustc_query_system::ich::StableHashingContext;
use rustc_query_system::query::{
QueryCache, QueryContext, QueryDispatcher, QueryJobId, QueryMap, QuerySideEffect,
QueryStackDeferred, QueryStackFrame, QueryStackFrameExtra, force_query,
};
use rustc_query_system::{QueryOverflow, QueryOverflowNote};
use rustc_serialize::{Decodable, Encodable};
use rustc_span::def_id::LOCAL_CRATE;
use crate::QueryDispatcherUnerased;
use crate::error::{QueryOverflow, QueryOverflowNote};
/// Implements [`QueryContext`] for use by [`rustc_query_system`], since that
/// crate does not have direct access to [`TyCtxt`].

View file

@ -23,13 +23,6 @@ impl<Key, Value> Default for Cache<Key, Value> {
}
}
impl<Key, Value> Cache<Key, Value> {
/// Actually frees the underlying memory in contrast to what stdlib containers do on `clear`
pub fn clear(&self) {
*self.hashmap.borrow_mut() = Default::default();
}
}
impl<Key: Eq + Hash, Value: Clone> Cache<Key, Value> {
pub fn get<Tcx: DepContext>(&self, key: &Key, tcx: Tcx) -> Option<Value> {
Some(self.hashmap.borrow().get(key)?.get(tcx))

View file

@ -124,7 +124,7 @@ impl DepNode {
pub fn construct<Tcx, Key>(tcx: Tcx, kind: DepKind, arg: &Key) -> DepNode
where
Tcx: super::DepContext,
Key: DepNodeParams<Tcx>,
Key: DepNodeKey<Tcx>,
{
let hash = arg.to_fingerprint(tcx);
let dep_node = DepNode { kind, hash: hash.into() };
@ -167,16 +167,13 @@ impl fmt::Debug for DepNode {
}
}
pub trait DepNodeParams<Tcx: DepContext>: fmt::Debug + Sized {
/// Trait for query keys as seen by dependency-node tracking.
pub trait DepNodeKey<Tcx: DepContext>: fmt::Debug + Sized {
fn fingerprint_style() -> FingerprintStyle;
/// This method turns the parameters of a DepNodeConstructor into an opaque
/// Fingerprint to be used in DepNode.
/// Not all DepNodeParams support being turned into a Fingerprint (they
/// don't need to if the corresponding DepNode is anonymous).
fn to_fingerprint(&self, _: Tcx) -> Fingerprint {
panic!("Not implemented. Accidentally called on anonymous node?")
}
/// This method turns a query key into an opaque `Fingerprint` to be used
/// in `DepNode`.
fn to_fingerprint(&self, _: Tcx) -> Fingerprint;
fn to_debug_str(&self, tcx: Tcx) -> String;
@ -189,7 +186,8 @@ pub trait DepNodeParams<Tcx: DepContext>: fmt::Debug + Sized {
fn recover(tcx: Tcx, dep_node: &DepNode) -> Option<Self>;
}
impl<Tcx: DepContext, T> DepNodeParams<Tcx> for T
// Blanket impl of `DepNodeKey`, which is specialized by other impls elsewhere.
impl<Tcx: DepContext, T> DepNodeKey<Tcx> for T
where
T: for<'a> HashStable<StableHashingContext<'a>> + fmt::Debug,
{
@ -239,7 +237,7 @@ pub struct DepKindVTable<Tcx: DepContext> {
/// Indicates whether and how the query key can be recovered from its hashed fingerprint.
///
/// The [`DepNodeParams`] trait determines the fingerprint style for each key type.
/// The [`DepNodeKey`] trait determines the fingerprint style for each key type.
pub fingerprint_style: FingerprintStyle,
/// The red/green evaluation system will try to mark a specific DepNode in the

View file

@ -7,7 +7,7 @@ mod serialized;
use std::panic;
pub use dep_node::{DepKind, DepKindVTable, DepNode, DepNodeParams, WorkProductId};
pub use dep_node::{DepKind, DepKindVTable, DepNode, DepNodeKey, WorkProductId};
pub(crate) use graph::DepGraphData;
pub use graph::{DepGraph, DepNodeIndex, TaskDepsRef, WorkProduct, WorkProductMap, hash_result};
pub use query::DepGraphQuery;

View file

@ -1,7 +1,6 @@
use rustc_errors::codes::*;
use rustc_hir::limit::Limit;
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol};
use rustc_span::Span;
#[derive(Subdiagnostic)]
#[note("...which requires {$desc}...")]
@ -75,24 +74,3 @@ pub(crate) struct IncrementCompilation {
pub run_cmd: String,
pub dep_node: String,
}
#[derive(Diagnostic)]
#[help(
"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
)]
#[diag("queries overflow the depth limit!")]
pub struct QueryOverflow {
#[primary_span]
pub span: Span,
#[subdiagnostic]
pub note: QueryOverflowNote,
pub suggested_limit: Limit,
pub crate_name: Symbol,
}
#[derive(Subdiagnostic)]
#[note("query depth increased by {$depth} when {$desc}")]
pub struct QueryOverflowNote {
pub desc: String,
pub depth: usize,
}

View file

@ -11,7 +11,6 @@ pub const IGNORED_ATTRIBUTES: &[Symbol] = &[
sym::cfg_trace, // FIXME should this really be ignored?
sym::rustc_if_this_changed,
sym::rustc_then_this_would_need,
sym::rustc_dirty,
sym::rustc_clean,
sym::rustc_partition_reused,
sym::rustc_partition_codegened,

View file

@ -10,7 +10,3 @@ pub mod dep_graph;
mod error;
pub mod ich;
pub mod query;
mod values;
pub use error::{QueryOverflow, QueryOverflowNote};
pub use values::Value;

View file

@ -5,7 +5,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
use rustc_span::ErrorGuaranteed;
use super::QueryStackFrameExtra;
use crate::dep_graph::{DepKind, DepNode, DepNodeParams, HasDepContext, SerializedDepNodeIndex};
use crate::dep_graph::{DepKind, DepNode, DepNodeKey, HasDepContext, SerializedDepNodeIndex};
use crate::ich::StableHashingContext;
use crate::query::caches::QueryCache;
use crate::query::{CycleError, CycleErrorHandling, DepNodeIndex, QueryContext, QueryState};
@ -33,7 +33,7 @@ pub trait QueryDispatcher<'tcx>: Copy + 'tcx {
// `Key` and `Value` are `Copy` instead of `Clone` to ensure copying them stays cheap,
// but it isn't necessary.
type Key: DepNodeParams<DepContextOf<'tcx, Self>> + Eq + Hash + Copy + Debug;
type Key: DepNodeKey<DepContextOf<'tcx, Self>> + Eq + Hash + Copy + Debug;
type Value: Copy;
type Cache: QueryCache<Key = Self::Key, Value = Self::Value>;

View file

@ -18,7 +18,7 @@ use tracing::instrument;
use super::{QueryDispatcher, QueryStackDeferred, QueryStackFrameExtra};
use crate::dep_graph::{
DepContext, DepGraphData, DepNode, DepNodeIndex, DepNodeParams, HasDepContext,
DepContext, DepGraphData, DepNode, DepNodeIndex, DepNodeKey, HasDepContext,
};
use crate::ich::StableHashingContext;
use crate::query::caches::QueryCache;

View file

@ -1,21 +0,0 @@
use rustc_span::ErrorGuaranteed;
use crate::dep_graph::DepContext;
use crate::query::CycleError;
pub trait Value<Tcx: DepContext>: Sized {
fn from_cycle_error(tcx: Tcx, cycle_error: &CycleError, guar: ErrorGuaranteed) -> Self;
}
impl<Tcx: DepContext, T> Value<Tcx> for T {
default fn from_cycle_error(tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed) -> T {
tcx.sess().dcx().abort_if_errors();
// Ideally we would use `bug!` here. But bug! is only defined in rustc_middle, and it's
// non-trivial to define it earlier.
panic!(
"<{} as Value>::from_cycle_error called without errors: {:#?}",
std::any::type_name::<T>(),
cycle_error.cycle,
);
}
}

View file

@ -16,7 +16,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_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }

View file

@ -1,531 +0,0 @@
resolve_accessible_unsure = not sure whether the path is accessible or not
.note = the type may have associated items, but we are currently not checking them
resolve_add_as_non_derive =
add as non-Derive macro
`#[{$macro_path}]`
resolve_added_macro_use =
have you added the `#[macro_use]` on the module/import?
resolve_ancestor_only =
visibilities can only be restricted to ancestor modules
resolve_anonymous_lifetime_non_gat_report_error = missing lifetime in associated type
.label = this lifetime must come from the implemented type
.note = in the trait the associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
resolve_arguments_macro_use_not_allowed = arguments to `macro_use` are not allowed here
resolve_associated_const_with_similar_name_exists =
there is an associated constant with a similar name
resolve_associated_fn_with_similar_name_exists =
there is an associated function with a similar name
resolve_associated_type_with_similar_name_exists =
there is an associated type with a similar name
resolve_attempt_to_use_non_constant_value_in_constant =
attempt to use a non-constant value in a constant
resolve_attempt_to_use_non_constant_value_in_constant_label_with_suggestion =
non-constant value
resolve_attempt_to_use_non_constant_value_in_constant_with_suggestion =
consider using `{$suggestion}` instead of `{$current}`
resolve_attempt_to_use_non_constant_value_in_constant_without_suggestion =
this would need to be a `{$suggestion}`
resolve_attributes_starting_with_rustc_are_reserved =
attributes starting with `rustc` are reserved for use by the `rustc` compiler
resolve_binding_in_never_pattern =
never patterns cannot contain variable bindings
.suggestion = use a wildcard `_` instead
resolve_binding_shadows_something_unacceptable =
{$shadowing_binding}s cannot shadow {$shadowed_binding}s
.label = cannot be named the same as {$article} {$shadowed_binding}
.label_shadowed_binding = the {$shadowed_binding} `{$name}` is {$participle} here
resolve_binding_shadows_something_unacceptable_suggestion =
try specify the pattern arguments
resolve_cannot_be_reexported_crate_public =
`{$ident}` is only public within the crate, and cannot be re-exported outside
resolve_cannot_be_reexported_private =
`{$ident}` is private, and cannot be re-exported
resolve_cannot_capture_dynamic_environment_in_fn_item =
can't capture dynamic environment in a fn item
.help = use the `|| {"{"} ... {"}"}` closure form instead
resolve_cannot_determine_import_resolution =
cannot determine resolution for the import
.note = import resolution is stuck, try simplifying other imports
resolve_cannot_determine_macro_resolution =
cannot determine resolution for the {$kind} `{$path}`
.note = import resolution is stuck, try simplifying macro imports
resolve_cannot_find_builtin_macro_with_name =
cannot find a built-in macro with name `{$ident}`
resolve_cannot_find_ident_in_this_scope =
cannot find {$expected} `{$ident}` in this scope
resolve_cannot_glob_import_possible_crates =
cannot glob-import all possible crates
resolve_cannot_use_through_an_import =
cannot use {$article} {$descr} through an import
.note = the {$descr} imported here
resolve_change_import_binding =
you can use `as` to change the binding name of the import
resolve_consider_adding_a_derive =
consider adding a derive
resolve_consider_adding_macro_export =
consider adding a `#[macro_export]` to the macro in the imported module
resolve_consider_declaring_with_pub =
consider declaring type or module `{$ident}` with `pub`
resolve_consider_making_the_field_public =
{ $number_of_fields ->
[one] consider making the field publicly accessible
*[other] consider making the fields publicly accessible
}
resolve_consider_marking_as_pub =
consider marking `{$ident}` as `pub` in the imported module
resolve_consider_marking_as_pub_crate =
in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)`
resolve_consider_move_macro_position =
consider moving the definition of `{$ident}` before this call
resolve_const_not_member_of_trait =
const `{$const_}` is not a member of trait `{$trait_}`
.label = not a member of trait `{$trait_}`
resolve_const_param_in_enum_discriminant =
const parameters may not be used in enum discriminant values
resolve_const_param_in_non_trivial_anon_const =
const parameters may only be used as standalone arguments here, i.e. `{$name}`
resolve_constructor_private_if_any_field_private =
a constructor is private if any of the fields is private
resolve_elided_anonymous_lifetime_report_error =
`&` without an explicit lifetime name cannot be used here
.label = explicit lifetime name needed here
resolve_elided_anonymous_lifetime_report_error_suggestion =
consider introducing a higher-ranked lifetime here
resolve_expected_module_found =
expected module, found {$res} `{$path_str}`
.label = not a module
resolve_explicit_anonymous_lifetime_report_error =
`'_` cannot be used here
.label = `'_` is a reserved lifetime name
resolve_explicit_unsafe_traits =
unsafe traits like `{$ident}` should be implemented explicitly
resolve_extern_crate_loading_macro_not_at_crate_root =
an `extern crate` loading macros must be at the crate root
resolve_extern_crate_not_idiomatic = `extern crate` is not idiomatic in the new edition
.suggestion = convert it to a `use`
resolve_extern_crate_self_requires_renaming =
`extern crate self;` requires renaming
.suggestion = rename the `self` crate to be able to import it
resolve_forward_declared_generic_in_const_param_ty =
const parameter types cannot reference parameters before they are declared
.label = const parameter type cannot reference `{$param}` before it is declared
resolve_forward_declared_generic_param =
generic parameter defaults cannot reference parameters before they are declared
.label = cannot reference `{$param}` before it is declared
resolve_found_an_item_configured_out =
found an item that was configured out
resolve_generic_arguments_in_macro_path =
generic arguments in macro path
resolve_generic_params_from_outer_item =
can't use {$is_self ->
[true] `Self`
*[false] generic parameters
} from outer item
.label = use of {$is_self ->
[true] `Self`
*[false] generic parameter
} from outer item
.refer_to_type_directly = refer to the type directly here instead
.suggestion = try introducing a local generic parameter here
.note = nested items are independent from their parent item for everything except for privacy and name resolution
resolve_generic_params_from_outer_item_const = a `const` is a separate item from the item that contains it
resolve_generic_params_from_outer_item_const_param = const parameter from outer item
resolve_generic_params_from_outer_item_inner_item = {$is_self ->
[true] `Self`
*[false] generic parameter
} used in this inner {$descr}
resolve_generic_params_from_outer_item_self_ty_alias = `Self` type implicitly declared here, by this `impl`
resolve_generic_params_from_outer_item_self_ty_param = can't use `Self` here
resolve_generic_params_from_outer_item_static = a `static` is a separate item from the item that contains it
resolve_generic_params_from_outer_item_ty_param = type parameter from outer item
resolve_ident_bound_more_than_once_in_parameter_list =
identifier `{$identifier}` is bound more than once in this parameter list
.label = used as parameter more than once
resolve_ident_bound_more_than_once_in_same_pattern =
identifier `{$identifier}` is bound more than once in the same pattern
.label = used in a pattern more than once
resolve_ident_imported_here_but_it_is_desc =
`{$imported_ident}` is imported here, but it is {$imported_ident_desc}
resolve_ident_in_scope_but_it_is_desc =
`{$imported_ident}` is in scope, but it is {$imported_ident_desc}
resolve_implicit_elided_lifetimes_not_allowed_here = implicit elided lifetime not allowed here
resolve_imported_crate = `$crate` may not be imported
resolve_imported_macro_not_found = imported macro not found
resolve_imports_cannot_refer_to =
imports cannot refer to {$what}
resolve_indeterminate =
cannot determine resolution for the visibility
resolve_invalid_asm_sym =
invalid `sym` operand
.label = is a local variable
.help = `sym` operands must refer to either a function or a static
resolve_is_private =
{$ident_descr} `{$ident}` is private
.label = private {$ident_descr}
resolve_item_was_behind_feature =
the item is gated behind the `{$feature}` feature
resolve_item_was_cfg_out = the item is gated here
resolve_label_with_similar_name_reachable =
a label with a similar name is reachable
resolve_legacy_derive_helpers = derive helper attribute is used before it is introduced
.label = the attribute is introduced here
resolve_lending_iterator_report_error =
associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
.note = you can't create an `Iterator` that borrows each `Item` from itself, but you can instead create a new type that borrows your existing type and implement `Iterator` for that new type
resolve_lifetime_param_in_enum_discriminant =
lifetime parameters may not be used in enum discriminant values
resolve_lifetime_param_in_non_trivial_anon_const =
lifetime parameters may not be used in const expressions
resolve_lowercase_self =
attempt to use a non-constant value in a constant
.suggestion = try using `Self`
resolve_macro_cannot_use_as_attr =
`{$ident}` exists, but has no `attr` rules
resolve_macro_cannot_use_as_derive =
`{$ident}` exists, but has no `derive` rules
resolve_macro_cannot_use_as_fn_like =
`{$ident}` exists, but has no rules for function-like invocation
resolve_macro_defined_later =
a macro with the same name exists, but it appears later
resolve_macro_expanded_extern_crate_cannot_shadow_extern_arguments =
macro-expanded `extern crate` items cannot shadow names passed with `--extern`
resolve_macro_expanded_macro_exports_accessed_by_absolute_paths = macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
.note = the macro is defined here
resolve_macro_expected_found =
expected {$expected}, found {$found} `{$macro_path}`
.label = not {$article} {$expected}
resolve_macro_extern_deprecated =
`#[macro_escape]` is a deprecated synonym for `#[macro_use]`
.help = try an outer attribute: `#[macro_use]`
resolve_macro_is_private = macro `{$ident}` is private
resolve_macro_rule_never_used = rule #{$n} of macro `{$name}` is never used
resolve_macro_use_deprecated =
applying the `#[macro_use]` attribute to an `extern crate` item is deprecated
.help = remove it and import macros at use sites with a `use` item instead
resolve_macro_use_extern_crate_self = `#[macro_use]` is not supported on `extern crate self`
resolve_macro_use_name_already_in_use =
`{$name}` is already in scope
.note = macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)
resolve_method_not_member_of_trait =
method `{$method}` is not a member of trait `{$trait_}`
.label = not a member of trait `{$trait_}`
resolve_missing_macro_rules_name = maybe you have forgotten to define a name for this `macro_rules!`
resolve_module_only =
visibility must resolve to a module
resolve_name_defined_multiple_time =
the name `{$name}` is defined multiple times
.note = `{$name}` must be defined only once in the {$descr} namespace of this {$container}
resolve_name_defined_multiple_time_old_binding_definition =
previous definition of the {$old_kind} `{$name}` here
resolve_name_defined_multiple_time_old_binding_import =
previous import of the {$old_kind} `{$name}` here
resolve_name_defined_multiple_time_redefined =
`{$name}` redefined here
resolve_name_defined_multiple_time_reimported =
`{$name}` reimported here
resolve_name_is_already_used_as_generic_parameter =
the name `{$name}` is already used for a generic parameter in this item's generic parameters
.label = already used
.first_use_of_name = first use of `{$name}`
resolve_name_reserved_in_attribute_namespace =
name `{$ident}` is reserved in attribute namespace
resolve_note_and_refers_to_the_item_defined_here =
{$first ->
[true] {$dots ->
[true] the {$binding_descr} `{$binding_name}` is defined here...
*[false] the {$binding_descr} `{$binding_name}` is defined here
}
*[false] {$dots ->
[true] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here...
*[false] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here
}
}
resolve_out_of_scope_macro_calls = cannot find macro `{$path}` in the current scope when looking from {$location}
.label = not found from {$location}
.help = import `macro_rules` with `use` to make it callable above its definition
resolve_outer_ident_is_not_publicly_reexported =
{$outer_ident_descr} `{$outer_ident}` is not publicly re-exported
resolve_param_in_enum_discriminant =
generic parameters may not be used in enum discriminant values
.label = cannot perform const operation using `{$name}`
resolve_param_in_non_trivial_anon_const =
generic parameters may not be used in const operations
.label = cannot perform const operation using `{$name}`
resolve_param_in_non_trivial_anon_const_help =
add `#![feature(generic_const_exprs)]` to allow generic const expressions
resolve_param_in_ty_of_const_param =
the type of const parameters must not depend on other generic parameters
.label = the type must not depend on the parameter `{$name}`
resolve_pattern_doesnt_bind_name = pattern doesn't bind `{$name}`
resolve_private_extern_crate_reexport = extern crate `{$ident}` is private and cannot be re-exported
.suggestion = consider making the `extern crate` item publicly accessible
resolve_proc_macro_derive_resolution_fallback = cannot find {$ns_descr} `{$ident}` in this scope
.label = names from parent modules are not accessible without an explicit import
resolve_proc_macro_same_crate = can't use a procedural macro from the same crate that defines it
.help = you can define integration tests in a directory named `tests`
resolve_redundant_import_visibility = glob import doesn't reexport anything with visibility `{$import_vis}` because no imported item is public enough
.note = the most public imported item is `{$max_vis}`
.help = reduce the glob import's visibility or increase visibility of imported items
resolve_reexport_of_crate_public =
re-export of crate public `{$ident}`
resolve_reexport_of_private =
re-export of private `{$ident}`
resolve_reexport_private_dependency =
{$kind} `{$name}` from private dependency '{$krate}' is re-exported
resolve_relative_2018 =
relative paths are not supported in visibilities in 2018 edition or later
.suggestion = try
resolve_remove_surrounding_derive =
remove from the surrounding `derive()`
resolve_remove_unnecessary_import = remove unnecessary import
resolve_self_import_can_only_appear_once_in_the_list =
`self` import can only appear once in an import list
.label = can only appear once in an import list
resolve_self_import_only_in_import_list_with_non_empty_prefix =
`self` import can only appear in an import list with a non-empty prefix
.label = can only appear in an import list with a non-empty prefix
resolve_self_imports_only_allowed_within =
`self` imports are only allowed within a {"{"} {"}"} list
resolve_self_imports_only_allowed_within_multipart_suggestion =
alternatively, use the multi-path `use` syntax to import `self`
resolve_self_imports_only_allowed_within_suggestion =
consider importing the module directly
resolve_self_in_const_generic_ty =
cannot use `Self` in const parameter type
resolve_self_in_generic_param_default =
generic parameters cannot use `Self` in their defaults
resolve_similarly_named_defined_here =
similarly named {$candidate_descr} `{$candidate}` defined here
resolve_single_item_defined_here =
{$candidate_descr} `{$candidate}` defined here
resolve_static_lifetime_is_reserved = invalid lifetime parameter name: `{$lifetime}`
.label = 'static is a reserved lifetime name
resolve_suggestion_import_ident_directly =
import `{$ident}` directly
resolve_suggestion_import_ident_through_reexport =
import `{$ident}` through the re-export
resolve_tool_module_imported =
cannot use a tool module through an import
.note = the tool module imported here
resolve_tool_only_accepts_identifiers =
`{$tool}` only accepts identifiers
.label = not an identifier
resolve_tool_was_already_registered =
tool `{$tool}` was already registered
.label = already registered here
resolve_trait_impl_duplicate =
duplicate definitions with name `{$name}`:
.label = duplicate definition
.old_span_label = previous definition here
.trait_item_span = item in trait
resolve_trait_impl_mismatch =
item `{$name}` is an associated {$kind}, which doesn't match its trait `{$trait_path}`
.label = does not match trait
.trait_impl_mismatch_label_item = item in trait
resolve_try_using_similarly_named_label =
try using similarly named label
resolve_type_not_member_of_trait =
type `{$type_}` is not a member of trait `{$trait_}`
.label = not a member of trait `{$trait_}`
resolve_type_param_in_enum_discriminant =
type parameters may not be used in enum discriminant values
resolve_type_param_in_non_trivial_anon_const =
type parameters may not be used in const expressions
resolve_undeclared_label =
use of undeclared label `{$name}`
.label = undeclared label `{$name}`
resolve_underscore_lifetime_is_reserved = `'_` cannot be used here
.label = `'_` is a reserved lifetime name
.help = use another lifetime specifier
resolve_unexpected_res_change_ty_to_const_param_sugg =
you might have meant to write a const parameter here
resolve_unexpected_res_use_at_op_in_slice_pat_with_range_sugg =
if you meant to collect the rest of the slice in `{$ident}`, use the at operator
resolve_unknown_diagnostic_attribute = unknown diagnostic attribute
resolve_unknown_diagnostic_attribute_typo_sugg = an attribute with a similar name exists
resolve_unnamed_crate_root_import =
crate root imports need to be explicitly named: `use crate as name;`
resolve_unreachable_label =
use of unreachable label `{$name}`
.label = unreachable label `{$name}`
.label_definition_span = unreachable label defined here
.note = labels are unreachable through functions, closures, async blocks and modules
resolve_unreachable_label_similar_name_reachable =
a label with a similar name is reachable
resolve_unreachable_label_similar_name_unreachable =
a label with a similar name exists but is also unreachable
resolve_unreachable_label_suggestion_use_similarly_named =
try using similarly named label
resolve_unreachable_label_with_similar_name_exists =
a label with a similar name exists but is unreachable
resolve_unused_extern_crate = unused extern crate
.label = unused
.suggestion = remove the unused `extern crate`
resolve_unused_label = unused label
resolve_unused_macro_definition = unused macro definition: `{$name}`
resolve_unused_macro_use = unused `#[macro_use]` import
resolve_variable_bound_with_different_mode =
variable `{$variable_name}` is bound inconsistently across alternatives separated by `|`
.label = bound in different ways
.first_binding_span = first binding
resolve_variable_is_a_typo = you might have meant to use the similarly named previously used binding `{$typo}`
resolve_variable_is_not_bound_in_all_patterns =
variable `{$name}` is not bound in all patterns
resolve_variable_not_in_all_patterns = variable not in all patterns

File diff suppressed because it is too large Load diff

View file

@ -98,8 +98,6 @@ pub use macros::registered_tools_ast;
use crate::ref_mut::{CmCell, CmRefCell};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
#[derive(Copy, Clone, PartialEq, Debug)]
enum Determinacy {
Determined,

View file

@ -540,7 +540,7 @@ macro_rules! typed_def_id {
}
// N.B.: when adding new typed `DefId`s update the corresponding trait impls in
// `rustc_middle::dep_graph::def_node` for `DepNodeParams`.
// `rustc_middle::dep_graph::dep_node_key` for `DepNodeKey`.
typed_def_id! { ModDefId, LocalModDefId }
impl LocalModDefId {

View file

@ -1956,7 +1956,6 @@ symbols! {
rustc_deprecated_safe_2024,
rustc_diagnostic_item,
rustc_diagnostic_macros,
rustc_dirty,
rustc_do_not_const_check,
rustc_doc_primitive,
rustc_driver,

View file

@ -127,6 +127,7 @@ fn recv_before_send() {
}
#[test]
#[ignore = "Inherently flaky and has caused several CI failures"]
fn recv_timeout_before_send() {
let (sender, receiver) = oneshot::channel();
@ -135,6 +136,8 @@ fn recv_timeout_before_send() {
sender.send(99u128).unwrap();
});
// FIXME(#152145): Under load, there's no guarantee that thread `t` has
// ever been scheduled and run before this timeout expires.
match receiver.recv_timeout(Duration::from_secs(1)) {
Ok(99) => {}
_ => panic!("expected Ok(99)"),

View file

@ -1859,11 +1859,17 @@ impl Config {
.get(&target)
.and_then(|t| t.llvm_libunwind)
.or(self.llvm_libunwind_default)
.unwrap_or(if target.contains("fuchsia") || target.contains("hexagon") {
LlvmLibunwind::InTree
} else {
LlvmLibunwind::No
})
.unwrap_or(
if target.contains("fuchsia")
|| (target.contains("hexagon") && !target.contains("qurt"))
{
// Fuchsia and Hexagon Linux use in-tree llvm-libunwind.
// Hexagon QuRT uses libc_eh from the Hexagon SDK instead.
LlvmLibunwind::InTree
} else {
LlvmLibunwind::No
},
)
}
pub fn split_debuginfo(&self, target: TargetSelection) -> SplitDebuginfo {

View file

@ -71,7 +71,7 @@ extern crate tikv_jemalloc_sys as _;
use std::env::{self, VarError};
use std::io::{self, IsTerminal};
use std::path::Path;
use std::process;
use std::process::ExitCode;
use rustc_errors::DiagCtxtHandle;
use rustc_hir::def_id::LOCAL_CRATE;
@ -126,7 +126,7 @@ mod visit;
mod visit_ast;
mod visit_lib;
pub fn main() {
pub fn main() -> ExitCode {
let mut early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
rustc_driver::install_ice_hook(
@ -164,11 +164,10 @@ pub fn main() {
Err(error) => early_dcx.early_fatal(error.to_string()),
}
let exit_code = rustc_driver::catch_with_exit_code(|| {
rustc_driver::catch_with_exit_code(|| {
let at_args = rustc_driver::args::raw_args(&early_dcx);
main_args(&mut early_dcx, &at_args);
});
process::exit(exit_code);
})
}
fn init_logging(early_dcx: &EarlyDiagCtxt) {

View file

@ -32,7 +32,7 @@ use std::env;
use std::fs::read_to_string;
use std::io::Write as _;
use std::path::Path;
use std::process::exit;
use std::process::ExitCode;
/// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If
/// true, then return it. The parameter is assumed to be either `--arg=value` or `--arg value`.
@ -182,15 +182,17 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
}
}
fn display_help() {
fn display_help() -> ExitCode {
if writeln!(&mut anstream::stdout().lock(), "{}", help_message()).is_err() {
exit(rustc_driver::EXIT_FAILURE);
ExitCode::FAILURE
} else {
ExitCode::SUCCESS
}
}
const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml";
pub fn main() {
pub fn main() -> ExitCode {
let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
rustc_driver::init_rustc_env_logger(&early_dcx);
@ -203,7 +205,7 @@ pub fn main() {
dcx.handle().note(format!("Clippy version: {version_info}"));
});
exit(rustc_driver::catch_with_exit_code(move || {
rustc_driver::catch_with_exit_code(move || {
let mut orig_args = rustc_driver::args::raw_args(&early_dcx);
let has_sysroot_arg = |args: &mut [String]| -> bool {
@ -246,15 +248,15 @@ pub fn main() {
pass_sysroot_env_if_given(&mut args, sys_root_env);
rustc_driver::run_compiler(&args, &mut DefaultCallbacks);
return;
return ExitCode::SUCCESS;
}
if orig_args.iter().any(|a| a == "--version" || a == "-V") {
let version_info = rustc_tools_util::get_version_info!();
match writeln!(&mut anstream::stdout().lock(), "{version_info}") {
Ok(()) => exit(rustc_driver::EXIT_SUCCESS),
Err(_) => exit(rustc_driver::EXIT_FAILURE),
return match writeln!(&mut anstream::stdout().lock(), "{version_info}") {
Ok(()) => ExitCode::SUCCESS,
Err(_) => ExitCode::FAILURE,
}
}
@ -268,8 +270,7 @@ pub fn main() {
}
if !wrapper_mode && (orig_args.iter().any(|a| a == "--help" || a == "-h") || orig_args.len() == 1) {
display_help();
exit(0);
return display_help();
}
let mut args: Vec<String> = orig_args.clone();
@ -311,7 +312,8 @@ pub fn main() {
} else {
rustc_driver::run_compiler(&args, &mut RustcCallbacks { clippy_args_var });
}
}))
ExitCode::SUCCESS
})
}
#[must_use]

View file

@ -21,7 +21,7 @@ impl TestCx<'_> {
// - execute build/foo/bar.exe and save output
//
// FIXME -- use non-incremental mode as an oracle? That doesn't apply
// to #[rustc_dirty] and clean tests I guess
// to #[rustc_clean] tests I guess
let revision = self.revision.expect("incremental tests require a list of revisions");

View file

@ -39,6 +39,7 @@ mod log;
use std::env;
use std::num::{NonZero, NonZeroI32};
use std::ops::Range;
use std::process::ExitCode;
use std::rc::Rc;
use std::str::FromStr;
use std::sync::Once;
@ -404,7 +405,11 @@ fn run_compiler_and_exit(
// Invoke compiler, catch any unwinding panics and handle return code.
let exit_code =
rustc_driver::catch_with_exit_code(move || rustc_driver::run_compiler(args, callbacks));
exit(exit_code)
exit(if exit_code == ExitCode::SUCCESS {
rustc_driver::EXIT_SUCCESS
} else {
rustc_driver::EXIT_FAILURE
})
}
/// Parses a comma separated list of `T` from the given string:
@ -434,7 +439,7 @@ fn parse_range(val: &str) -> Result<Range<u32>, &'static str> {
Ok(from..to)
}
fn main() {
fn main() -> ExitCode {
let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
// Snapshot a copy of the environment before `rustc` starts messing with it.
@ -449,9 +454,7 @@ fn main() {
if crate_kind == "host" {
// For host crates like proc macros and build scripts, we are an entirely normal rustc.
// These eventually produce actual binaries and never run in Miri.
match rustc_driver::main() {
// Empty match proves this function will never return.
}
return rustc_driver::main();
} else if crate_kind != "target" {
panic!("invalid `MIRI_BE_RUSTC` value: {crate_kind:?}")
};

View file

@ -1,6 +1,8 @@
// We need this feature as it changes `dylib` linking behavior and allows us to link to `rustc_driver`.
#![feature(rustc_private)]
fn main() {
use std::process::ExitCode;
fn main() -> ExitCode {
rustdoc::main()
}

View file

@ -55,9 +55,7 @@ pub fn _kernel_1(x: &mut [f32; 256]) {
// CHECK-NEXT: %.offload_ptrs = alloca [1 x ptr], align 8
// CHECK-NEXT: %.offload_sizes = alloca [1 x i64], align 8
// CHECK-NEXT: %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8
// CHECK: %dummy = load volatile ptr, ptr @.offload_sizes.[[K]], align 8
// CHECK-NEXT: %dummy1 = load volatile ptr, ptr @.offloading.entry.[[K]], align 8
// CHECK-NEXT: call void @__tgt_init_all_rtls()
// CHECK: call void @__tgt_init_all_rtls()
// CHECK-NEXT: store ptr %x, ptr %.offload_baseptrs, align 8
// CHECK-NEXT: store ptr %x, ptr %.offload_ptrs, align 8
// CHECK-NEXT: store i64 1024, ptr %.offload_sizes, align 8

View file

@ -2,7 +2,7 @@
// `f == FrameType::Inter || f == FrameType::Switch`.
//@ compile-flags: -Copt-level=3
//@ min-llvm-version: 21
//@ min-llvm-version: 23
#![crate_type = "lib"]
@ -18,8 +18,7 @@ pub enum FrameType {
#[no_mangle]
pub fn is_inter_or_switch(f: FrameType) -> bool {
// CHECK-NEXT: start:
// CHECK-NEXT: and i8
// CHECK-NEXT: icmp
// CHECK-NEXT: trunc i8 %{{.*}} to i1
// CHECK-NEXT: ret
matches!(f, FrameType::Inter | FrameType::Switch)
}

View file

@ -1,20 +0,0 @@
// Make sure search stores its data in `window`
// It needs to use a global to avoid racing on search-index.js and search.js
// https://github.com/rust-lang/rust/pull/118961
include: "utils.goml"
// URL query
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa"
wait-for: "#search-tabs"
wait-for-window-property-false: {"searchIndex": null}
// Form input
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
call-function: ("perform-search", {"query": "Foo"})
wait-for-window-property-false: {"searchIndex": null}
// source sidebar
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
click: "#sidebar-button"
wait-for: "#src-sidebar details"
assert-window-property: {"searchIndex": null}

View file

@ -28,6 +28,7 @@ extern crate rustc_session;
use std::cell::RefCell;
use std::collections::HashMap;
use std::process::ExitCode;
use std::thread_local;
use rustc_borrowck::consumers::{self, BodyWithBorrowckFacts, ConsumerOptions};
@ -42,16 +43,15 @@ use rustc_middle::ty::TyCtxt;
use rustc_middle::util::Providers;
use rustc_session::Session;
fn main() {
let exit_code = rustc_driver::catch_with_exit_code(move || {
fn main() -> ExitCode {
rustc_driver::catch_with_exit_code(move || {
let mut rustc_args: Vec<_> = std::env::args().collect();
// We must pass -Zpolonius so that the borrowck information is computed.
rustc_args.push("-Zpolonius".to_owned());
let mut callbacks = CompilerCalls::default();
// Call the Rust compiler with our callbacks.
rustc_driver::run_compiler(&rustc_args, &mut callbacks);
});
std::process::exit(exit_code);
})
}
#[derive(Default)]

View file

@ -1,8 +1,8 @@
error: OK
--> $DIR/dep-graph-assoc-type-codegen.rs:29:5
--> $DIR/dep-graph-assoc-type-codegen.rs:29:34
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: aborting due to 1 previous error

View file

@ -1,14 +1,14 @@
error: OK
--> $DIR/dep-graph-caller-callee.rs:21:5
--> $DIR/dep-graph-caller-callee.rs:21:34
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: no path from `x` to `typeck`
--> $DIR/dep-graph-caller-callee.rs:32:5
--> $DIR/dep-graph-caller-callee.rs:32:34
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: aborting due to 2 previous errors

View file

@ -5,15 +5,15 @@
#![allow(dead_code)]
#![allow(unused_variables)]
#[rustc_clean(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph
#[rustc_clean(cfg = "foo")] //~ ERROR attribute requires -Z query-dep-graph
fn main() {}
#[rustc_if_this_changed(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph
#[rustc_if_this_changed] //~ ERROR attribute requires -Z query-dep-graph
struct Foo<T> {
f: T,
}
#[rustc_clean(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph
#[rustc_clean(cfg = "foo")] //~ ERROR attribute requires -Z query-dep-graph
type TypeAlias<T> = Foo<T>;
#[rustc_then_this_would_need(variances_of)] //~ ERROR attribute requires -Z query-dep-graph

View file

@ -1,20 +1,20 @@
error: attribute requires -Z query-dep-graph to be enabled
--> $DIR/dep-graph-check-attr.rs:8:1
|
LL | #[rustc_clean(hir_owner)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[rustc_clean(cfg = "foo")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: attribute requires -Z query-dep-graph to be enabled
--> $DIR/dep-graph-check-attr.rs:11:1
|
LL | #[rustc_if_this_changed(hir_owner)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[rustc_if_this_changed]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: attribute requires -Z query-dep-graph to be enabled
--> $DIR/dep-graph-check-attr.rs:16:1
|
LL | #[rustc_clean(hir_owner)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[rustc_clean(cfg = "foo")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: attribute requires -Z query-dep-graph to be enabled
--> $DIR/dep-graph-check-attr.rs:19:1

View file

@ -1,134 +1,134 @@
error: no path from `WillChange` to `type_of`
--> $DIR/dep-graph-struct-signature.rs:28:5
--> $DIR/dep-graph-struct-signature.rs:28:34
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error: no path from `WillChange` to `associated_item`
--> $DIR/dep-graph-struct-signature.rs:29:5
--> $DIR/dep-graph-struct-signature.rs:29:34
|
LL | #[rustc_then_this_would_need(associated_item)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^
error: no path from `WillChange` to `trait_def`
--> $DIR/dep-graph-struct-signature.rs:30:5
--> $DIR/dep-graph-struct-signature.rs:30:34
|
LL | #[rustc_then_this_would_need(trait_def)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:36:5
--> $DIR/dep-graph-struct-signature.rs:36:34
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:37:5
--> $DIR/dep-graph-struct-signature.rs:37:34
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:40:5
--> $DIR/dep-graph-struct-signature.rs:40:34
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:41:5
--> $DIR/dep-graph-struct-signature.rs:41:34
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:46:5
--> $DIR/dep-graph-struct-signature.rs:46:34
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:53:5
--> $DIR/dep-graph-struct-signature.rs:53:34
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:61:9
--> $DIR/dep-graph-struct-signature.rs:61:38
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:63:9
--> $DIR/dep-graph-struct-signature.rs:63:38
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error: no path from `WillChange` to `type_of`
--> $DIR/dep-graph-struct-signature.rs:68:5
--> $DIR/dep-graph-struct-signature.rs:68:34
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error: no path from `WillChange` to `type_of`
--> $DIR/dep-graph-struct-signature.rs:75:5
--> $DIR/dep-graph-struct-signature.rs:75:34
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
error: no path from `WillChange` to `fn_sig`
--> $DIR/dep-graph-struct-signature.rs:81:5
--> $DIR/dep-graph-struct-signature.rs:81:34
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: no path from `WillChange` to `fn_sig`
--> $DIR/dep-graph-struct-signature.rs:84:5
--> $DIR/dep-graph-struct-signature.rs:84:34
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: no path from `WillChange` to `typeck`
--> $DIR/dep-graph-struct-signature.rs:85:5
--> $DIR/dep-graph-struct-signature.rs:85:34
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:32:9
--> $DIR/dep-graph-struct-signature.rs:32:38
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: no path from `WillChange` to `fn_sig`
--> $DIR/dep-graph-struct-signature.rs:77:9
--> $DIR/dep-graph-struct-signature.rs:77:38
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:48:9
--> $DIR/dep-graph-struct-signature.rs:48:38
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:49:9
--> $DIR/dep-graph-struct-signature.rs:49:38
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:55:9
--> $DIR/dep-graph-struct-signature.rs:55:38
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:56:9
--> $DIR/dep-graph-struct-signature.rs:56:38
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
error: aborting due to 22 previous errors

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