Auto merge of #152163 - JonathanBrouwer:rollup-Ypg7w4H, r=JonathanBrouwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#150831 (c-variadic: make `va_arg` match on `Arch` exhaustive)
 - rust-lang/rust#152113 (Fix GitHub CI summary in CodeBuild)
 - rust-lang/rust#152153 (Incorporate query description functions into `QueryVTable`)
 - 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#152119 (Convert to inline diagnostics in `rustc_middle`)
 - rust-lang/rust#152121 (Convert to inline diagnostics in `rustc_builtin_macros`)
 - rust-lang/rust#152133 (library/std: Rename `ON_BROKEN_PIPE_FLAG_USED` to `ON_BROKEN_PIPE_USED`)

Failed merges:

 - rust-lang/rust#152107 (Convert to inline diagnostics in `rustc_borrowck`)
 - rust-lang/rust#152117 (Convert to inline diagnostics in `rustc_trait_selection`)
 - 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 12:10:17 +00:00
commit 66daca1a85
37 changed files with 940 additions and 1500 deletions

View file

@ -3514,7 +3514,6 @@ dependencies = [
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_feature", "rustc_feature",
"rustc_fluent_macro",
"rustc_macros", "rustc_macros",
"rustc_session", "rustc_session",
"rustc_span", "rustc_span",
@ -3600,7 +3599,6 @@ dependencies = [
"rustc_errors", "rustc_errors",
"rustc_expand", "rustc_expand",
"rustc_feature", "rustc_feature",
"rustc_fluent_macro",
"rustc_hir", "rustc_hir",
"rustc_index", "rustc_index",
"rustc_lexer", "rustc_lexer",
@ -3772,10 +3770,8 @@ dependencies = [
"libc", "libc",
"rustc_abi", "rustc_abi",
"rustc_ast", "rustc_ast",
"rustc_ast_passes",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_borrowck", "rustc_borrowck",
"rustc_builtin_macros",
"rustc_codegen_ssa", "rustc_codegen_ssa",
"rustc_const_eval", "rustc_const_eval",
"rustc_data_structures", "rustc_data_structures",
@ -3796,7 +3792,6 @@ dependencies = [
"rustc_mir_transform", "rustc_mir_transform",
"rustc_parse", "rustc_parse",
"rustc_passes", "rustc_passes",
"rustc_pattern_analysis",
"rustc_public", "rustc_public",
"rustc_resolve", "rustc_resolve",
"rustc_session", "rustc_session",
@ -3846,7 +3841,6 @@ dependencies = [
"rustc_data_structures", "rustc_data_structures",
"rustc_error_codes", "rustc_error_codes",
"rustc_error_messages", "rustc_error_messages",
"rustc_fluent_macro",
"rustc_hashes", "rustc_hashes",
"rustc_index", "rustc_index",
"rustc_lint_defs", "rustc_lint_defs",
@ -4262,7 +4256,6 @@ dependencies = [
"rustc_error_messages", "rustc_error_messages",
"rustc_errors", "rustc_errors",
"rustc_feature", "rustc_feature",
"rustc_fluent_macro",
"rustc_graphviz", "rustc_graphviz",
"rustc_hashes", "rustc_hashes",
"rustc_hir", "rustc_hir",
@ -4451,7 +4444,6 @@ dependencies = [
"rustc_arena", "rustc_arena",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_fluent_macro",
"rustc_hir", "rustc_hir",
"rustc_index", "rustc_index",
"rustc_macros", "rustc_macros",

View file

@ -13,7 +13,6 @@ rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_macros = { path = "../rustc_macros" } rustc_macros = { path = "../rustc_macros" }
rustc_session = { path = "../rustc_session" } rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" } rustc_span = { path = "../rustc_span" }

View file

@ -1,342 +0,0 @@
ast_passes_abi_cannot_be_coroutine =
functions with the {$abi} ABI cannot be `{$coroutine_kind_str}`
.suggestion = remove the `{$coroutine_kind_str}` keyword from this definition
ast_passes_abi_custom_safe_foreign_function =
foreign functions with the "custom" ABI cannot be safe
.suggestion = remove the `safe` keyword from this definition
ast_passes_abi_custom_safe_function =
functions with the "custom" ABI must be unsafe
.suggestion = add the `unsafe` keyword to this definition
ast_passes_abi_must_not_have_parameters_or_return_type=
invalid signature for `extern {$abi}` function
.note = functions with the {$abi} ABI cannot have any parameters or return type
.suggestion = remove the parameters and return type
ast_passes_abi_must_not_have_return_type=
invalid signature for `extern {$abi}` function
.note = functions with the {$abi} ABI cannot have a return type
.help = remove the return type
ast_passes_abi_x86_interrupt =
invalid signature for `extern "x86-interrupt"` function
.note = functions with the "x86-interrupt" ABI must be have either 1 or 2 parameters (but found {$param_count})
ast_passes_assoc_const_without_body =
associated constant in `impl` without body
.suggestion = provide a definition for the constant
ast_passes_assoc_fn_without_body =
associated function in `impl` without body
.suggestion = provide a definition for the function
ast_passes_assoc_type_without_body =
associated type in `impl` without body
.suggestion = provide a definition for the type
ast_passes_async_fn_in_const_trait_or_trait_impl =
async functions are not allowed in `const` {$context ->
[trait_impl] trait impls
[impl] impls
*[trait] traits
}
.label = associated functions of `const` cannot be declared `async`
ast_passes_at_least_one_trait = at least one trait must be specified
ast_passes_auto_generic = auto traits cannot have generic parameters
.label = auto trait cannot have generic parameters
.suggestion = remove the parameters
ast_passes_auto_items = auto traits cannot have associated items
.label = {ast_passes_auto_items}
.suggestion = remove the associated items
ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetime bounds
.label = {ast_passes_auto_super_lifetime}
.suggestion = remove the super traits or lifetime bounds
ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block
.cannot_have = cannot have a body
.invalid = the invalid body
.existing = `extern` blocks define existing foreign {$kind}s and {$kind}s inside of them cannot have a body
ast_passes_bound_in_context = bounds on `type`s in {$ctx} have no effect
ast_passes_c_variadic_bad_extern = `...` is not supported for `extern "{$abi}"` functions
.label = `extern "{$abi}"` because of this
.help = only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
ast_passes_c_variadic_bad_naked_extern = `...` is not supported for `extern "{$abi}"` naked functions
.label = `extern "{$abi}"` because of this
.help = C-variadic function must have a compatible calling convention
ast_passes_c_variadic_must_be_unsafe =
functions with a C variable argument list must be unsafe
.suggestion = add the `unsafe` keyword to this definition
ast_passes_c_variadic_no_extern = `...` is not supported for non-extern functions
.help = only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
ast_passes_c_variadic_not_supported = the `{$target}` target does not support c-variadic functions
ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic
.const = `const` because of this
.variadic = C-variadic because of this
ast_passes_const_and_coroutine = functions cannot be both `const` and `{$coroutine_kind}`
.const = `const` because of this
.coroutine = `{$coroutine_kind}` because of this
.label = {""}
ast_passes_const_auto_trait = auto traits cannot be const
.help = remove the `const` keyword
ast_passes_const_bound_trait_object = const trait bounds are not allowed in trait object types
ast_passes_const_without_body =
free constant item without body
.suggestion = provide a definition for the constant
ast_passes_constraint_on_negative_bound =
associated type constraints not allowed on negative bounds
ast_passes_coroutine_and_c_variadic = functions cannot be both `{$coroutine_kind}` and C-variadic
.const = `{$coroutine_kind}` because of this
.variadic = C-variadic because of this
ast_passes_equality_in_where = equality constraints are not yet supported in `where` clauses
.label = not supported
.suggestion = if `{$ident}` is an associated type you're trying to set, use the associated type binding syntax
.suggestion_path = if `{$trait_segment}::{$potential_assoc}` is an associated type you're trying to set, use the associated type binding syntax
.note = see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information
ast_passes_extern_block_suggestion = if you meant to declare an externally defined function, use an `extern` block
ast_passes_extern_fn_qualifiers = functions in `extern` blocks cannot have `{$kw}` qualifier
.label = in this `extern` block
.suggestion = remove the `{$kw}` qualifier
ast_passes_extern_invalid_safety = items in `extern` blocks without an `unsafe` qualifier cannot have safety qualifiers
.suggestion = add `unsafe` to this `extern` block
ast_passes_extern_item_ascii = items in `extern` blocks cannot use non-ascii identifiers
.label = in this `extern` block
.note = this limitation may be lifted in the future; see issue #83942 <https://github.com/rust-lang/rust/issues/83942> for more information
ast_passes_extern_keyword_link = for more information, visit https://doc.rust-lang.org/std/keyword.extern.html
ast_passes_extern_types_cannot = `type`s inside `extern` blocks cannot have {$descr}
.suggestion = remove the {$remove_descr}
.label = `extern` block begins here
ast_passes_extern_without_abi = `extern` declarations without an explicit ABI are disallowed
.suggestion = specify an ABI
.help = prior to Rust 2024, a default ABI was inferred
ast_passes_extern_without_abi_sugg = `extern` declarations without an explicit ABI are deprecated
.label = ABI should be specified here
.suggestion = explicitly specify the {$default_abi} ABI
ast_passes_feature_on_non_nightly = `#![feature]` may not be used on the {$channel} release channel
.suggestion = remove the attribute
.stable_since = the feature `{$name}` has been stable since `{$since}` and no longer requires an attribute to enable
ast_passes_fieldless_union = unions cannot have zero fields
ast_passes_fn_body_extern = incorrect function inside `extern` block
.cannot_have = cannot have a body
.suggestion = remove the invalid body
.help = you might have meant to write a function accessible through FFI, which can be done by writing `extern fn` outside of the `extern` block
.label = `extern` blocks define existing foreign functions and functions inside of them cannot have a body
ast_passes_fn_param_c_var_args_not_last =
`...` must be the last argument of a C-variadic function
ast_passes_fn_param_doc_comment =
documentation comments cannot be applied to function parameters
.label = doc comments are not allowed here
ast_passes_fn_param_forbidden_attr =
allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
ast_passes_fn_param_forbidden_self =
`self` parameter is only allowed in associated functions
.label = not semantically valid as function parameter
.note = associated functions are those in `impl` or `trait` definitions
ast_passes_fn_param_too_many =
function can not have more than {$max_num_args} arguments
ast_passes_fn_ptr_invalid_safety = function pointers cannot be declared with `safe` safety qualifier
.suggestion = remove safe from this item
ast_passes_fn_without_body =
free function without a body
.suggestion = provide a definition for the function
ast_passes_forbidden_bound =
bounds cannot be used in this context
ast_passes_forbidden_const_param =
late-bound const parameters cannot be used currently
ast_passes_forbidden_default =
`default` is only allowed on items in trait impls
.label = `default` because of this
ast_passes_forbidden_non_lifetime_param =
only lifetime parameters can be used in this context
ast_passes_generic_before_constraints = generic arguments must come before the first constraint
.constraints = {$constraint_len ->
[one] constraint
*[other] constraints
}
.args = generic {$args_len ->
[one] argument
*[other] arguments
}
.empty_string = {""},
.suggestion = move the {$constraint_len ->
[one] constraint
*[other] constraints
} after the generic {$args_len ->
[one] argument
*[other] arguments
}
ast_passes_generic_default_trailing = generic parameters with a default must be trailing
ast_passes_impl_fn_const =
redundant `const` fn marker in const impl
.parent_constness = this declares all associated functions implicitly const
.label = remove the `const`
ast_passes_incompatible_features = `{$f1}` and `{$f2}` are incompatible, using them at the same time is not allowed
.help = remove one of these features
ast_passes_item_invalid_safety = items outside of `unsafe extern {"{ }"}` cannot be declared with `safe` safety qualifier
.suggestion = remove safe from this item
ast_passes_item_underscore = `{$kind}` items in this context need a name
.label = `_` is not a valid name for this `{$kind}` item
ast_passes_match_arm_with_no_body =
`match` arm with no body
.suggestion = add a body after the pattern
ast_passes_missing_unsafe_on_extern = extern blocks must be unsafe
.suggestion = needs `unsafe` before the extern keyword
ast_passes_missing_unsafe_on_extern_lint = extern blocks should be unsafe
.suggestion = needs `unsafe` before the extern keyword
ast_passes_module_nonascii = trying to load file for module `{$name}` with non-ascii identifier name
.help = consider using the `#[path]` attribute to specify filesystem path
ast_passes_negative_bound_not_supported =
negative bounds are not supported
ast_passes_negative_bound_with_parenthetical_notation =
parenthetical notation may not be used for negative bounds
ast_passes_nested_impl_trait = nested `impl Trait` is not allowed
.outer = outer `impl Trait`
.inner = nested `impl Trait` here
ast_passes_nested_lifetimes = nested quantification of lifetimes
ast_passes_nomangle_ascii = `#[no_mangle]` requires ASCII identifier
ast_passes_obsolete_auto = `impl Trait for .. {"{}"}` is an obsolete syntax
.help = use `auto trait Trait {"{}"}` instead
ast_passes_out_of_order_params = {$param_ord} parameters must be declared prior to {$max_param} parameters
.suggestion = reorder the parameters: lifetimes, then consts and types
ast_passes_pattern_in_bodiless = patterns aren't allowed in functions without bodies
.label = pattern not allowed in function without body
ast_passes_pattern_in_fn_pointer = patterns aren't allowed in function pointer types
ast_passes_pattern_in_foreign = patterns aren't allowed in foreign function declarations
.label = pattern not allowed in foreign function
ast_passes_precise_capturing_duplicated = duplicate `use<...>` precise capturing syntax
.label = second `use<...>` here
ast_passes_precise_capturing_not_allowed_here = `use<...>` precise capturing syntax not allowed in {$loc}
ast_passes_scalable_vector_not_tuple_struct = scalable vectors must be tuple structs
ast_passes_static_without_body =
free static item without body
.suggestion = provide a definition for the static
ast_passes_tilde_const_disallowed = `[const]` is not allowed here
.closure = closures cannot have `[const]` trait bounds
.function = this function is not `const`, so it cannot have `[const]` trait bounds
.trait = this trait is not `const`, so it cannot have `[const]` trait bounds
.trait_impl = this impl is not `const`, so it cannot have `[const]` trait bounds
.impl = inherent impls cannot have `[const]` trait bounds
.trait_assoc_ty = associated types in non-`const` traits cannot have `[const]` trait bounds
.trait_impl_assoc_ty = associated types in non-const impls cannot have `[const]` trait bounds
.inherent_assoc_ty = inherent associated types cannot have `[const]` trait bounds
.struct = structs cannot have `[const]` trait bounds
.enum = enums cannot have `[const]` trait bounds
.union = unions cannot have `[const]` trait bounds
.anon_const = anonymous constants cannot have `[const]` trait bounds
.object = trait objects cannot have `[const]` trait bounds
.item = this item cannot have `[const]` trait bounds
ast_passes_trait_fn_const =
functions in {$in_impl ->
[true] trait impls
*[false] traits
} cannot be declared const
.label = functions in {$in_impl ->
[true] trait impls
*[false] traits
} cannot be const
.const_context_label = this declares all associated functions implicitly const
.remove_const_sugg = remove the `const`{$requires_multiple_changes ->
[true] {" ..."}
*[false] {""}
}
.make_impl_const_sugg = ... and declare the impl to be const instead
.make_trait_const_sugg = ... and declare the trait to be const instead
ast_passes_trait_object_single_bound = only a single explicit lifetime bound is permitted
ast_passes_ty_alias_without_body =
free type alias without body
.suggestion = provide a definition for the type
ast_passes_unsafe_item = {$kind} cannot be declared unsafe
ast_passes_unsafe_negative_impl = negative impls cannot be unsafe
.negative = negative because of this
.unsafe = unsafe because of this
ast_passes_unsafe_static =
static items cannot be declared with `unsafe` safety qualifier outside of `extern` block
ast_passes_visibility_not_permitted =
visibility qualifiers are not permitted here
.enum_variant = enum variants and their fields always share the visibility of the enum they are in
.trait_impl = trait items always share the visibility of their trait
.individual_impl_items = place qualifiers on individual impl items instead
.individual_foreign_items = place qualifiers on individual foreign items instead
.remove_qualifier_sugg = remove the qualifier
ast_passes_where_clause_after_type_alias = where clauses are not allowed after the type for type aliases
.note = see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
.help = add `#![feature(lazy_type_alias)]` to the crate attributes to enable
ast_passes_where_clause_before_type_alias = where clauses are not allowed before the type for type aliases
.note = see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
.remove_suggestion = remove this `where`
.move_suggestion = move it to the end of the type declaration

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor}; use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
use rustc_ast::{self as ast, AttrVec, NodeId, PatKind, attr, token}; use rustc_ast::{self as ast, AttrVec, NodeId, PatKind, attr, token};
use rustc_errors::inline_fluent;
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features}; use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features};
use rustc_session::Session; use rustc_session::Session;
use rustc_session::parse::{feature_err, feature_warn}; use rustc_session::parse::{feature_err, feature_warn};
@ -124,7 +125,7 @@ impl<'a> PostExpansionVisitor<'a> {
&self, &self,
non_lifetime_binders, non_lifetime_binders,
non_lt_param_spans, non_lt_param_spans,
crate::fluent_generated::ast_passes_forbidden_non_lifetime_param inline_fluent!("only lifetime parameters can be used in this context")
); );
// FIXME(non_lifetime_binders): Const bound params are pretty broken. // FIXME(non_lifetime_binders): Const bound params are pretty broken.

View file

@ -11,5 +11,3 @@
pub mod ast_validation; pub mod ast_validation;
mod errors; mod errors;
pub mod feature_gate; pub mod feature_gate;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -15,7 +15,6 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" } rustc_expand = { path = "../rustc_expand" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_lexer = { path = "../rustc_lexer" } rustc_lexer = { path = "../rustc_lexer" }

View file

@ -1,320 +0,0 @@
builtin_macros_alloc_error_must_be_fn = alloc_error_handler must be a function
builtin_macros_alloc_must_statics = allocators must be statics
builtin_macros_asm_attribute_not_supported =
this attribute is not supported on assembly
builtin_macros_asm_clobber_abi = clobber_abi
builtin_macros_asm_clobber_no_reg = asm with `clobber_abi` must specify explicit registers for outputs
builtin_macros_asm_clobber_outputs = generic outputs
builtin_macros_asm_duplicate_arg = duplicate argument named `{$name}`
.label = previously here
.arg = duplicate argument
builtin_macros_asm_explicit_register_name = explicit register arguments cannot have names
builtin_macros_asm_mayunwind = asm labels are not allowed with the `may_unwind` option
builtin_macros_asm_modifier_invalid = asm template modifier must be a single character
builtin_macros_asm_mutually_exclusive = the `{$opt1}` and `{$opt2}` options are mutually exclusive
builtin_macros_asm_no_matched_argument_name = there is no argument named `{$name}`
builtin_macros_asm_noreturn = asm outputs are not allowed with the `noreturn` option
builtin_macros_asm_opt_already_provided = the `{$symbol}` option was already provided
.label = this option was already provided
.suggestion = remove this option
builtin_macros_asm_pos_after = positional arguments cannot follow named arguments or explicit register arguments
.pos = positional argument
.named = named argument
.explicit = explicit register argument
builtin_macros_asm_pure_combine = the `pure` option must be combined with either `nomem` or `readonly`
builtin_macros_asm_pure_no_output = asm with the `pure` option must have at least one output
builtin_macros_asm_unsupported_clobber_abi = `clobber_abi` cannot be used with `{$macro_name}!`
builtin_macros_asm_unsupported_option = the `{$symbol}` option cannot be used with `{$macro_name}!`
.label = the `{$symbol}` option is not meaningful for global-scoped inline assembly
.suggestion = remove this option
builtin_macros_assert_missing_comma = unexpected string literal
.suggestion = try adding a comma
builtin_macros_assert_requires_boolean = macro requires a boolean expression as an argument
.label = boolean expression required
builtin_macros_assert_requires_expression = macro requires an expression as an argument
.suggestion = try removing semicolon
builtin_macros_autodiff = autodiff must be applied to function
builtin_macros_autodiff_missing_config = autodiff requires at least a name and mode
builtin_macros_autodiff_mode_activity = {$act} can not be used in {$mode} Mode
builtin_macros_autodiff_number_activities = expected {$expected} activities, but found {$found}
builtin_macros_autodiff_ret_activity = invalid return activity {$act} in {$mode} Mode
builtin_macros_autodiff_ty_activity = {$act} can not be used for this type
builtin_macros_autodiff_unknown_activity = did not recognize Activity: `{$act}`
builtin_macros_autodiff_width = autodiff width must fit u32, but is {$width}
builtin_macros_avoid_att_syntax = avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
builtin_macros_avoid_intel_syntax = avoid using `.intel_syntax`, Intel syntax is the default
builtin_macros_bad_derive_target = `derive` may only be applied to `struct`s, `enum`s and `union`s
.label = not applicable here
.label2 = not a `struct`, `enum` or `union`
builtin_macros_bench_sig = functions used as benches must have signature `fn(&mut Bencher) -> impl Termination`
builtin_macros_cannot_derive_union = this trait cannot be derived for unions
builtin_macros_cfg_accessible_has_args = `cfg_accessible` path cannot accept arguments
builtin_macros_cfg_accessible_indeterminate = cannot determine whether the path is accessible or not
builtin_macros_cfg_accessible_literal_path = `cfg_accessible` path cannot be a literal
builtin_macros_cfg_accessible_multiple_paths = multiple `cfg_accessible` paths are specified
builtin_macros_cfg_accessible_unspecified_path = `cfg_accessible` path is not specified
builtin_macros_cfg_select_no_matches = none of the predicates in this `cfg_select` evaluated to true
builtin_macros_cfg_select_unreachable = unreachable predicate
.label = always matches
.label2 = this predicate is never reached
builtin_macros_coerce_pointee_requires_maybe_sized = `derive(CoercePointee)` requires `{$name}` to be marked `?Sized`
builtin_macros_coerce_pointee_requires_one_field = `CoercePointee` can only be derived on `struct`s with at least one field
builtin_macros_coerce_pointee_requires_one_generic = `CoercePointee` can only be derived on `struct`s that are generic over at least one type
builtin_macros_coerce_pointee_requires_one_pointee = exactly one generic type parameter must be marked as `#[pointee]` to derive `CoercePointee` traits
builtin_macros_coerce_pointee_requires_transparent = `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
builtin_macros_coerce_pointee_too_many_pointees = only one type parameter can be marked as `#[pointee]` when deriving `CoercePointee` traits
.label = here another type parameter is marked as `#[pointee]`
builtin_macros_concat_bytes_array = cannot concatenate doubly nested array
.note = byte strings are treated as arrays of bytes
.help = try flattening the array
builtin_macros_concat_bytes_bad_repeat = repeat count is not a positive number
builtin_macros_concat_bytes_invalid = cannot concatenate {$lit_kind} literals
.byte_char = try using a byte character
.byte_str = try using a byte string
.c_str = try using a null-terminated byte string
.c_str_note = concatenating C strings is ambiguous about including the '\0'
.number_array = try wrapping the number in an array
builtin_macros_concat_bytes_missing_literal = expected a byte literal
.note = only byte literals (like `b"foo"`, `b's'` and `[3, 4, 5]`) can be passed to `concat_bytes!()`
builtin_macros_concat_bytes_non_u8 = numeric literal is not a `u8`
builtin_macros_concat_bytes_oob = numeric literal is out of bounds
builtin_macros_concat_bytestr = cannot concatenate a byte string literal
builtin_macros_concat_c_str_lit = cannot concatenate a C string literal
builtin_macros_concat_missing_literal = expected a literal
.note = only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()`
builtin_macros_default_arg = `#[default]` attribute does not accept a value
.suggestion = try using `#[default]`
builtin_macros_derive_from_usage_note = `#[derive(From)]` can only be used on structs with exactly one field
builtin_macros_derive_from_wrong_field_count = `#[derive(From)]` used on a struct with {$multiple_fields ->
[true] multiple fields
*[false] no fields
}
builtin_macros_derive_from_wrong_target = `#[derive(From)]` used on {$kind}
builtin_macros_derive_macro_call = `derive` cannot be used on items with type macros
builtin_macros_derive_path_args_list = traits in `#[derive(...)]` don't accept arguments
.suggestion = remove the arguments
builtin_macros_derive_path_args_value = traits in `#[derive(...)]` don't accept values
.suggestion = remove the value
builtin_macros_duplicate_macro_attribute = duplicated attribute
builtin_macros_eii_declaration_expected_list = `#[eii_declaration(...)]` expects a list of one or two elements
builtin_macros_eii_declaration_expected_macro = `#[eii_declaration(...)]` is only valid on macros
builtin_macros_eii_declaration_expected_unsafe = expected this argument to be "unsafe"
.note = the second argument is optional
builtin_macros_eii_only_once = `#[{$name}]` can only be specified once
.note = specified again here
builtin_macros_eii_shared_macro_expected_function = `#[{$name}]` is only valid on functions
builtin_macros_eii_shared_macro_expected_max_one_argument = `#[{$name}]` expected no arguments or a single argument: `#[{$name}(default)]`
builtin_macros_eii_shared_macro_in_statement_position = `#[{$name}]` can only be used on functions inside a module
.label = `#[{$name}]` is used on this item, which is part of another item's local scope
builtin_macros_env_not_defined = environment variable `{$var}` not defined at compile time
.cargo = Cargo sets build script variables at run time. Use `std::env::var({$var_expr})` instead
.cargo_typo = there is a similar Cargo environment variable: `{$suggested_var}`
.custom = use `std::env::var({$var_expr})` to read the variable at run time
builtin_macros_env_not_unicode = environment variable `{$var}` is not a valid Unicode string
builtin_macros_env_takes_args = `env!()` takes 1 or 2 arguments
builtin_macros_expected_comma_in_list = expected token: `,`
builtin_macros_expected_one_cfg_pattern = expected 1 cfg-pattern
builtin_macros_expected_other = expected operand, {$is_inline_asm ->
[false] options
*[true] clobber_abi, options
}, or additional template string
builtin_macros_export_macro_rules = cannot export macro_rules! macros from a `proc-macro` crate type currently
builtin_macros_format_add_missing_colon = add a colon before the format specifier
builtin_macros_format_duplicate_arg = duplicate argument named `{$ident}`
.label1 = previously here
.label2 = duplicate argument
builtin_macros_format_no_arg_named = there is no argument named `{$name}`
.note = did you intend to capture a variable `{$name}` from the surrounding scope?
.note2 = to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro
builtin_macros_format_pos_mismatch = {$n} positional {$n ->
[one] argument
*[more] arguments
} in format string, but {$desc}
builtin_macros_format_positional_after_named = positional arguments cannot follow named arguments
.label = positional arguments must be before named arguments
.named_args = named argument
builtin_macros_format_redundant_args = redundant {$n ->
[one] argument
*[more] arguments
}
.help = {$n ->
[one] the formatting string already captures the binding directly, it doesn't need to be included in the argument list
*[more] the formatting strings already captures the bindings directly, they don't need to be included in the argument list
}
.note = {$n ->
[one] the formatting specifier is referencing the binding already
*[more] the formatting specifiers are referencing the bindings already
}
.suggestion = this can be removed
builtin_macros_format_remove_raw_ident = remove the `r#`
builtin_macros_format_reorder_format_parameter = did you mean `{$replacement}`?
builtin_macros_format_requires_string = requires at least a format string argument
builtin_macros_format_string_invalid = invalid format string: {$desc}
.label = {$label1} in format string
.note = {$note}
.second_label = {$label}
builtin_macros_format_unknown_trait = unknown format trait `{$ty}`
.note = the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
.suggestion = use the `{$trait_name}` trait
builtin_macros_format_unused_arg = {$named ->
[true] named argument
*[false] argument
} never used
builtin_macros_format_unused_args = multiple unused formatting arguments
.label = multiple missing formatting specifiers
builtin_macros_format_use_positional = consider using a positional formatting argument instead
builtin_macros_incomplete_include = include macro expected single expression in source
builtin_macros_multiple_default_attrs = multiple `#[default]` attributes
.note = only one `#[default]` attribute is needed
.label = `#[default]` used here
.label_again = `#[default]` used again here
.help = try removing {$only_one ->
[true] this
*[false] these
}
builtin_macros_multiple_defaults = multiple declared defaults
.label = first default
.additional = additional default
.note = only one variant can be default
.suggestion = make `{$ident}` default
builtin_macros_naked_functions_testing_attribute =
cannot use `#[unsafe(naked)]` with testing attributes
.label = function marked with testing attribute here
.naked_attribute = `#[unsafe(naked)]` is incompatible with testing attributes
builtin_macros_no_default_variant = `#[derive(Default)]` on enum with no `#[default]`
.label = this enum needs a unit variant marked with `#[default]`
.suggestion = make this unit variant default by placing `#[default]` on it
builtin_macros_non_exhaustive_default = default variant must be exhaustive
.label = declared `#[non_exhaustive]` here
.help = consider a manual implementation of `Default`
builtin_macros_non_generic_pointee = the `#[pointee]` attribute may only be used on generic parameters
builtin_macros_non_unit_default = the `#[default]` attribute may only be used on unit enum variants{$post}
.help = consider a manual implementation of `Default`
builtin_macros_only_one_argument = {$name} takes 1 argument
builtin_macros_proc_macro = `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
builtin_macros_proc_macro_attribute_only_usable_with_crate_type = the `#[{$path}]` attribute is only usable with crates of the `proc-macro` crate type
builtin_macros_requires_cfg_pattern =
macro requires a cfg-pattern as an argument
.label = cfg-pattern required
builtin_macros_source_utils_expected_item = expected item, found `{$token}`
builtin_macros_takes_no_arguments = {$name} takes no arguments
builtin_macros_test_bad_fn = {$kind} functions cannot be used for tests
.label = `{$kind}` because of this
builtin_macros_test_case_non_item = `#[test_case]` attribute is only allowed on items
builtin_macros_test_runner_invalid = `test_runner` argument must be a path
builtin_macros_test_runner_nargs = `#![test_runner(..)]` accepts exactly 1 argument
builtin_macros_tests_not_support = building tests with panic=abort is not supported without `-Zpanic_abort_tests`
builtin_macros_trace_macros = trace_macros! accepts only `true` or `false`
builtin_macros_unexpected_lit = expected path to a trait, found literal
.label = not a trait
.str_lit = try using `#[derive({$sym})]`
.other = for example, write `#[derive(Debug)]` for `Debug`
builtin_macros_unnameable_test_items = cannot test inner items

View file

@ -463,44 +463,44 @@ impl<'a, 'b> rustc_ast::visit::Visitor<'a> for AlwaysErrorOnGenericParam<'a, 'b>
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_transparent, code = E0802)] #[diag("`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`", code = E0802)]
struct RequireTransparent { struct RequireTransparent {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_one_field, code = E0802)] #[diag("`CoercePointee` can only be derived on `struct`s with at least one field", code = E0802)]
struct RequireOneField { struct RequireOneField {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_one_generic, code = E0802)] #[diag("`CoercePointee` can only be derived on `struct`s that are generic over at least one type", code = E0802)]
struct RequireOneGeneric { struct RequireOneGeneric {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_one_pointee, code = E0802)] #[diag("exactly one generic type parameter must be marked as `#[pointee]` to derive `CoercePointee` traits", code = E0802)]
struct RequireOnePointee { struct RequireOnePointee {
#[primary_span] #[primary_span]
span: Span, span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_too_many_pointees, code = E0802)] #[diag("only one type parameter can be marked as `#[pointee]` when deriving `CoercePointee` traits", code = E0802)]
struct TooManyPointees { struct TooManyPointees {
#[primary_span] #[primary_span]
one: Span, one: Span,
#[label] #[label("here another type parameter is marked as `#[pointee]`")]
another: Span, another: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_maybe_sized, code = E0802)] #[diag("`derive(CoercePointee)` requires `{$name}` to be marked `?Sized`", code = E0802)]
struct RequiresMaybeSized { struct RequiresMaybeSized {
#[primary_span] #[primary_span]
span: Span, span: Span,

File diff suppressed because it is too large Load diff

View file

@ -57,8 +57,6 @@ pub mod standard_library_imports;
pub mod test_harness; pub mod test_harness;
pub mod util; pub mod util;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
let mut register = |name, kind| resolver.register_builtin_macro(name, kind); let mut register = |name, kind| resolver.register_builtin_macro(name, kind);
macro register_bang($($name:ident: $f:expr,)*) { macro register_bang($($name:ident: $f:expr,)*) {

View file

@ -131,7 +131,7 @@ fn emit_ptr_va_arg<'ll, 'tcx>(
); );
if indirect { if indirect {
let tmp_ret = bx.load(llty, addr, addr_align); let tmp_ret = bx.load(llty, addr, addr_align);
bx.load(bx.cx.layout_of(target_ty).llvm_type(bx.cx), tmp_ret, align.abi) bx.load(layout.llvm_type(bx.cx), tmp_ret, align.abi)
} else { } else {
bx.load(llty, addr, addr_align) bx.load(llty, addr, addr_align)
} }
@ -1007,6 +1007,8 @@ fn emit_xtensa_va_arg<'ll, 'tcx>(
/// Determine the va_arg implementation to use. The LLVM va_arg instruction /// Determine the va_arg implementation to use. The LLVM va_arg instruction
/// is lacking in some instances, so we should only use it as a fallback. /// is lacking in some instances, so we should only use it as a fallback.
///
/// <https://llvm.org/docs/LangRef.html#va-arg-instruction>
pub(super) fn emit_va_arg<'ll, 'tcx>( pub(super) fn emit_va_arg<'ll, 'tcx>(
bx: &mut Builder<'_, 'll, 'tcx>, bx: &mut Builder<'_, 'll, 'tcx>,
addr: OperandRef<'tcx, &'ll Value>, addr: OperandRef<'tcx, &'ll Value>,
@ -1015,6 +1017,10 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
let layout = bx.cx.layout_of(target_ty); let layout = bx.cx.layout_of(target_ty);
let target_ty_size = layout.layout.size().bytes(); let target_ty_size = layout.layout.size().bytes();
// Some ABIs have special behavior for zero-sized types. currently `VaArgSafe` is not
// implemented for any zero-sized types, so this assert should always hold.
assert!(!bx.layout_of(target_ty).is_zst());
let target = &bx.cx.tcx.sess.target; let target = &bx.cx.tcx.sess.target;
match target.arch { match target.arch {
Arch::X86 => emit_ptr_va_arg( Arch::X86 => emit_ptr_va_arg(
@ -1026,17 +1032,24 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes }, if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes },
ForceRightAdjust::No, ForceRightAdjust::No,
), ),
Arch::AArch64 | Arch::Arm64EC if target.is_like_windows || target.is_like_darwin => { Arch::Arm64EC => emit_ptr_va_arg(
emit_ptr_va_arg( bx,
bx, addr,
addr, target_ty,
target_ty, PassMode::Direct,
PassMode::Direct, SlotSize::Bytes8,
SlotSize::Bytes8, if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes },
if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes }, ForceRightAdjust::No,
ForceRightAdjust::No, ),
) Arch::AArch64 if target.is_like_windows || target.is_like_darwin => emit_ptr_va_arg(
} bx,
addr,
target_ty,
PassMode::Direct,
SlotSize::Bytes8,
if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes },
ForceRightAdjust::No,
),
Arch::AArch64 => emit_aapcs_va_arg(bx, addr, target_ty), Arch::AArch64 => emit_aapcs_va_arg(bx, addr, target_ty),
Arch::Arm => { Arch::Arm => {
// Types wider than 16 bytes are not currently supported. Clang has special logic for // Types wider than 16 bytes are not currently supported. Clang has special logic for
@ -1064,7 +1077,16 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
AllowHigherAlign::Yes, AllowHigherAlign::Yes,
ForceRightAdjust::Yes, ForceRightAdjust::Yes,
), ),
Arch::LoongArch32 => emit_ptr_va_arg( Arch::RiscV32 if target.abi == Abi::Ilp32e => {
// FIXME: clang manually adjusts the alignment for this ABI. It notes:
//
// > To be compatible with GCC's behaviors, we force arguments with
// > 2×XLEN-bit alignment and size at most 2×XLEN bits like `long long`,
// > `unsigned long long` and `double` to have 4-byte alignment. This
// > behavior may be changed when RV32E/ILP32E is ratified.
bug!("c-variadic calls with ilp32e use a custom ABI and are not currently implemented");
}
Arch::RiscV32 | Arch::LoongArch32 => emit_ptr_va_arg(
bx, bx,
addr, addr,
target_ty, target_ty,
@ -1073,7 +1095,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
AllowHigherAlign::Yes, AllowHigherAlign::Yes,
ForceRightAdjust::No, ForceRightAdjust::No,
), ),
Arch::LoongArch64 => emit_ptr_va_arg( Arch::RiscV64 | Arch::LoongArch64 => emit_ptr_va_arg(
bx, bx,
addr, addr,
target_ty, target_ty,
@ -1140,16 +1162,34 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
// This includes `target.is_like_darwin`, which on x86_64 targets is like sysv64. // This includes `target.is_like_darwin`, which on x86_64 targets is like sysv64.
Arch::X86_64 => emit_x86_64_sysv64_va_arg(bx, addr, target_ty), Arch::X86_64 => emit_x86_64_sysv64_va_arg(bx, addr, target_ty),
Arch::Xtensa => emit_xtensa_va_arg(bx, addr, target_ty), Arch::Xtensa => emit_xtensa_va_arg(bx, addr, target_ty),
Arch::Hexagon => { Arch::Hexagon => match target.env {
if target.env == Env::Musl { Env::Musl => emit_hexagon_va_arg_musl(bx, addr, target_ty),
emit_hexagon_va_arg_musl(bx, addr, target_ty) _ => emit_hexagon_va_arg_bare_metal(bx, addr, target_ty),
} else { },
emit_hexagon_va_arg_bare_metal(bx, addr, target_ty) Arch::Sparc64 => emit_ptr_va_arg(
} bx,
addr,
target_ty,
if target_ty_size > 2 * 8 { PassMode::Indirect } else { PassMode::Direct },
SlotSize::Bytes8,
AllowHigherAlign::Yes,
ForceRightAdjust::No,
),
Arch::Bpf => bug!("bpf does not support c-variadic functions"),
Arch::SpirV => bug!("spirv does not support c-variadic functions"),
Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => {
// FIXME: port MipsTargetLowering::lowerVAARG.
bx.va_arg(addr.immediate(), bx.cx.layout_of(target_ty).llvm_type(bx.cx))
}
Arch::Sparc | Arch::Avr | Arch::M68k | Arch::Msp430 => {
// Clang uses the LLVM implementation for these architectures.
bx.va_arg(addr.immediate(), bx.cx.layout_of(target_ty).llvm_type(bx.cx))
}
Arch::Other(_) => {
// For custom targets, use the LLVM va_arg instruction as a fallback.
bx.va_arg(addr.immediate(), bx.cx.layout_of(target_ty).llvm_type(bx.cx))
} }
// For all other architecture/OS combinations fall back to using
// the LLVM va_arg instruction.
// https://llvm.org/docs/LangRef.html#va-arg-instruction
_ => bx.va_arg(addr.immediate(), bx.cx.layout_of(target_ty).llvm_type(bx.cx)),
} }
} }

View file

@ -9,10 +9,8 @@ anstyle = "1.0.13"
jiff = { version = "0.2.5", default-features = false, features = ["std"] } jiff = { version = "0.2.5", default-features = false, features = ["std"] }
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_passes = { path = "../rustc_ast_passes" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_borrowck = { path = "../rustc_borrowck" } rustc_borrowck = { path = "../rustc_borrowck" }
rustc_builtin_macros = { path = "../rustc_builtin_macros" }
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" } rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_const_eval = { path = "../rustc_const_eval" } rustc_const_eval = { path = "../rustc_const_eval" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
@ -33,7 +31,6 @@ rustc_mir_build = { path = "../rustc_mir_build" }
rustc_mir_transform = { path = "../rustc_mir_transform" } rustc_mir_transform = { path = "../rustc_mir_transform" }
rustc_parse = { path = "../rustc_parse" } rustc_parse = { path = "../rustc_parse" }
rustc_passes = { path = "../rustc_passes" } rustc_passes = { path = "../rustc_passes" }
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] } rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
rustc_resolve = { path = "../rustc_resolve" } rustc_resolve = { path = "../rustc_resolve" }
rustc_session = { path = "../rustc_session" } rustc_session = { path = "../rustc_session" }

View file

@ -114,18 +114,13 @@ pub fn default_translator() -> Translator {
pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
rustc_ast_passes::DEFAULT_LOCALE_RESOURCE,
rustc_borrowck::DEFAULT_LOCALE_RESOURCE, rustc_borrowck::DEFAULT_LOCALE_RESOURCE,
rustc_builtin_macros::DEFAULT_LOCALE_RESOURCE,
rustc_const_eval::DEFAULT_LOCALE_RESOURCE, rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
rustc_errors::DEFAULT_LOCALE_RESOURCE,
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE, rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
rustc_lint::DEFAULT_LOCALE_RESOURCE, rustc_lint::DEFAULT_LOCALE_RESOURCE,
rustc_middle::DEFAULT_LOCALE_RESOURCE,
rustc_mir_build::DEFAULT_LOCALE_RESOURCE, rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_passes::DEFAULT_LOCALE_RESOURCE, rustc_passes::DEFAULT_LOCALE_RESOURCE,
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE, rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];

View file

@ -14,7 +14,6 @@ rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_codes = { path = "../rustc_error_codes" } rustc_error_codes = { path = "../rustc_error_codes" }
rustc_error_messages = { path = "../rustc_error_messages" } rustc_error_messages = { path = "../rustc_error_messages" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hashes = { path = "../rustc_hashes" } rustc_hashes = { path = "../rustc_hashes" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_lint_defs = { path = "../rustc_lint_defs" } rustc_lint_defs = { path = "../rustc_lint_defs" }

View file

@ -1,48 +0,0 @@
errors_delayed_at_with_newline =
delayed at {$emitted_at}
{$note}
errors_delayed_at_without_newline =
delayed at {$emitted_at} - {$note}
errors_expected_lifetime_parameter =
expected lifetime {$count ->
[1] parameter
*[other] parameters
}
errors_indicate_anonymous_lifetime =
indicate the anonymous {$count ->
[1] lifetime
*[other] lifetimes
}
errors_invalid_flushed_delayed_diagnostic_level =
`flushed_delayed` got diagnostic with level {$level}, instead of the expected `DelayedBug`
errors_target_inconsistent_architecture =
inconsistent target specification: "data-layout" claims architecture is {$dl}-endian, while "target-endian" is `{$target}`
errors_target_inconsistent_pointer_width =
inconsistent target specification: "data-layout" claims pointers are {$pointer_size}-bit, while "target-pointer-width" is `{$target}`
errors_target_invalid_address_space =
invalid address space `{$addr_space}` for `{$cause}` in "data-layout": {$err}
errors_target_invalid_alignment =
invalid alignment for `{$cause}` in "data-layout": `{$align}` is {$err_kind ->
[not_power_of_two] not a power of 2
[too_large] too large
*[other] {""}
}
errors_target_invalid_bits =
invalid {$kind} `{$bit}` for `{$cause}` in "data-layout": {$err}
errors_target_invalid_bits_size = {$err}
errors_target_invalid_datalayout_pointer_spec =
unknown pointer specification `{$err}` in datalayout string
errors_target_missing_alignment =
missing alignment for `{$cause}` in "data-layout"

View file

@ -7,8 +7,7 @@ use rustc_span::{Span, Symbol};
use crate::diagnostic::DiagLocation; use crate::diagnostic::DiagLocation;
use crate::{ use crate::{
Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, Subdiagnostic, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, Subdiagnostic, inline_fluent,
fluent_generated as fluent,
}; };
impl IntoDiagArg for DiagLocation { impl IntoDiagArg for DiagLocation {
@ -44,43 +43,48 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetDataLayoutErrors<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
match self { match self {
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => { TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
Diag::new(dcx, level, fluent::errors_target_invalid_address_space) Diag::new(dcx, level, inline_fluent!("invalid address space `{$addr_space}` for `{$cause}` in \"data-layout\": {$err}"))
.with_arg("addr_space", addr_space) .with_arg("addr_space", addr_space)
.with_arg("cause", cause) .with_arg("cause", cause)
.with_arg("err", err) .with_arg("err", err)
} }
TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => { TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => {
Diag::new(dcx, level, fluent::errors_target_invalid_bits) Diag::new(dcx, level, inline_fluent!("invalid {$kind} `{$bit}` for `{$cause}` in \"data-layout\": {$err}"))
.with_arg("kind", kind) .with_arg("kind", kind)
.with_arg("bit", bit) .with_arg("bit", bit)
.with_arg("cause", cause) .with_arg("cause", cause)
.with_arg("err", err) .with_arg("err", err)
} }
TargetDataLayoutErrors::MissingAlignment { cause } => { TargetDataLayoutErrors::MissingAlignment { cause } => {
Diag::new(dcx, level, fluent::errors_target_missing_alignment) Diag::new(dcx, level, inline_fluent!("missing alignment for `{$cause}` in \"data-layout\""))
.with_arg("cause", cause) .with_arg("cause", cause)
} }
TargetDataLayoutErrors::InvalidAlignment { cause, err } => { TargetDataLayoutErrors::InvalidAlignment { cause, err } => {
Diag::new(dcx, level, fluent::errors_target_invalid_alignment) Diag::new(dcx, level, inline_fluent!("invalid alignment for `{$cause}` in \"data-layout\": `{$align}` is {$err_kind ->
.with_arg("cause", cause) [not_power_of_two] not a power of 2
.with_arg("err_kind", err.diag_ident()) [too_large] too large
.with_arg("align", err.align()) *[other] {\"\"}
}"))
.with_arg("cause", cause)
.with_arg("err_kind", err.diag_ident())
.with_arg("align", err.align())
} }
TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => { TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => {
Diag::new(dcx, level, fluent::errors_target_inconsistent_architecture) Diag::new(dcx, level, inline_fluent!(
.with_arg("dl", dl) "inconsistent target specification: \"data-layout\" claims architecture is {$dl}-endian, while \"target-endian\" is `{$target}`"
.with_arg("target", target) ))
.with_arg("dl", dl).with_arg("target", target)
} }
TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => { TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => {
Diag::new(dcx, level, fluent::errors_target_inconsistent_pointer_width) Diag::new(dcx, level, inline_fluent!(
.with_arg("pointer_size", pointer_size) "inconsistent target specification: \"data-layout\" claims pointers are {$pointer_size}-bit, while \"target-pointer-width\" is `{$target}`"
.with_arg("target", target) )).with_arg("pointer_size", pointer_size).with_arg("target", target)
} }
TargetDataLayoutErrors::InvalidBitsSize { err } => { TargetDataLayoutErrors::InvalidBitsSize { err } => {
Diag::new(dcx, level, fluent::errors_target_invalid_bits_size).with_arg("err", err) Diag::new(dcx, level, inline_fluent!("{$err}")).with_arg("err", err)
} }
TargetDataLayoutErrors::UnknownPointerSpecification { err } => { TargetDataLayoutErrors::UnknownPointerSpecification { err } => {
Diag::new(dcx, level, fluent::errors_target_invalid_datalayout_pointer_spec) Diag::new(dcx, level, inline_fluent!("unknown pointer specification `{$err}` in datalayout string"))
.with_arg("err", err) .with_arg("err", err)
} }
} }
@ -99,7 +103,12 @@ impl Subdiagnostic for SingleLabelManySpans {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(errors_expected_lifetime_parameter)] #[label(
"expected lifetime {$count ->
[1] parameter
*[other] parameters
}"
)]
pub struct ExpectedLifetimeParameter { pub struct ExpectedLifetimeParameter {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -107,7 +116,14 @@ pub struct ExpectedLifetimeParameter {
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion(errors_indicate_anonymous_lifetime, code = "{suggestion}", style = "verbose")] #[suggestion(
"indicate the anonymous {$count ->
[1] lifetime
*[other] lifetimes
}",
code = "{suggestion}",
style = "verbose"
)]
pub struct IndicateAnonymousLifetime { pub struct IndicateAnonymousLifetime {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,

View file

@ -45,8 +45,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
rustc_span::create_default_session_globals_then(|| { rustc_span::create_default_session_globals_then(|| {
let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); let sm = Arc::new(SourceMap::new(FilePathMapping::empty()));
sm.new_source_file(filename(&sm, "test.rs"), code.to_owned()); sm.new_source_file(filename(&sm, "test.rs"), code.to_owned());
let translator = let translator = Translator::with_fallback_bundle(vec![], false);
Translator::with_fallback_bundle(vec![crate::DEFAULT_LOCALE_RESOURCE], false);
let output = Arc::new(Mutex::new(Vec::new())); let output = Arc::new(Mutex::new(Vec::new()));
let je = JsonEmitter::new( let je = JsonEmitter::new(

View file

@ -92,8 +92,6 @@ pub mod translation;
pub type PResult<'a, T> = Result<T, Diag<'a>>; pub type PResult<'a, T> = Result<T, Diag<'a>>;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger. // `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_pointer_width = "64")] #[cfg(target_pointer_width = "64")]
rustc_data_structures::static_assert_size!(PResult<'_, ()>, 24); rustc_data_structures::static_assert_size!(PResult<'_, ()>, 24);
@ -1531,7 +1529,9 @@ impl DiagCtxtInner {
// the usual `Diag`/`DiagCtxt` level, so we must augment `bug` // the usual `Diag`/`DiagCtxt` level, so we must augment `bug`
// in a lower-level fashion. // in a lower-level fashion.
bug.arg("level", bug.level); bug.arg("level", bug.level);
let msg = crate::fluent_generated::errors_invalid_flushed_delayed_diagnostic_level; let msg = inline_fluent!(
"`flushed_delayed` got diagnostic with level {$level}, instead of the expected `DelayedBug`"
);
let msg = self.eagerly_translate_for_subdiag(&bug, msg); // after the `arg` call let msg = self.eagerly_translate_for_subdiag(&bug, msg); // after the `arg` call
bug.sub(Note, msg, bug.span.primary_span().unwrap().into()); bug.sub(Note, msg, bug.span.primary_span().unwrap().into());
} }
@ -1573,10 +1573,13 @@ impl DelayedDiagInner {
// lower-level fashion. // lower-level fashion.
let mut diag = self.inner; let mut diag = self.inner;
let msg = match self.note.status() { let msg = match self.note.status() {
BacktraceStatus::Captured => crate::fluent_generated::errors_delayed_at_with_newline, BacktraceStatus::Captured => inline_fluent!(
"delayed at {$emitted_at}
{$note}"
),
// Avoid the needless newline when no backtrace has been captured, // Avoid the needless newline when no backtrace has been captured,
// the display impl should just be a single line. // the display impl should just be a single line.
_ => crate::fluent_generated::errors_delayed_at_without_newline, _ => inline_fluent!("delayed at {$emitted_at} - {$note}"),
}; };
diag.arg("emitted_at", diag.emitted_at.clone()); diag.arg("emitted_at", diag.emitted_at.clone());
diag.arg("note", self.note); diag.arg("note", self.note);

View file

@ -429,7 +429,14 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
$macro!(#feedable_queries); $macro!(#feedable_queries);
} }
} }
pub mod descs {
/// Functions that format a human-readable description of each query
/// and its key, as specified by the `desc` query modifier.
///
/// (The leading `_` avoids collisions with actual query names when
/// expanded in `rustc_middle::queries`, and makes this macro-generated
/// module easier to search for.)
pub mod _description_fns {
use super::*; use super::*;
#query_description_stream #query_description_stream
} }

View file

@ -18,7 +18,6 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_messages = { path = "../rustc_error_messages" } # Used for intra-doc links rustc_error_messages = { path = "../rustc_error_messages" } # Used for intra-doc links
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_graphviz = { path = "../rustc_graphviz" } rustc_graphviz = { path = "../rustc_graphviz" }
rustc_hashes = { path = "../rustc_hashes" } rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }

View file

@ -1,133 +0,0 @@
middle_assert_async_resume_after_drop = `async fn` resumed after async drop
middle_assert_async_resume_after_panic = `async fn` resumed after panicking
middle_assert_async_resume_after_return = `async fn` resumed after completion
middle_assert_coroutine_resume_after_drop = coroutine resumed after async drop
middle_assert_coroutine_resume_after_panic = coroutine resumed after panicking
middle_assert_coroutine_resume_after_return = coroutine resumed after completion
middle_assert_divide_by_zero =
attempt to divide `{$val}` by zero
middle_assert_gen_resume_after_drop = `gen` fn or block cannot be further iterated on after it async dropped
middle_assert_gen_resume_after_panic = `gen` fn or block cannot be further iterated on after it panicked
middle_assert_invalid_enum_construction =
trying to construct an enum from an invalid value `{$source}`
middle_assert_misaligned_ptr_deref =
misaligned pointer dereference: address must be a multiple of {$required} but is {$found}
middle_assert_null_ptr_deref =
null pointer dereference occurred
middle_assert_op_overflow =
attempt to compute `{$left} {$op} {$right}`, which would overflow
middle_assert_overflow_neg =
attempt to negate `{$val}`, which would overflow
middle_assert_remainder_by_zero =
attempt to calculate the remainder of `{$val}` with a divisor of zero
middle_assert_shl_overflow =
attempt to shift left by `{$val}`, which would overflow
middle_assert_shr_overflow =
attempt to shift right by `{$val}`, which would overflow
middle_autodiff_unsafe_inner_const_ref = reading from a `Duplicated` const {$ty} is unsafe
middle_bounds_check =
index out of bounds: the length is {$len} but the index is {$index}
middle_conflict_types =
this expression supplies two conflicting concrete types for the same opaque type
middle_consider_type_length_limit =
consider adding a `#![type_length_limit="{$type_length}"]` attribute to your crate
middle_const_eval_non_int =
constant evaluation of enum discriminant resulted in non-integer
middle_const_not_used_in_type_alias =
const parameter `{$ct}` is part of concrete type but not used in parameter list for the `impl Trait` type alias
middle_deprecated = use of deprecated {$kind} `{$path}`{$has_note ->
[true] : {$note}
*[other] {""}
}
middle_deprecated_in_future = use of {$kind} `{$path}` that will be deprecated in a future Rust version{$has_note ->
[true] : {$note}
*[other] {""}
}
middle_deprecated_in_version = use of {$kind} `{$path}` that will be deprecated in future version {$version}{$has_note ->
[true] : {$note}
*[other] {""}
}
middle_deprecated_suggestion = replace the use of the deprecated {$kind}
middle_drop_check_overflow =
overflow while adding drop-check rules for `{$ty}`
.note = overflowed on `{$overflow_ty}`
middle_erroneous_constant = erroneous constant encountered
middle_failed_writing_file =
failed to write file {$path}: {$error}"
# Note: We only mention patterns here since the error can only occur with references, and those
# are forbidden in const generics.
middle_invalid_const_in_valtree = constant {$global_const_id} cannot be used as pattern
.note = constants that reference mutable or external memory cannot be used as patterns
middle_layout_cycle =
a cycle occurred during layout computation
middle_layout_normalization_failure =
unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized
middle_layout_references_error =
the type has an unknown layout
middle_layout_simd_too_many =
the SIMD type `{$ty}` has more elements than the limit {$max_lanes}
middle_layout_simd_zero_length =
the SIMD type `{$ty}` has zero elements
middle_layout_size_overflow =
values of the type `{$ty}` are too big for the target architecture
middle_layout_too_generic = the type `{$ty}` does not have a fixed layout
middle_layout_unknown =
the type `{$ty}` has an unknown layout
middle_max_num_nodes_in_valtree = maximum number of nodes exceeded in constant {$global_const_id}
middle_opaque_hidden_type_mismatch =
concrete type differs from previous defining opaque type use
.label = expected `{$self_ty}`, got `{$other_ty}`
middle_previous_use_here =
previous use here
middle_recursion_limit_reached =
reached the recursion limit finding the struct tail for `{$ty}`
.help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]`
middle_requires_lang_item = requires `{$name}` lang_item
middle_strict_coherence_needs_negative_coherence =
to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled
.label = due to this attribute
middle_type_length_limit = reached the type-length limit while instantiating `{$instance}`
middle_unsupported_union = we don't support unions yet: '{$ty_name}'

View file

@ -9,8 +9,8 @@ use rustc_span::{Span, Symbol};
use crate::ty::{Instance, Ty}; use crate::ty::{Instance, Ty};
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_drop_check_overflow, code = E0320)] #[diag("overflow while adding drop-check rules for `{$ty}`", code = E0320)]
#[note] #[note("overflowed on `{$overflow_ty}`")]
pub(crate) struct DropCheckOverflow<'tcx> { pub(crate) struct DropCheckOverflow<'tcx> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -19,33 +19,33 @@ pub(crate) struct DropCheckOverflow<'tcx> {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_failed_writing_file)] #[diag("failed to write file {$path}: {$error}\"")]
pub(crate) struct FailedWritingFile<'a> { pub(crate) struct FailedWritingFile<'a> {
pub path: &'a Path, pub path: &'a Path,
pub error: io::Error, pub error: io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_opaque_hidden_type_mismatch)] #[diag("concrete type differs from previous defining opaque type use")]
pub(crate) struct OpaqueHiddenTypeMismatch<'tcx> { pub(crate) struct OpaqueHiddenTypeMismatch<'tcx> {
pub self_ty: Ty<'tcx>, pub self_ty: Ty<'tcx>,
pub other_ty: Ty<'tcx>, pub other_ty: Ty<'tcx>,
#[primary_span] #[primary_span]
#[label] #[label("expected `{$self_ty}`, got `{$other_ty}`")]
pub other_span: Span, pub other_span: Span,
#[subdiagnostic] #[subdiagnostic]
pub sub: TypeMismatchReason, pub sub: TypeMismatchReason,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_unsupported_union)] #[diag("we don't support unions yet: '{$ty_name}'")]
pub struct UnsupportedUnion { pub struct UnsupportedUnion {
pub ty_name: String, pub ty_name: String,
} }
// FIXME(autodiff): I should get used somewhere // FIXME(autodiff): I should get used somewhere
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_autodiff_unsafe_inner_const_ref)] #[diag("reading from a `Duplicated` const {$ty} is unsafe")]
pub struct AutodiffUnsafeInnerConstRef<'tcx> { pub struct AutodiffUnsafeInnerConstRef<'tcx> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -54,12 +54,12 @@ pub struct AutodiffUnsafeInnerConstRef<'tcx> {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
pub enum TypeMismatchReason { pub enum TypeMismatchReason {
#[label(middle_conflict_types)] #[label("this expression supplies two conflicting concrete types for the same opaque type")]
ConflictType { ConflictType {
#[primary_span] #[primary_span]
span: Span, span: Span,
}, },
#[note(middle_previous_use_here)] #[note("previous use here")]
PreviousUse { PreviousUse {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -67,8 +67,10 @@ pub enum TypeMismatchReason {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_recursion_limit_reached)] #[diag("reached the recursion limit finding the struct tail for `{$ty}`")]
#[help] #[help(
"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]`"
)]
pub(crate) struct RecursionLimitReached<'tcx> { pub(crate) struct RecursionLimitReached<'tcx> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -77,23 +79,25 @@ pub(crate) struct RecursionLimitReached<'tcx> {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_const_eval_non_int)] #[diag("constant evaluation of enum discriminant resulted in non-integer")]
pub(crate) struct ConstEvalNonIntError { pub(crate) struct ConstEvalNonIntError {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_strict_coherence_needs_negative_coherence)] #[diag(
"to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled"
)]
pub(crate) struct StrictCoherenceNeedsNegativeCoherence { pub(crate) struct StrictCoherenceNeedsNegativeCoherence {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
#[label] #[label("due to this attribute")]
pub attr_span: Option<Span>, pub attr_span: Option<Span>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_requires_lang_item)] #[diag("requires `{$name}` lang_item")]
pub(crate) struct RequiresLangItem { pub(crate) struct RequiresLangItem {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -101,7 +105,9 @@ pub(crate) struct RequiresLangItem {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_const_not_used_in_type_alias)] #[diag(
"const parameter `{$ct}` is part of concrete type but not used in parameter list for the `impl Trait` type alias"
)]
pub(super) struct ConstNotUsedTraitAlias { pub(super) struct ConstNotUsedTraitAlias {
pub ct: String, pub ct: String,
#[primary_span] #[primary_span]
@ -133,41 +139,41 @@ impl fmt::Debug for CustomSubdiagnostic<'_> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
pub enum LayoutError<'tcx> { pub enum LayoutError<'tcx> {
#[diag(middle_layout_unknown)] #[diag("the type `{$ty}` has an unknown layout")]
Unknown { ty: Ty<'tcx> }, Unknown { ty: Ty<'tcx> },
#[diag(middle_layout_too_generic)] #[diag("the type `{$ty}` does not have a fixed layout")]
TooGeneric { ty: Ty<'tcx> }, TooGeneric { ty: Ty<'tcx> },
#[diag(middle_layout_size_overflow)] #[diag("values of the type `{$ty}` are too big for the target architecture")]
Overflow { ty: Ty<'tcx> }, Overflow { ty: Ty<'tcx> },
#[diag(middle_layout_simd_too_many)] #[diag("the SIMD type `{$ty}` has more elements than the limit {$max_lanes}")]
SimdTooManyLanes { ty: Ty<'tcx>, max_lanes: u64 }, SimdTooManyLanes { ty: Ty<'tcx>, max_lanes: u64 },
#[diag(middle_layout_simd_zero_length)] #[diag("the SIMD type `{$ty}` has zero elements")]
SimdZeroLength { ty: Ty<'tcx> }, SimdZeroLength { ty: Ty<'tcx> },
#[diag(middle_layout_normalization_failure)] #[diag("unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized")]
NormalizationFailure { ty: Ty<'tcx>, failure_ty: String }, NormalizationFailure { ty: Ty<'tcx>, failure_ty: String },
#[diag(middle_layout_cycle)] #[diag("a cycle occurred during layout computation")]
Cycle, Cycle,
#[diag(middle_layout_references_error)] #[diag("the type has an unknown layout")]
ReferencesError, ReferencesError,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_erroneous_constant)] #[diag("erroneous constant encountered")]
pub(crate) struct ErroneousConstant { pub(crate) struct ErroneousConstant {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_type_length_limit)] #[diag("reached the type-length limit while instantiating `{$instance}`")]
#[help(middle_consider_type_length_limit)] #[help("consider adding a `#![type_length_limit=\"{$type_length}\"]` attribute to your crate")]
pub(crate) struct TypeLengthLimit<'tcx> { pub(crate) struct TypeLengthLimit<'tcx> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -176,7 +182,7 @@ pub(crate) struct TypeLengthLimit<'tcx> {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_max_num_nodes_in_valtree)] #[diag("maximum number of nodes exceeded in constant {$global_const_id}")]
pub(crate) struct MaxNumNodesInValtree { pub(crate) struct MaxNumNodesInValtree {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -184,8 +190,8 @@ pub(crate) struct MaxNumNodesInValtree {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(middle_invalid_const_in_valtree)] #[diag("constant {$global_const_id} cannot be used as pattern")]
#[note] #[note("constants that reference mutable or external memory cannot be used as patterns")]
pub(crate) struct InvalidConstInValtree { pub(crate) struct InvalidConstInValtree {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,

View file

@ -91,5 +91,3 @@ pub mod dep_graph;
// Allows macros to refer to this crate as `::rustc_middle` // Allows macros to refer to this crate as `::rustc_middle`
extern crate self as rustc_middle; extern crate self as rustc_middle;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -4,7 +4,7 @@
use std::num::NonZero; use std::num::NonZero;
use rustc_ast::NodeId; use rustc_ast::NodeId;
use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintBuffer}; use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintBuffer, inline_fluent};
use rustc_feature::GateIssue; use rustc_feature::GateIssue;
use rustc_hir::attrs::{DeprecatedSince, Deprecation}; use rustc_hir::attrs::{DeprecatedSince, Deprecation};
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
@ -103,7 +103,7 @@ fn deprecation_lint(is_in_effect: bool) -> &'static Lint {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[suggestion( #[suggestion(
middle_deprecated_suggestion, "replace the use of the deprecated {$kind}",
code = "{suggestion}", code = "{suggestion}",
style = "verbose", style = "verbose",
applicability = "machine-applicable" applicability = "machine-applicable"
@ -128,10 +128,19 @@ pub struct Deprecated {
impl<'a, G: EmissionGuarantee> rustc_errors::LintDiagnostic<'a, G> for Deprecated { impl<'a, G: EmissionGuarantee> rustc_errors::LintDiagnostic<'a, G> for Deprecated {
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
diag.primary_message(match &self.since_kind { diag.primary_message(match &self.since_kind {
DeprecatedSinceKind::InEffect => crate::fluent_generated::middle_deprecated, DeprecatedSinceKind::InEffect => inline_fluent!("use of deprecated {$kind} `{$path}`{$has_note ->
DeprecatedSinceKind::InFuture => crate::fluent_generated::middle_deprecated_in_future, [true] : {$note}
*[other] {\"\"}
}"),
DeprecatedSinceKind::InFuture => inline_fluent!("use of {$kind} `{$path}` that will be deprecated in a future Rust version{$has_note ->
[true] : {$note}
*[other] {\"\"}
}"),
DeprecatedSinceKind::InVersion(_) => { DeprecatedSinceKind::InVersion(_) => {
crate::fluent_generated::middle_deprecated_in_version inline_fluent!("use of {$kind} `{$path}` that will be deprecated in future version {$version}{$has_note ->
[true] : {$note}
*[other] {\"\"}
}")
} }
}); });
diag.arg("kind", self.kind); diag.arg("kind", self.kind);

View file

@ -336,18 +336,26 @@ impl<O> AssertKind<O> {
pub fn diagnostic_message(&self) -> DiagMessage { pub fn diagnostic_message(&self) -> DiagMessage {
use AssertKind::*; use AssertKind::*;
use crate::fluent_generated::*;
match self { match self {
BoundsCheck { .. } => middle_bounds_check, BoundsCheck { .. } => inline_fluent!(
Overflow(BinOp::Shl, _, _) => middle_assert_shl_overflow, "index out of bounds: the length is {$len} but the index is {$index}"
Overflow(BinOp::Shr, _, _) => middle_assert_shr_overflow, ),
Overflow(_, _, _) => middle_assert_op_overflow, Overflow(BinOp::Shl, _, _) => {
OverflowNeg(_) => middle_assert_overflow_neg, inline_fluent!("attempt to shift left by `{$val}`, which would overflow")
DivisionByZero(_) => middle_assert_divide_by_zero, }
RemainderByZero(_) => middle_assert_remainder_by_zero, Overflow(BinOp::Shr, _, _) => {
inline_fluent!("attempt to shift right by `{$val}`, which would overflow")
}
Overflow(_, _, _) => {
inline_fluent!("attempt to compute `{$left} {$op} {$right}`, which would overflow")
}
OverflowNeg(_) => inline_fluent!("attempt to negate `{$val}`, which would overflow"),
DivisionByZero(_) => inline_fluent!("attempt to divide `{$val}` by zero"),
RemainderByZero(_) => inline_fluent!(
"attempt to calculate the remainder of `{$val}` with a divisor of zero"
),
ResumedAfterReturn(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) => { ResumedAfterReturn(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) => {
middle_assert_async_resume_after_return inline_fluent!("`async fn` resumed after completion")
} }
ResumedAfterReturn(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) => { ResumedAfterReturn(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) => {
todo!() todo!()
@ -356,36 +364,42 @@ impl<O> AssertKind<O> {
bug!("gen blocks can be resumed after they return and will keep returning `None`") bug!("gen blocks can be resumed after they return and will keep returning `None`")
} }
ResumedAfterReturn(CoroutineKind::Coroutine(_)) => { ResumedAfterReturn(CoroutineKind::Coroutine(_)) => {
middle_assert_coroutine_resume_after_return inline_fluent!("coroutine resumed after completion")
} }
ResumedAfterPanic(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) => { ResumedAfterPanic(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) => {
middle_assert_async_resume_after_panic inline_fluent!("`async fn` resumed after panicking")
} }
ResumedAfterPanic(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) => { ResumedAfterPanic(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) => {
todo!() todo!()
} }
ResumedAfterPanic(CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) => { ResumedAfterPanic(CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) => {
middle_assert_gen_resume_after_panic inline_fluent!("`gen` fn or block cannot be further iterated on after it panicked")
} }
ResumedAfterPanic(CoroutineKind::Coroutine(_)) => { ResumedAfterPanic(CoroutineKind::Coroutine(_)) => {
middle_assert_coroutine_resume_after_panic inline_fluent!("coroutine resumed after panicking")
}
NullPointerDereference => inline_fluent!("null pointer dereference occurred"),
InvalidEnumConstruction(_) => {
inline_fluent!("trying to construct an enum from an invalid value `{$source}`")
} }
NullPointerDereference => middle_assert_null_ptr_deref,
InvalidEnumConstruction(_) => middle_assert_invalid_enum_construction,
ResumedAfterDrop(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) => { ResumedAfterDrop(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) => {
middle_assert_async_resume_after_drop inline_fluent!("`async fn` resumed after async drop")
} }
ResumedAfterDrop(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) => { ResumedAfterDrop(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) => {
todo!() todo!()
} }
ResumedAfterDrop(CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) => { ResumedAfterDrop(CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) => {
middle_assert_gen_resume_after_drop inline_fluent!(
"`gen` fn or block cannot be further iterated on after it async dropped"
)
} }
ResumedAfterDrop(CoroutineKind::Coroutine(_)) => { ResumedAfterDrop(CoroutineKind::Coroutine(_)) => {
middle_assert_coroutine_resume_after_drop inline_fluent!("coroutine resumed after async drop")
} }
MisalignedPointerDereference { .. } => middle_assert_misaligned_ptr_deref, MisalignedPointerDereference { .. } => inline_fluent!(
"misaligned pointer dereference: address must be a multiple of {$required} but is {$found}"
),
} }
} }
@ -498,6 +512,7 @@ impl<'tcx> TerminatorKind<'tcx> {
} }
pub use helper::*; pub use helper::*;
use rustc_errors::inline_fluent;
mod helper { mod helper {
use super::*; use super::*;

View file

@ -32,7 +32,8 @@ pub type IsLoadableFromDiskFn<'tcx, Key> =
/// Stores function pointers and other metadata for a particular query. /// Stores function pointers and other metadata for a particular query.
/// ///
/// Used indirectly by query plumbing in `rustc_query_system`, via a trait. /// Used indirectly by query plumbing in `rustc_query_system` via a trait,
/// and also used directly by query plumbing in `rustc_query_impl`.
pub struct QueryVTable<'tcx, C: QueryCache> { pub struct QueryVTable<'tcx, C: QueryCache> {
pub name: &'static str, pub name: &'static str,
pub eval_always: bool, pub eval_always: bool,
@ -52,6 +53,12 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub value_from_cycle_error: pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value, fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String, pub format_value: fn(&C::Value) -> String,
/// Formats a human-readable description of this query and its key, as
/// specified by the `desc` query modifier.
///
/// Used when reporting query cycle errors and similar problems.
pub description_fn: fn(TyCtxt<'tcx>, C::Key) -> String,
} }
pub struct QuerySystemFns { pub struct QuerySystemFns {

View file

@ -9,6 +9,7 @@ use rustc_abi::{
use rustc_error_messages::DiagMessage; use rustc_error_messages::DiagMessage;
use rustc_errors::{ use rustc_errors::{
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
inline_fluent,
}; };
use rustc_hir::LangItem; use rustc_hir::LangItem;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
@ -268,18 +269,25 @@ impl<'tcx> LayoutError<'tcx> {
pub fn diagnostic_message(&self) -> DiagMessage { pub fn diagnostic_message(&self) -> DiagMessage {
use LayoutError::*; use LayoutError::*;
use crate::fluent_generated::*;
match self { match self {
Unknown(_) => middle_layout_unknown, Unknown(_) => inline_fluent!("the type `{$ty}` has an unknown layout"),
SizeOverflow(_) => middle_layout_size_overflow, SizeOverflow(_) => {
InvalidSimd { kind: SimdLayoutError::TooManyLanes(_), .. } => { inline_fluent!("values of the type `{$ty}` are too big for the target architecture")
middle_layout_simd_too_many
} }
InvalidSimd { kind: SimdLayoutError::ZeroLength, .. } => middle_layout_simd_zero_length, InvalidSimd { kind: SimdLayoutError::TooManyLanes(_), .. } => {
TooGeneric(_) => middle_layout_too_generic, inline_fluent!(
NormalizationFailure(_, _) => middle_layout_normalization_failure, "the SIMD type `{$ty}` has more elements than the limit {$max_lanes}"
Cycle(_) => middle_layout_cycle, )
ReferencesError(_) => middle_layout_references_error, }
InvalidSimd { kind: SimdLayoutError::ZeroLength, .. } => {
inline_fluent!("the SIMD type `{$ty}` has zero elements")
}
TooGeneric(_) => inline_fluent!("the type `{$ty}` does not have a fixed layout"),
NormalizationFailure(_, _) => inline_fluent!(
"unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized"
),
Cycle(_) => inline_fluent!("a cycle occurred during layout computation"),
ReferencesError(_) => inline_fluent!("the type has an unknown layout"),
} }
} }

View file

@ -11,7 +11,6 @@ rustc_apfloat = "0.2.0"
rustc_arena = { path = "../rustc_arena", optional = true } rustc_arena = { path = "../rustc_arena", optional = true }
rustc_data_structures = { path = "../rustc_data_structures", optional = true } rustc_data_structures = { path = "../rustc_data_structures", optional = true }
rustc_errors = { path = "../rustc_errors", optional = true } rustc_errors = { path = "../rustc_errors", optional = true }
rustc_fluent_macro = { path = "../rustc_fluent_macro", optional = true }
rustc_hir = { path = "../rustc_hir", optional = true } rustc_hir = { path = "../rustc_hir", optional = true }
rustc_index = { path = "../rustc_index", default-features = false } rustc_index = { path = "../rustc_index", default-features = false }
rustc_macros = { path = "../rustc_macros", optional = true } rustc_macros = { path = "../rustc_macros", optional = true }
@ -36,7 +35,6 @@ rustc = [
"dep:rustc_arena", "dep:rustc_arena",
"dep:rustc_data_structures", "dep:rustc_data_structures",
"dep:rustc_errors", "dep:rustc_errors",
"dep:rustc_fluent_macro",
"dep:rustc_hir", "dep:rustc_hir",
"dep:rustc_macros", "dep:rustc_macros",
"dep:rustc_middle", "dep:rustc_middle",

View file

@ -1,31 +0,0 @@
pattern_analysis_excluside_range_missing_gap = multiple ranges are one apart
.label = this range doesn't match `{$gap}` because `..` is an exclusive range
.suggestion = use an inclusive range instead
pattern_analysis_excluside_range_missing_max = exclusive range missing `{$max}`
.label = this range doesn't match `{$max}` because `..` is an exclusive range
.suggestion = use an inclusive range instead
pattern_analysis_mixed_deref_pattern_constructors = mix of deref patterns and normal constructors
.deref_pattern_label = matches on the result of dereferencing `{$smart_pointer_ty}`
.normal_constructor_label = matches directly on `{$smart_pointer_ty}`
pattern_analysis_non_exhaustive_omitted_pattern = some variants are not matched explicitly
.help = ensure that all variants are matched explicitly by adding the suggested match arms
.note = the matched value is of type `{$scrut_ty}` and the `non_exhaustive_omitted_patterns` attribute was found
pattern_analysis_non_exhaustive_omitted_pattern_lint_on_arm = the lint level must be set on the whole match
.help = it no longer has any effect to set the lint level on an individual match arm
.label = remove this attribute
.suggestion = set the lint level on the whole match
pattern_analysis_overlapping_range_endpoints = multiple patterns overlap on their endpoints
.label = ... with this range
.note = you likely meant to write mutually exclusive ranges
pattern_analysis_uncovered = {$count ->
[1] pattern `{$witness_1}`
[2] patterns `{$witness_1}` and `{$witness_2}`
[3] patterns `{$witness_1}`, `{$witness_2}` and `{$witness_3}`
*[other] patterns `{$witness_1}`, `{$witness_2}`, `{$witness_3}` and {$remainder} more
} not covered

View file

@ -6,7 +6,14 @@ use rustc_span::Span;
use crate::rustc::{RustcPatCtxt, WitnessPat}; use crate::rustc::{RustcPatCtxt, WitnessPat};
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
#[label(pattern_analysis_uncovered)] #[label(
"{$count ->
[1] pattern `{$witness_1}`
[2] patterns `{$witness_1}` and `{$witness_2}`
[3] patterns `{$witness_1}`, `{$witness_2}` and `{$witness_3}`
*[other] patterns `{$witness_1}`, `{$witness_2}`, `{$witness_3}` and {$remainder} more
} not covered"
)]
pub struct Uncovered { pub struct Uncovered {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -40,10 +47,10 @@ impl Uncovered {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(pattern_analysis_overlapping_range_endpoints)] #[diag("multiple patterns overlap on their endpoints")]
#[note] #[note("you likely meant to write mutually exclusive ranges")]
pub struct OverlappingRangeEndpoints { pub struct OverlappingRangeEndpoints {
#[label] #[label("... with this range")]
pub range: Span, pub range: Span,
#[subdiagnostic] #[subdiagnostic]
pub overlap: Vec<Overlap>, pub overlap: Vec<Overlap>,
@ -66,10 +73,14 @@ impl Subdiagnostic for Overlap {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(pattern_analysis_excluside_range_missing_max)] #[diag("exclusive range missing `{$max}`")]
pub struct ExclusiveRangeMissingMax { pub struct ExclusiveRangeMissingMax {
#[label] #[label("this range doesn't match `{$max}` because `..` is an exclusive range")]
#[suggestion(code = "{suggestion}", applicability = "maybe-incorrect")] #[suggestion(
"use an inclusive range instead",
code = "{suggestion}",
applicability = "maybe-incorrect"
)]
/// This is an exclusive range that looks like `lo..max` (i.e. doesn't match `max`). /// This is an exclusive range that looks like `lo..max` (i.e. doesn't match `max`).
pub first_range: Span, pub first_range: Span,
/// Suggest `lo..=max` instead. /// Suggest `lo..=max` instead.
@ -78,10 +89,14 @@ pub struct ExclusiveRangeMissingMax {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(pattern_analysis_excluside_range_missing_gap)] #[diag("multiple ranges are one apart")]
pub struct ExclusiveRangeMissingGap { pub struct ExclusiveRangeMissingGap {
#[label] #[label("this range doesn't match `{$gap}` because `..` is an exclusive range")]
#[suggestion(code = "{suggestion}", applicability = "maybe-incorrect")] #[suggestion(
"use an inclusive range instead",
code = "{suggestion}",
applicability = "maybe-incorrect"
)]
/// This is an exclusive range that looks like `lo..gap` (i.e. doesn't match `gap`). /// This is an exclusive range that looks like `lo..gap` (i.e. doesn't match `gap`).
pub first_range: Span, pub first_range: Span,
pub gap: String, // a printed pattern pub gap: String, // a printed pattern
@ -113,9 +128,11 @@ impl Subdiagnostic for GappedRange {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(pattern_analysis_non_exhaustive_omitted_pattern)] #[diag("some variants are not matched explicitly")]
#[help] #[help("ensure that all variants are matched explicitly by adding the suggested match arms")]
#[note] #[note(
"the matched value is of type `{$scrut_ty}` and the `non_exhaustive_omitted_patterns` attribute was found"
)]
pub(crate) struct NonExhaustiveOmittedPattern<'tcx> { pub(crate) struct NonExhaustiveOmittedPattern<'tcx> {
pub scrut_ty: Ty<'tcx>, pub scrut_ty: Ty<'tcx>,
#[subdiagnostic] #[subdiagnostic]
@ -123,25 +140,29 @@ pub(crate) struct NonExhaustiveOmittedPattern<'tcx> {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(pattern_analysis_non_exhaustive_omitted_pattern_lint_on_arm)] #[diag("the lint level must be set on the whole match")]
#[help] #[help("it no longer has any effect to set the lint level on an individual match arm")]
pub(crate) struct NonExhaustiveOmittedPatternLintOnArm { pub(crate) struct NonExhaustiveOmittedPatternLintOnArm {
#[label] #[label("remove this attribute")]
pub lint_span: Span, pub lint_span: Span,
#[suggestion(code = "#[{lint_level}({lint_name})]\n", applicability = "maybe-incorrect")] #[suggestion(
"set the lint level on the whole match",
code = "#[{lint_level}({lint_name})]\n",
applicability = "maybe-incorrect"
)]
pub suggest_lint_on_match: Option<Span>, pub suggest_lint_on_match: Option<Span>,
pub lint_level: &'static str, pub lint_level: &'static str,
pub lint_name: &'static str, pub lint_name: &'static str,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(pattern_analysis_mixed_deref_pattern_constructors)] #[diag("mix of deref patterns and normal constructors")]
pub(crate) struct MixedDerefPatternConstructors<'tcx> { pub(crate) struct MixedDerefPatternConstructors<'tcx> {
#[primary_span] #[primary_span]
pub spans: Vec<Span>, pub spans: Vec<Span>,
pub smart_pointer_ty: Ty<'tcx>, pub smart_pointer_ty: Ty<'tcx>,
#[label(pattern_analysis_deref_pattern_label)] #[label("matches on the result of dereferencing `{$smart_pointer_ty}`")]
pub deref_pattern_label: Span, pub deref_pattern_label: Span,
#[label(pattern_analysis_normal_constructor_label)] #[label("matches directly on `{$smart_pointer_ty}`")]
pub normal_constructor_label: Span, pub normal_constructor_label: Span,
} }

View file

@ -19,9 +19,6 @@ pub mod pat_column;
pub mod rustc; pub mod rustc;
pub mod usefulness; pub mod usefulness;
#[cfg(feature = "rustc")]
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
use std::fmt; use std::fmt;
pub use rustc_index::{Idx, IndexVec}; // re-exported to avoid rustc_index version issues pub use rustc_index::{Idx, IndexVec}; // re-exported to avoid rustc_index version issues

View file

@ -9,17 +9,18 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_data_structures::unord::UnordMap; use rustc_data_structures::unord::UnordMap;
use rustc_hashes::Hash64; use rustc_hashes::Hash64;
use rustc_hir::def_id::DefId;
use rustc_hir::limit::Limit; use rustc_hir::limit::Limit;
use rustc_index::Idx; use rustc_index::Idx;
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::dep_graph::{ use rustc_middle::dep_graph::{
self, DepContext, DepKind, DepKindVTable, DepNode, DepNodeIndex, SerializedDepNodeIndex, self, DepContext, DepKindVTable, DepNode, DepNodeIndex, SerializedDepNodeIndex, dep_kinds,
dep_kinds,
}; };
use rustc_middle::query::Key; use rustc_middle::query::Key;
use rustc_middle::query::on_disk_cache::{ use rustc_middle::query::on_disk_cache::{
AbsoluteBytePos, CacheDecoder, CacheEncoder, EncodedDepNodeIndex, AbsoluteBytePos, CacheDecoder, CacheEncoder, EncodedDepNodeIndex,
}; };
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::ty::codec::TyEncoder; use rustc_middle::ty::codec::TyEncoder;
use rustc_middle::ty::print::with_reduced_queries; use rustc_middle::ty::print::with_reduced_queries;
use rustc_middle::ty::tls::{self, ImplicitCtxt}; use rustc_middle::ty::tls::{self, ImplicitCtxt};
@ -312,15 +313,14 @@ macro_rules! should_ever_cache_on_disk {
}; };
} }
fn mk_query_stack_frame_extra<'tcx, K: Key + Copy + 'tcx>( /// The deferred part of a deferred query stack frame.
(tcx, key, kind, name, do_describe): ( fn mk_query_stack_frame_extra<'tcx, Cache>(
TyCtxt<'tcx>, (tcx, vtable, key): (TyCtxt<'tcx>, &'tcx QueryVTable<'tcx, Cache>, Cache::Key),
K, ) -> QueryStackFrameExtra
DepKind, where
&'static str, Cache: QueryCache,
fn(TyCtxt<'tcx>, K) -> String, Cache::Key: Key,
), {
) -> QueryStackFrameExtra {
let def_id = key.key_as_def_id(); let def_id = key.key_as_def_id();
// If reduced queries are requested, we may be printing a query stack due // If reduced queries are requested, we may be printing a query stack due
@ -328,13 +328,13 @@ fn mk_query_stack_frame_extra<'tcx, K: Key + Copy + 'tcx>(
let reduce_queries = with_reduced_queries(); let reduce_queries = with_reduced_queries();
// Avoid calling queries while formatting the description // Avoid calling queries while formatting the description
let description = ty::print::with_no_queries!(do_describe(tcx, key)); let description = ty::print::with_no_queries!((vtable.description_fn)(tcx, key));
let description = if tcx.sess.verbose_internals() { let description = if tcx.sess.verbose_internals() {
format!("{description} [{name:?}]") format!("{description} [{name:?}]", name = vtable.name)
} else { } else {
description description
}; };
let span = if kind == dep_graph::dep_kinds::def_span || reduce_queries { let span = if vtable.dep_kind == dep_graph::dep_kinds::def_span || reduce_queries {
// The `def_span` query is used to calculate `default_span`, // The `def_span` query is used to calculate `default_span`,
// so exit to avoid infinite recursion. // so exit to avoid infinite recursion.
None None
@ -342,7 +342,7 @@ fn mk_query_stack_frame_extra<'tcx, K: Key + Copy + 'tcx>(
Some(key.default_span(tcx)) Some(key.default_span(tcx))
}; };
let def_kind = if kind == dep_graph::dep_kinds::def_kind || reduce_queries { let def_kind = if vtable.dep_kind == dep_graph::dep_kinds::def_kind || reduce_queries {
// Try to avoid infinite recursion. // Try to avoid infinite recursion.
None None
} else { } else {
@ -351,17 +351,16 @@ fn mk_query_stack_frame_extra<'tcx, K: Key + Copy + 'tcx>(
QueryStackFrameExtra::new(description, span, def_kind) QueryStackFrameExtra::new(description, span, def_kind)
} }
pub(crate) fn create_query_frame< pub(crate) fn create_deferred_query_stack_frame<'tcx, Cache>(
'tcx,
K: Copy + DynSend + DynSync + Key + for<'a> HashStable<StableHashingContext<'a>> + 'tcx,
>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
do_describe: fn(TyCtxt<'tcx>, K) -> String, vtable: &'tcx QueryVTable<'tcx, Cache>,
key: K, key: Cache::Key,
kind: DepKind, ) -> QueryStackFrame<QueryStackDeferred<'tcx>>
name: &'static str, where
) -> QueryStackFrame<QueryStackDeferred<'tcx>> { Cache: QueryCache,
let def_id = key.key_as_def_id(); Cache::Key: Key + DynSend + DynSync + for<'a> HashStable<StableHashingContext<'a>> + 'tcx,
{
let kind = vtable.dep_kind;
let hash = tcx.with_stable_hashing_context(|mut hcx| { let hash = tcx.with_stable_hashing_context(|mut hcx| {
let mut hasher = StableHasher::new(); let mut hasher = StableHasher::new();
@ -369,11 +368,11 @@ pub(crate) fn create_query_frame<
key.hash_stable(&mut hcx, &mut hasher); key.hash_stable(&mut hcx, &mut hasher);
hasher.finish::<Hash64>() hasher.finish::<Hash64>()
}); });
let def_id_for_ty_in_cycle = key.def_id_for_ty_in_cycle();
let info = let def_id: Option<DefId> = key.key_as_def_id();
QueryStackDeferred::new((tcx, key, kind, name, do_describe), mk_query_stack_frame_extra); let def_id_for_ty_in_cycle: Option<DefId> = key.def_id_for_ty_in_cycle();
let info = QueryStackDeferred::new((tcx, vtable, key), mk_query_stack_frame_extra);
QueryStackFrame::new(info, kind, hash, def_id, def_id_for_ty_in_cycle) QueryStackFrame::new(info, kind, hash, def_id, def_id_for_ty_in_cycle)
} }
@ -697,6 +696,7 @@ macro_rules! define_queries {
}, },
hash_result: hash_result!([$($modifiers)*][queries::$name::Value<'tcx>]), hash_result: hash_result!([$($modifiers)*][queries::$name::Value<'tcx>]),
format_value: |value| format!("{:?}", erase::restore_val::<queries::$name::Value<'tcx>>(*value)), format_value: |value| format!("{:?}", erase::restore_val::<queries::$name::Value<'tcx>>(*value)),
description_fn: $crate::queries::_description_fns::$name,
} }
} }
@ -742,10 +742,9 @@ macro_rules! define_queries {
qmap: &mut QueryMap<'tcx>, qmap: &mut QueryMap<'tcx>,
require_complete: bool, require_complete: bool,
) -> Option<()> { ) -> Option<()> {
let make_frame = |tcx, key| { let make_frame = |tcx: TyCtxt<'tcx>, key| {
let kind = rustc_middle::dep_graph::dep_kinds::$name; let vtable = &tcx.query_system.query_vtables.$name;
let name = stringify!($name); $crate::plumbing::create_deferred_query_stack_frame(tcx, vtable, key)
$crate::plumbing::create_query_frame(tcx, queries::descs::$name, key, kind, name)
}; };
// Call `gather_active_jobs_inner` to do the actual work. // Call `gather_active_jobs_inner` to do the actual work.

View file

@ -1432,8 +1432,7 @@ impl EarlyDiagCtxt {
fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> { fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
// FIXME(#100717): early errors aren't translated at the moment, so this is fine, but it will // FIXME(#100717): early errors aren't translated at the moment, so this is fine, but it will
// need to reference every crate that might emit an early error for translation to work. // need to reference every crate that might emit an early error for translation to work.
let translator = let translator = Translator::with_fallback_bundle(vec![], false);
Translator::with_fallback_bundle(vec![rustc_errors::DEFAULT_LOCALE_RESOURCE], false);
let emitter: Box<DynEmitter> = match output { let emitter: Box<DynEmitter> = match output {
config::ErrorOutputType::HumanReadable { kind, color_config } => match kind { config::ErrorOutputType::HumanReadable { kind, color_config } => match kind {
HumanReadableErrorType { short, unicode } => Box::new( HumanReadableErrorType { short, unicode } => Box::new(

View file

@ -169,15 +169,15 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
pub const SIG_DFL: u8 = 3; pub const SIG_DFL: u8 = 3;
} }
let (sigpipe_attr_specified, handler) = match sigpipe { let (on_broken_pipe_used, handler) = match sigpipe {
sigpipe::DEFAULT => (false, Some(libc::SIG_IGN)), sigpipe::DEFAULT => (false, Some(libc::SIG_IGN)),
sigpipe::INHERIT => (true, None), sigpipe::INHERIT => (true, None),
sigpipe::SIG_IGN => (true, Some(libc::SIG_IGN)), sigpipe::SIG_IGN => (true, Some(libc::SIG_IGN)),
sigpipe::SIG_DFL => (true, Some(libc::SIG_DFL)), sigpipe::SIG_DFL => (true, Some(libc::SIG_DFL)),
_ => unreachable!(), _ => unreachable!(),
}; };
if sigpipe_attr_specified { if on_broken_pipe_used {
ON_BROKEN_PIPE_FLAG_USED.store(true, crate::sync::atomic::Ordering::Relaxed); ON_BROKEN_PIPE_USED.store(true, crate::sync::atomic::Ordering::Relaxed);
} }
if let Some(handler) = handler { if let Some(handler) = handler {
rtassert!(signal(libc::SIGPIPE, handler) != libc::SIG_ERR); rtassert!(signal(libc::SIGPIPE, handler) != libc::SIG_ERR);
@ -199,7 +199,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
target_os = "vxworks", target_os = "vxworks",
target_os = "vita", target_os = "vita",
)))] )))]
static ON_BROKEN_PIPE_FLAG_USED: crate::sync::atomic::Atomic<bool> = static ON_BROKEN_PIPE_USED: crate::sync::atomic::Atomic<bool> =
crate::sync::atomic::AtomicBool::new(false); crate::sync::atomic::AtomicBool::new(false);
#[cfg(not(any( #[cfg(not(any(
@ -211,8 +211,8 @@ static ON_BROKEN_PIPE_FLAG_USED: crate::sync::atomic::Atomic<bool> =
target_os = "vita", target_os = "vita",
target_os = "nuttx", target_os = "nuttx",
)))] )))]
pub(crate) fn on_broken_pipe_flag_used() -> bool { pub(crate) fn on_broken_pipe_used() -> bool {
ON_BROKEN_PIPE_FLAG_USED.load(crate::sync::atomic::Ordering::Relaxed) ON_BROKEN_PIPE_USED.load(crate::sync::atomic::Ordering::Relaxed)
} }
// SAFETY: must be called only once during runtime cleanup. // SAFETY: must be called only once during runtime cleanup.

View file

@ -356,7 +356,7 @@ impl Command {
// If -Zon-broken-pipe is not used, reset SIGPIPE to SIG_DFL for backward compatibility. // If -Zon-broken-pipe is not used, reset SIGPIPE to SIG_DFL for backward compatibility.
// //
// -Zon-broken-pipe is an opportunity to change the default here. // -Zon-broken-pipe is an opportunity to change the default here.
if !crate::sys::pal::on_broken_pipe_flag_used() { if !crate::sys::pal::on_broken_pipe_used() {
#[cfg(target_os = "android")] // see issue #88585 #[cfg(target_os = "android")] // see issue #88585
{ {
let mut action: libc::sigaction = mem::zeroed(); let mut action: libc::sigaction = mem::zeroed();
@ -455,7 +455,7 @@ impl Command {
use core::sync::atomic::{Atomic, AtomicU8, Ordering}; use core::sync::atomic::{Atomic, AtomicU8, Ordering};
use crate::mem::MaybeUninit; use crate::mem::MaybeUninit;
use crate::sys::{self, cvt_nz, on_broken_pipe_flag_used}; use crate::sys::{self, cvt_nz, on_broken_pipe_used};
if self.get_gid().is_some() if self.get_gid().is_some()
|| self.get_uid().is_some() || self.get_uid().is_some()
@ -731,7 +731,7 @@ impl Command {
// If -Zon-broken-pipe is not used, reset SIGPIPE to SIG_DFL for backward compatibility. // If -Zon-broken-pipe is not used, reset SIGPIPE to SIG_DFL for backward compatibility.
// //
// -Zon-broken-pipe is an opportunity to change the default here. // -Zon-broken-pipe is an opportunity to change the default here.
if !on_broken_pipe_flag_used() { if !on_broken_pipe_used() {
let mut default_set = MaybeUninit::<libc::sigset_t>::uninit(); let mut default_set = MaybeUninit::<libc::sigset_t>::uninit();
cvt(sigemptyset(default_set.as_mut_ptr()))?; cvt(sigemptyset(default_set.as_mut_ptr()))?;
cvt(sigaddset(default_set.as_mut_ptr(), libc::SIGPIPE))?; cvt(sigaddset(default_set.as_mut_ptr(), libc::SIGPIPE))?;

View file

@ -359,11 +359,11 @@ docker \
rust-ci \ rust-ci \
"${command[@]}" "${command[@]}"
if isCI; then
cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}"
fi
if [ -f /.dockerenv ]; then if [ -f /.dockerenv ]; then
rm -rf $objdir rm -rf $objdir
docker cp checkout:/checkout/obj $objdir docker cp checkout:/checkout/obj $objdir
fi fi
if isCI; then
cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}"
fi