Reject unsupported naked functions
Transition unsupported naked functions future incompatibility lint into an error: * Naked functions must contain a single inline assembly block. Introduced as future incompatibility lint in 1.50 #79653. Change into an error fixes a soundness issue described in #32489. * Naked functions must not use any forms of inline attribute. Introduced as future incompatibility lint in 1.56 #87652.
This commit is contained in:
parent
84e918971d
commit
888332fee4
9 changed files with 182 additions and 295 deletions
|
@ -486,6 +486,7 @@ E0783: include_str!("./error_codes/E0783.md"),
|
|||
E0784: include_str!("./error_codes/E0784.md"),
|
||||
E0785: include_str!("./error_codes/E0785.md"),
|
||||
E0786: include_str!("./error_codes/E0786.md"),
|
||||
E0787: include_str!("./error_codes/E0787.md"),
|
||||
;
|
||||
// E0006, // merged with E0005
|
||||
// E0008, // cannot bind by-move into a pattern guard
|
||||
|
|
28
compiler/rustc_error_codes/src/error_codes/E0787.md
Normal file
28
compiler/rustc_error_codes/src/error_codes/E0787.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
An unsupported naked function definition.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0787
|
||||
#![feature(naked_functions)]
|
||||
|
||||
#[naked]
|
||||
pub extern "C" fn f() -> u32 {
|
||||
42
|
||||
}
|
||||
```
|
||||
|
||||
The naked functions must be defined using a single inline assembly
|
||||
block.
|
||||
|
||||
The execution must never fall through past the end of the assembly
|
||||
code so the block must use `noreturn` option. The asm block can also
|
||||
use `att_syntax` and `raw` options, but others options are not allowed.
|
||||
|
||||
The asm block must not contain any operands other than `const` and
|
||||
`sym`.
|
||||
|
||||
### Additional information
|
||||
|
||||
For more information, please see [RFC 2972].
|
||||
|
||||
[RFC 2972]: https://github.com/rust-lang/rfcs/blob/master/text/2972-constrained-naked.md
|
Loading…
Add table
Add a link
Reference in a new issue