rust/compiler/rustc_lint/src
Matthias Krüger c5efc6aada
Rollup merge of #137306 - tgross35:remove-i128-u128-improper-ctypes, r=traviscross,workingjubilee
Remove `i128` and `u128` from `improper_ctypes_definitions`

Rust's 128-bit integers have historically been incompatible with C [1]. However, there have been a number of changes in Rust and LLVM that mean this is no longer the case:

* Incorrect alignment of `i128` on x86 [1]: adjusting Rust's alignment proposed at https://github.com/rust-lang/compiler-team/issues/683, implemented at https://github.com/rust-lang/rust/pull/116672.
* LLVM version of the above: resolved in LLVM, including ABI fix. Present in LLVM18 (our minimum supported version).
* Incorrect alignment of `i128` on 64-bit PowerPC, SPARC, and MIPS [2]: Rust's data layouts adjusted at https://github.com/rust-lang/rust/pull/132422, https://github.com/rust-lang/rust/pull/132741, https://github.com/rust-lang/rust/pull/134115.
* LLVM version of the above: done in LLVM 20 https://github.com/llvm/llvm-project/issues/102783.
* Incorrect return convention of `i128` on Windows: adjusted to match GCC and Clang at https://github.com/rust-lang/rust/pull/134290.

At https://github.com/rust-lang/lang-team/issues/255#issuecomment-2088855084, the lang team considered it acceptable to remove `i128` from `improper_ctypes_definitions` if the LLVM version is known to be compatible. Time has elapsed since then and we have dropped support for LLVM versions that do not have the x86 fixes, meaning a per-llvm-version lint should no longer be necessary. The PowerPC, SPARC, and MIPS changes only came in LLVM 20 but since Rust's datalayouts have also been updated to match, we will be using the correct alignment regardless of LLVM version.

`repr(i128)` was added to this lint in https://github.com/rust-lang/rust/pull/138282, but is also removed here.

Part of the decision is that `i128` should match `__int128` in C on platforms that provide it, which documentation is updated to indicate. We will not guarantee that `i128` matches `_BitInt(128)` since that can be different from `__int128`. Some platforms (usually 32-bit) do not provide `__int128`; if any ABIs are extended in the future to define it, we will need to make sure that our ABI matches.

Closes: https://github.com/rust-lang/rust/issues/134288

[1]: https://github.com/rust-lang/rust/issues/54341
[2]: https://github.com/rust-lang/rust/issues/128950
2025-06-04 07:54:31 +02:00
..
early Rollup merge of #141004 - matthewjasper:unicode-before-expansion, r=davidtwco 2025-05-30 07:01:28 +02:00
nonstandard_style
types Remove rustc_attr_data_structures re-export from rustc_attr_parsing 2025-05-18 18:14:43 +02:00
async_closures.rs Move some Map methods onto TyCtxt. 2025-02-17 13:21:02 +11:00
async_fn_in_trait.rs nightly feature tracking: get rid of the per-feature bool fields 2024-10-23 09:14:41 +01:00
autorefs.rs Use more subdiagnostics and reword the overloaded deref note 2025-05-14 23:53:40 +02:00
builtin.rs Reorder fields in hir::ItemKind variants. 2025-05-30 02:23:20 +10:00
context.rs Avoid re-interning in LateContext::get_def_path 2025-04-26 22:06:44 +02:00
dangling.rs Implement .use keyword as an alias of clone 2025-03-06 17:58:32 -03:00
default_could_be_derived.rs Reorder fields in hir::ItemKind variants. 2025-05-30 02:23:20 +10:00
deref_into_dyn_supertrait.rs Use Symbol in LateContext::get_associated_type. 2025-04-14 16:12:21 +10:00
drop_forget_useless.rs Move methods from Map to TyCtxt, part 3. 2025-02-21 14:31:09 +11:00
early.rs Add visit_id to ast Visitor 2025-06-01 02:38:24 +00:00
enum_intrinsics_non_enums.rs Fold visit into ty 2025-03-15 06:34:36 +00:00
errors.rs Move eager translation to a method on Diag 2025-04-16 21:38:59 -04:00
expect.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
for_loops_over_fallibles.rs Use span before macro expansion in lint for-loops-over-falibles 2025-05-08 21:17:33 +08:00
foreign_modules.rs Rename Instance::new to Instance::new_raw and add a note that it is raw 2025-05-05 13:17:35 +00:00
if_let_rescope.rs Move eager translation to a method on Diag 2025-04-16 21:38:59 -04:00
impl_trait_overcaptures.rs Rename unpack to kind 2025-05-27 11:14:45 +00:00
internal.rs Overhaul UsePath. 2025-06-03 08:23:21 +10:00
invalid_from_utf8.rs invalid_from_utf8[_unchecked]: also lint inherent methods 2025-02-16 16:34:51 +03:00
late.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
let_underscore.rs Rustfmt 2025-02-08 22:12:13 +00:00
levels.rs decouple "reporting in deps" from future incompatibility reason 2025-06-03 10:49:22 +02:00
lib.rs Rollup merge of #141004 - matthewjasper:unicode-before-expansion, r=davidtwco 2025-05-30 07:01:28 +02:00
lints.rs Rollup merge of #133823 - estebank:issue-56328, r=petrochenkov 2025-05-30 07:01:27 +02:00
macro_expr_fragment_specifier_2024_migration.rs Rename RefTokenTreeCursor. 2024-12-18 10:39:07 +11:00
map_unit_fn.rs Rustfmt 2025-02-08 22:12:13 +00:00
multiple_supertrait_upcastable.rs Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
non_ascii_idents.rs Make LevelAndSource a struct 2025-04-03 09:17:55 +00:00
non_fmt_panic.rs Use Option<Symbol> in panic_call. 2025-03-25 16:14:27 +11:00
non_local_def.rs Reorder fields in hir::ItemKind variants. 2025-05-30 02:23:20 +10:00
nonstandard_style.rs Reorder fields in hir::ItemKind variants. 2025-05-30 02:23:20 +10:00
noop_method_call.rs Rustfmt 2025-02-08 22:12:13 +00:00
opaque_hidden_inferred_bound.rs Squash fold into ty 2025-03-15 06:34:36 +00:00
pass_by_value.rs Rustfmt 2025-02-08 22:12:13 +00:00
passes.rs fix empty after lint on impl/trait items 2025-02-07 16:47:26 +01:00
precedence.rs Temporarily switch ambiguous_negative_literals lint to allow 2024-07-31 19:36:47 +02:00
ptr_nulls.rs Uplift clippy::invalid_null_ptr_usage as invalid_null_arguments 2025-03-30 19:33:15 +02:00
redundant_semicolon.rs Rustfmt 2025-02-08 22:12:13 +00:00
reference_casting.rs Expose peel_casts method as an util method inside rustc_lint 2025-03-30 12:14:02 +02:00
shadowed_into_iter.rs Use is_lang_item and as_lang_item instead of handrolling their logic 2025-04-22 11:02:37 +00:00
static_mut_refs.rs Fix error message for static references or mutable references 2025-04-26 14:48:30 +09:00
tests.rs update cfg(bootstrap) 2025-01-08 21:26:39 +01:00
traits.rs Rustfmt 2025-02-08 22:12:13 +00:00
transmute.rs Make UNNECESSARY_TRANSMUTES into a HIR lint 2025-05-25 15:57:48 +00:00
types.rs Rollup merge of #137306 - tgross35:remove-i128-u128-improper-ctypes, r=traviscross,workingjubilee 2025-06-04 07:54:31 +02:00
unit_bindings.rs Rustfmt 2025-02-08 22:12:13 +00:00
unqualified_local_imports.rs Overhaul UsePath. 2025-06-03 08:23:21 +10:00
unused.rs Fix unused_braces lint suggestion when encountering attributes 2025-05-25 18:17:43 +02:00
utils.rs Uplift clippy::invalid_null_ptr_usage as invalid_null_arguments 2025-03-30 19:33:15 +02:00