mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
a0215d8e46
Fundamentally, we have *three* disjoint categories of functions: 1. const-stable functions 2. private/unstable functions that are meant to be callable from const-stable functions 3. functions that can make use of unstable const features This PR implements the following system: - `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions. - `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category. - `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls. Also, several holes in recursive const stability checking are being closed. There's still one potential hole that is hard to avoid, which is when MIR building automatically inserts calls to a particular function in stable functions -- which happens in the panic machinery. Those need to *not* be `rustc_const_unstable` (or manually get a `rustc_const_stable_indirect`) to be sure they follow recursive const stability. But that's a fairly rare and special case so IMO it's fine. The net effect of this is that a `#[unstable]` or unmarked function can be constified simply by marking it as `const fn`, and it will then be const-callable from stable `const fn` and subject to recursive const stability requirements. If it is publicly reachable (which implies it cannot be unmarked), it will be const-unstable under the same feature gate. Only if the function ever becomes `#[stable]` does it need a `#[rustc_const_unstable]` or `#[rustc_const_stable]` marker to decide if this should also imply const-stability. Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to use unstable const lang features (including intrinsics), or (b) `#[stable]` functions that are not yet intended to be const-stable. Adding `#[rustc_const_stable]` is only needed for functions that are actually meant to be directly callable from stable const code. `#[rustc_const_stable_indirect]` is used to mark intrinsics as const-callable and for `#[rustc_const_unstable]` functions that are actually called from other, exposed-on-stable `const fn`. No other attributes are required.
125 lines
4.0 KiB
Plaintext
125 lines
4.0 KiB
Plaintext
attr_cfg_predicate_identifier =
|
|
`cfg` predicate key must be an identifier
|
|
|
|
attr_deprecated_item_suggestion =
|
|
suggestions on deprecated items are unstable
|
|
.help = add `#![feature(deprecated_suggestion)]` to the crate root
|
|
.note = see #94785 for more details
|
|
|
|
attr_expected_one_cfg_pattern =
|
|
expected 1 cfg-pattern
|
|
|
|
attr_expected_single_version_literal =
|
|
expected single version literal
|
|
|
|
attr_expected_version_literal =
|
|
expected a version literal
|
|
|
|
attr_expects_feature_list =
|
|
`{$name}` expects a list of feature names
|
|
|
|
attr_expects_features =
|
|
`{$name}` expects feature names
|
|
|
|
attr_incorrect_meta_item =
|
|
incorrect meta item
|
|
|
|
attr_incorrect_repr_format_align_one_arg =
|
|
incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
|
|
|
|
attr_incorrect_repr_format_expect_literal_integer =
|
|
incorrect `repr(align)` attribute format: `align` expects a literal integer as argument
|
|
|
|
attr_incorrect_repr_format_generic =
|
|
incorrect `repr({$repr_arg})` attribute format
|
|
.suggestion = use parentheses instead
|
|
|
|
attr_incorrect_repr_format_packed_expect_integer =
|
|
incorrect `repr(packed)` attribute format: `packed` expects a literal integer as argument
|
|
|
|
attr_incorrect_repr_format_packed_one_or_zero_arg =
|
|
incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all
|
|
|
|
attr_invalid_issue_string =
|
|
`issue` must be a non-zero numeric string or "none"
|
|
.must_not_be_zero = `issue` must not be "0", use "none" instead
|
|
.empty = cannot parse integer from empty string
|
|
.invalid_digit = invalid digit found in string
|
|
.pos_overflow = number too large to fit in target type
|
|
.neg_overflow = number too small to fit in target type
|
|
|
|
attr_invalid_predicate =
|
|
invalid predicate `{$predicate}`
|
|
|
|
attr_invalid_repr_align_need_arg =
|
|
invalid `repr(align)` attribute: `align` needs an argument
|
|
.suggestion = supply an argument here
|
|
|
|
attr_invalid_repr_generic =
|
|
invalid `repr({$repr_arg})` attribute: {$error_part}
|
|
|
|
attr_invalid_repr_hint_no_paren =
|
|
invalid representation hint: `{$name}` does not take a parenthesized argument list
|
|
|
|
attr_invalid_repr_hint_no_value =
|
|
invalid representation hint: `{$name}` does not take a value
|
|
|
|
attr_invalid_since =
|
|
'since' must be a Rust version number, such as "1.31.0"
|
|
|
|
attr_missing_feature =
|
|
missing 'feature'
|
|
|
|
attr_missing_issue =
|
|
missing 'issue'
|
|
|
|
attr_missing_note =
|
|
missing 'note'
|
|
|
|
attr_missing_since =
|
|
missing 'since'
|
|
|
|
attr_multiple_item =
|
|
multiple '{$item}' items
|
|
|
|
attr_multiple_stability_levels =
|
|
multiple stability levels
|
|
|
|
attr_non_ident_feature =
|
|
'feature' is not an identifier
|
|
|
|
attr_rustc_allowed_unstable_pairing =
|
|
`rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
|
|
|
|
attr_rustc_const_stable_indirect_pairing =
|
|
`const_stable_indirect` attribute does not make sense on `rustc_const_stable` function, its behavior is already implied
|
|
|
|
attr_rustc_promotable_pairing =
|
|
`rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute
|
|
|
|
attr_soft_no_args =
|
|
`soft` should not have any arguments
|
|
|
|
attr_unknown_meta_item =
|
|
unknown meta item '{$item}'
|
|
.label = expected one of {$expected}
|
|
|
|
attr_unknown_version_literal =
|
|
unknown version literal format, assuming it refers to a future version
|
|
|
|
attr_unstable_cfg_target_compact =
|
|
compact `cfg(target(..))` is experimental and subject to change
|
|
|
|
attr_unsupported_literal_cfg_boolean =
|
|
literal in `cfg` predicate value must be a boolean
|
|
attr_unsupported_literal_cfg_string =
|
|
literal in `cfg` predicate value must be a string
|
|
attr_unsupported_literal_deprecated_kv_pair =
|
|
item in `deprecated` must be a key/value pair
|
|
attr_unsupported_literal_deprecated_string =
|
|
literal in `deprecated` value must be a string
|
|
attr_unsupported_literal_generic =
|
|
unsupported literal
|
|
attr_unsupported_literal_suggestion =
|
|
consider removing the prefix
|