rust/compiler
Jubilee Young 2edf6c8784 Default repr(C) enums to c_int size
This is what ISO C strongly implies this is correct, and
many processor-specific ABIs imply or mandate this size, so
"everyone" (LLVM, gcc...) defaults to emitting enums this way.
However, this is by no means guaranteed by ISO C,
and the bare-metal Arm targets show it can be overridden,
which rustc supports via `c-enum-min-bits` in a target.json.

The override is a flag named `-fshort-enums` in clang and gcc,
but introducing a CLI flag is probably unnecessary for rustc.
This flag can be used by non-Arm microcontroller targets,
like AVR and MSP430, but it is not enabled for them by default.
Rust programmers who know the size of a target's enums
can use explicit reprs, which also lets them match C23 code.

This change is most relevant to 16-bit targets: AVR and MSP430.
Most of rustc's targets use 32-bit ints, but ILP64 does exist.
Regardless, rustc should now correctly handle enums for
both very small and very large targets.

Thanks to William for confirming MSP430 behavior,
and to Waffle for better style and no-core size_of asserts.

Co-authored-by: William D. Jones <thor0505@comcast.net>
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-02-16 15:06:17 -08:00
..
rustc rustc: Use unix_sigpipe instead of rustc_driver::set_sigpipe_handler 2022-10-02 17:49:36 +02:00
rustc_abi Default repr(C) enums to c_int size 2023-02-16 15:06:17 -08:00
rustc_apfloat compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
rustc_arena compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
rustc_ast parse const closures 2023-01-12 02:28:37 +00:00
rustc_ast_lowering Auto merge of #106776 - oli-obk:om_nom_nom_nom_nom, r=cjgillot 2023-01-13 13:57:21 +00:00
rustc_ast_passes gate const closures 2023-01-12 02:28:37 +00:00
rustc_ast_pretty parse const closures 2023-01-12 02:28:37 +00:00
rustc_attr Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_baked_icu_data Update crate documentation of rustc_baked_icu_data crate 2022-11-18 14:46:36 -08:00
rustc_borrowck Rollup merge of #106940 - oli-obk:tait_error, r=compiler-errors 2023-01-16 20:29:39 +01:00
rustc_builtin_macros Update format.rs 2023-01-02 15:51:54 +05:30
rustc_codegen_cranelift Change src/test to tests in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00
rustc_codegen_gcc Change src/test to tests in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00
rustc_codegen_llvm Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum 2023-01-14 08:33:09 +00:00
rustc_codegen_ssa Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum 2023-01-14 08:33:09 +00:00
rustc_const_eval fix fmt and bless 2023-01-12 02:28:38 +00:00
rustc_data_structures Harden the pre-tyctxt query system against accidental recomputation 2023-01-12 09:26:28 +00:00
rustc_driver Rollup merge of #104645 - yukiomoto:log-backtrace-option, r=oli-obk 2023-01-13 19:16:41 +01:00
rustc_error_codes Improve a TAIT error and add an error code plus documentation 2023-01-16 16:54:14 +00:00
rustc_error_messages Improve a TAIT error and add an error code plus documentation 2023-01-16 16:54:14 +00:00
rustc_errors Rollup merge of #106427 - mejrs:translation_errors, r=davidtwco 2023-01-11 17:30:54 +01:00
rustc_expand Update rental hack to work with remapped paths. 2023-01-13 20:36:03 +00:00
rustc_feature Auto merge of #106004 - fee1-dead-contrib:const-closures, r=oli-obk 2023-01-13 05:04:48 +00:00
rustc_fs_util Remove useless borrows and derefs 2022-12-01 17:34:43 +00:00
rustc_graphviz Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_hir parse const closures 2023-01-12 02:28:37 +00:00
rustc_hir_analysis Remove bound_{explicit,}_item_bounds 2023-01-15 15:36:06 +00:00
rustc_hir_pretty parse const closures 2023-01-12 02:28:37 +00:00
rustc_hir_typeck Auto merge of #106395 - compiler-errors:rework-predicates, r=eholk 2023-01-16 05:55:59 +00:00
rustc_incremental rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
rustc_index Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_infer Remove bound_{explicit,}_item_bounds 2023-01-15 15:36:06 +00:00
rustc_interface Rollup merge of #106678 - Veykril:proc-macro-panic-abort, r=eholk 2023-01-13 19:16:43 +01:00
rustc_lexer Recover fn keyword as Fn trait in bounds 2022-12-27 06:14:46 +00:00
rustc_lint Rollup merge of #106906 - matthiaskrgr:clone, r=Nilstrieb 2023-01-15 21:17:35 +01:00
rustc_lint_defs Bump IMPLIED_BOUNDS_ENTAILMENT to Deny + ReportNow 2023-01-12 20:44:54 +00:00
rustc_llvm rustc_llvm: replace llvm::makeArrayRef with ArrayRef constructors. 2023-01-11 11:25:15 -05:00
rustc_log Add log-backtrace option to show backtraces along with logging 2023-01-12 00:17:48 +09:00
rustc_macros Support eager subdiagnostics again 2023-01-11 14:20:34 -08:00
rustc_metadata fix various subst_identity vs skip_binder 2023-01-14 00:30:03 -07:00
rustc_middle Rollup merge of #106940 - oli-obk:tait_error, r=compiler-errors 2023-01-16 20:29:39 +01:00
rustc_mir_build Rollup merge of #106097 - mejrs:mir_build2, r=oli-obk 2023-01-11 22:25:47 -08:00
rustc_mir_dataflow Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_mir_transform Remove visit_place. 2023-01-14 17:04:02 +00:00
rustc_monomorphize fix various subst_identity vs skip_binder 2023-01-14 00:30:03 -07:00
rustc_parse Auto merge of #106872 - dtolnay:nbsp, r=fee1-dead 2023-01-16 09:37:08 +00:00
rustc_parse_format Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_passes change impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata 2023-01-14 00:29:56 -07:00
rustc_plugin_impl Migrate all diagnostics 2022-10-23 10:09:44 +02:00
rustc_privacy change impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata 2023-01-14 00:29:56 -07:00
rustc_query_impl Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_query_system Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_resolve Only suggest adding type param if path being resolved was a type 2023-01-15 16:33:08 +00:00
rustc_save_analysis rename get_parent_node to parent_id 2023-01-04 00:43:13 +00:00
rustc_serialize compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
rustc_session check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736) 2023-01-16 11:09:53 +01:00
rustc_smir Only keep one version of ImplicitSelfKind. 2022-09-13 19:18:23 +02:00
rustc_span Heuristically undo path prefix mappings. 2023-01-14 12:49:37 +00:00
rustc_symbol_mangling Add type flags support for Ty and Const late-bound regions 2023-01-08 03:37:20 +00:00
rustc_target Default repr(C) enums to c_int size 2023-02-16 15:06:17 -08:00
rustc_trait_selection Rollup merge of #106835 - compiler-errors:new-solver-gat-rebase-oops, r=lcnr 2023-01-16 20:29:38 +01:00
rustc_traits Remove bound_{explicit,}_item_bounds 2023-01-15 15:36:06 +00:00
rustc_transmute Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_ty_utils fix various subst_identity vs skip_binder 2023-01-14 00:30:03 -07:00
rustc_type_ir Add type flags support for Ty and Const late-bound regions 2023-01-08 03:37:20 +00:00