1
Fork 0
rust/compiler/rustc_hir/src
Amanieu d'Antras 56074b5231 Rewrite implementation of #[alloc_error_handler]
The new implementation doesn't use weak lang items and instead changes
`#[alloc_error_handler]` to an attribute macro just like
`#[global_allocator]`.

The attribute will generate the `__rg_oom` function which is called by
the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom`
function is defined in any crate then the compiler shim will call
`__rdl_oom` in the alloc crate which will simply panic.

This also fixes link errors with `-C link-dead-code` with
`default_alloc_error_handler`: `__rg_oom` was previously defined in the
alloc crate and would attempt to reference the `oom` lang item, even if
it didn't exist. This worked as long as `__rg_oom` was excluded from
linking since it was not called.

This is a prerequisite for the stabilization of
`default_alloc_error_handler` (#102318).
2022-10-31 16:32:57 +00:00
..
arena.rs Add an indirection for closures in hir::ExprKind 2022-07-12 21:00:13 +04:00
def.rs rustc_hir: Less error-prone methods for accessing PartialRes resolution 2022-10-11 09:04:52 +04:00
def_path_hash_map.rs Use on-disk-hash-table format for DefPathHashMap in hir::definitions. 2021-09-14 13:54:41 +02:00
definitions.rs Always import all tracing macros for the entire crate instead of piecemeal by module 2022-09-01 14:54:27 +00:00
diagnostic_items.rs Introduce get_diagnostic_name 2021-10-06 08:40:28 -05:00
errors.rs have LangItemError derive everything LangItem does 2022-08-25 11:06:45 -06:00
hir.rs Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
hir_id.rs separate definitions and HIR owners 2022-09-24 23:21:19 +09:00
intravisit.rs Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
lang_items.rs Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
lib.rs Cleanup weak lang items 2022-10-29 16:04:10 -05:00
pat_util.rs Introduce DotDotPos. 2022-09-08 15:25:50 +10:00
stable_hash_impls.rs Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
target.rs Handle generic parameters. 2022-09-09 01:31:46 +00:00
tests.rs Revert "Revert "Fix test"" 2021-07-06 11:28:06 +02:00
weak_lang_items.rs Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00