mirror of
https://github.com/rust-lang/rust.git
synced 2025-09-30 00:03:49 +00:00

rustc_intrinsic: support functions without body We synthesize a HIR body `loop {}` but such bodyless intrinsics. Most of the diff is due to turning `ItemKind::Fn` into a brace (named-field) enum variant, because it carries a `bool`-typed field now. This is to remember whether the function has a body. MIR building panics to avoid ever translating the fake `loop {}` body, and the intrinsic logic uses the lack of a body to implicitly mark that intrinsic as must-be-overridden. I first tried actually having no body rather than generating the fake body, but there's a *lot* of code that assumes that all function items have HIR and MIR, so this didn't work very well. Then I noticed that even `rustc_intrinsic_must_be_overridden` intrinsics have MIR generated (they are filled with an `Unreachable` terminator) so I guess I am not the first to discover this. ;) r? `@oli-obk`
12 lines
312 B
Plaintext
12 lines
312 B
Plaintext
error: must be overridden by codegen backend, but isn't
|
|
--> $DIR/not-overridden.rs:15:14
|
|
|
|
|
LL | unsafe { const_deallocate(std::ptr::null_mut(), 0, 0) }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
query stack during panic:
|
|
end of query stack
|
|
error: aborting due to 1 previous error
|
|
|