Skip to content

Commit 34f678c

Browse files
committed
also mention inline assembly const operands
1 parent 4641e23 commit 34f678c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

promotion.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ non-`Copy` types to be initialized idiomatically, for example
3535

3636
[RFC 2203]: https://github.com/rust-lang/rfcs/blob/master/text/2203-const-repeat-expr.md
3737

38-
### `#[rustc_args_required_const(...)]`
38+
### `#[rustc_args_required_const(...)]` and inline assembly `const` operands
3939

4040
Additionally, some platform intrinsics require certain parameters to be
4141
immediates (known at compile-time). We use the `#[rustc_args_required_const]`
@@ -44,6 +44,9 @@ attribute, introduced in
4444
specify these parameters and (aggressively, see below) try to promote the
4545
corresponding arguments.
4646

47+
Similarly, inline assembly has `const` operands, which are treated the same way
48+
as `rustc_args_required_const` arguments.
49+
4750
### Promotion inside `const` and `static`
4851

4952
Lifetime extension is also responsible for making code like this work:
@@ -96,7 +99,7 @@ declaration. We can thus be less conservative. This is called *explicit*
9699
promotion.
97100

98101
Currently, the following are considered explicit promotion contexts:
99-
* `#[rustc_args_required_const]` arguments
102+
* `#[rustc_args_required_const]` arguments and inline assembly `const` operands
100103
* lifetime extension in the bodies of `const` and `static` items and array lengths
101104
* the bodies of `const fn` -- but this is not justified by the above discussion; since `const fn` can be runtime-evaluated, the concerns about introducing hard errors where there would be none apply for `const fn` in exactly the same way as for `fn`, but this was overlooked when implementing the checks
102105

0 commit comments

Comments
 (0)