Commit graph

218 commits

Author SHA1 Message Date
Sky
21b7360a9a
Initial UnsafePinned/UnsafeUnpin impl [Part 1: Libs] 2025-04-13 01:11:04 -04:00
timesince
069fd02588
Remove redundant words 2025-04-09 18:46:50 +08:00
Skgland
5eb535c568
remove compiler support for extern "rust-intrinsic" blocks 2025-04-06 21:32:58 +02:00
Lieselotte
439048e074
BackendRepr::is_signed: comment why this may panics 2025-03-29 12:21:51 +01:00
Michael Goulet
6438b9eca8 Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
bors
52daa7d835 Auto merge of #137152 - saethlin:bss-const-allocs, r=wesleywiser
Add a .bss-like scheme for encoded const allocs

This check if all bytes are zero feel like it should be too slow, and instead we should have a flag that we track, but that seems hard. Let's see how this perfs first.

Also we can probably stash the "it's all zero actually" flag inside one of the other struct members that's already not using an entire byte. This optimization doesn't fire all that often, so it's possible that by sticking it in the varint length field, this PR actually makes rmeta size worse.
2025-03-13 16:41:22 +00:00
Matthias Krüger
d93ef397ce
Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu
Use `RUSTC_LINT_FLAGS` more

An alternative to the failed #138084.

Fixes #138106.

r? ````@jieyouxu````
2025-03-12 17:59:08 +01:00
Nicholas Nethercote
ff0a5fe975 Remove #![warn(unreachable_pub)] from all compiler/ crates.
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-11 13:14:21 +11:00
bors
90384941aa Auto merge of #138302 - matthiaskrgr:rollup-an2up80, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #136395 (Update to rand 0.9.0)
 - #137279 (Make some invalid codegen attr errors structured/translatable)
 - #137585 (Update documentation to consistently use 'm' in atomic synchronization example)
 - #137926 (Add a test for `-znostart-stop-gc` usage with LLD)
 - #138074 (Support `File::seek` for Hermit)
 - #138238 (Fix dyn -> param suggestion in struct ICEs)
 - #138270 (chore: Fix some comments)
 - #138286 (triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search (…)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-11 00:55:25 +00:00
许杰友 Jieyou Xu (Joe)
063ef18fdc Revert "Use workspace lints for crates in compiler/ #138084"
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to
consider options that avoids breaking downstream usages of cargo on
distributed `rustc-src` artifacts, where such cargo invocations fail due
to inability to inherit `lints` from workspace root manifest's
`workspace.lints` (this is only valid for the source rust-lang/rust
workspace, but not really the distributed `rustc-src` artifacts).

This breakage was reported in
<https://github.com/rust-lang/rust/issues/138304>.

This reverts commit 48caf81484, reversing
changes made to c6662879b2.
2025-03-10 18:12:47 +08:00
Chris Denton
1c7aaf95e1
Update rand to 0.9.0 2025-03-10 01:21:57 +00:00
Matthias Krüger
bfa1a62fd4
Rollup merge of #138158 - moulins:move-layout-to-rustc_abi, r=workingjubilee
Move more layouting logic to `rustc_abi`

Move all `LayoutData`-constructing code to `rustc_abi`:
- Infaillible operations get a new `LayoutData` constructor method;
- Faillible ones get a new method on `LayoutCalculator`.
2025-03-09 10:34:51 +01:00
Moulins
08530d3e99 Move coroutine layout logic to rustc_abi 2025-03-08 16:16:23 +01:00
Moulins
e69491ac60 Move SIMD layout logic to rustc_abi 2025-03-08 12:35:32 +01:00
Moulins
9917173575 Remove most manual LayoutData creations and move them to rustc_abi
...either as:
- methods on LayoutCalculator, for faillible operations;
- constructors on LayoutData, for infaillible ones.
2025-03-08 12:27:19 +01:00
Nicholas Nethercote
8a3e03392e Remove #![warn(unreachable_pub)] from all compiler/ crates.
(Except for `rustc_codegen_cranelift`.)

It's no longer necessary now that `unreachable_pub` is in the workspace
lints.
2025-03-08 08:41:43 +11:00
Nicholas Nethercote
beba32cebb Specify rust lints for compiler/ crates via Cargo.
By naming them in `[workspace.lints.rust]` in the top-level
`Cargo.toml`, and then making all `compiler/` crates inherit them with
`[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`,
because they're a bit different.)

The advantages of this over the current approach:
- It uses a standard Cargo feature, rather than special handling in
  bootstrap. So, easier to understand, and less likely to get
  accidentally broken in the future.
- It works for proc macro crates.

It's a shame it doesn't work for rustc-specific lints, as the comments
explain.
2025-03-08 08:41:09 +11:00
Michael Goulet
73d033f5a1
Rollup merge of #137805 - RalfJung:layout-debug-print, r=Noratrieb
adjust Layout debug printing to match the internal field name

The field got renamed a while ago, but the debug printing was not updated to match.
2025-03-06 12:22:19 -05:00
Jubilee Young
1f32f7bd78 compiler: add ExternAbi::is_rustic_abi 2025-03-04 18:21:36 -08:00
Ralf Jung
aac65f562b rename BackendRepr::Vector → SimdVector 2025-02-28 17:17:45 +01:00
Ralf Jung
476b0980f2 adjust Layout debug printing to match the internal field names 2025-02-28 16:32:15 +01:00
Jacob Pratt
7f14d2eba4
Rollup merge of #137334 - compiler-errors:edition-2024-fresh-2, r=saethlin,traviscross
Greatly simplify lifetime captures in edition 2024

Remove most of the `+ Captures` and `+ '_` from the compiler, since they are now unnecessary with the new edition 2021 lifetime capture rules. Use some `+ 'tcx` and `+ 'static` rather than being overly verbose with precise capturing syntax.
2025-02-23 02:44:18 -05:00
Matthias Krüger
86008eaeac
Rollup merge of #137256 - workingjubilee:untangle-vector-abi-assumptions, r=bjorn3,RalfJung
compiler: untangle SIMD alignment assumptions

There were a number of puzzling assumptions being made about SIMD types and their layout that I have corrected in this diff. These are mostly no-op edits in actual fact, but they do subtly alter a pair of checks in our invariant-checking and union layout computation that rested on those peculiar assumptions. Those unfortunately stand in the way of any further actual fixes. I submit this for review, even though it's not clearly motivated without its followups, because it should still be possible to independently conclude whether this is correct.
2025-02-23 00:16:19 +01:00
Michael Goulet
12e3911d81 Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
Michael Goulet
3d5438accd Fix binding mode problems 2025-02-22 00:13:19 +00:00
Michael Goulet
76d341fa09 Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
Jubilee Young
79f41c773a compiler: split vector_align into cabi and llvmlike
Introduce a pair of functions that actually describe what they do,
because it wasn't clear the alignment is sometimes a forgery.
2025-02-20 19:55:29 -08:00
Jubilee Young
5c474fd99b compiler: BackendRepr::inherent_{size,align} -> scalar_{size,align}
This pair of fn was introduced to perform invariant checks for scalars.
Their current behavior doesn't mesh as well with checking SIMD types,
so change the name of the fn to reflect their actual use-case and
refactor the corresponding checks.

Also simplify the returns from Option<AbiAndPrefAlign> to Option<Align>,
because every site was mapping away the "preferred" alignment anyways.
2025-02-20 19:55:29 -08:00
Jubilee Young
efff15afea compiler: Align::max_for_offset -> Align::max_aligned_factor
No functional changes.
2025-02-20 19:55:29 -08:00
zachs18
6493cd8699 Adjust LayoutData::uninhabited doc comment.
Co-authored-by: Jubilee <workingjubilee@gmail.com>
2025-02-20 13:41:24 -06:00
Zachary S
7ba3d7b54e Remove BackendRepr::Uninhabited, replaced with an uninhabited: bool field in LayoutData.
Also update comments that refered to BackendRepr::Uninhabited.
2025-02-20 13:27:32 -06:00
Ben Kimock
b75b67fa4a Add a .bss-like scheme for encoded const allocs 2025-02-19 12:02:36 -05:00
Ben Kimock
4cf21866e8 Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer 2025-02-16 16:18:30 -05:00
Ben Kimock
1d7cf0ff40 Replace some u64 hashes with Hash64 2025-02-15 13:59:09 -05:00
Jubilee Young
4bb0c3da2c Split out the extern_system_varargs feature
After the stabilization PR was opened, `extern "system"` functions were
added to `extended_varargs_abi_support`. This has a number of questions
regarding it that were not discussed and were somewhat surprising.
It deserves to be considered as its own feature, separate from
`extended_varargs_abi_support`.
2025-02-12 19:57:45 -08:00
Jubilee Young
f8570e8ac5 compiler: remove rustc_abi::lookup and AbiUnsupported
These can be entirely replaced by the FromStr implementation.
2025-02-11 20:18:01 -08:00
Jubilee Young
edff4fe2cc compiler: remove AbiDatas
These were a way to ensure hashes were stable over time for ExternAbi,
but simply hashing the strings is more stable in the face of changes.
As a result, we can do away with them.
2025-02-11 20:18:01 -08:00
Jubilee Young
8abff35b41 compiler: compare and hash ExternAbi like its string
Directly map each ExternAbi variant to its string and back again.
This has a few advantages:
- By making the ABIs compare equal to their strings, we can easily
  lexicographically sort them and use that sorted slice at runtime.
- We no longer need a workaround to make sure the hashes remain stable,
  as they already naturally are (by being the hashes of unique strings).
- The compiler can carry around less &str wide pointers
2025-02-11 20:18:01 -08:00
Jubilee Young
d9c7abba55 compiler: narrow scope of nightly cfg in rustc_abi 2025-02-11 18:55:48 -08:00
Jubilee Young
cd9d39e360 compiler: remove abi-specific extern "{abi}" suggestions
These are either residue of a long-term migration away from something,
or are simply trying too hard to be specifically useful:
nearest-match suggestions for ABI strings should handle this.
2025-02-09 20:45:47 -08:00
Jubilee Young
3f50076fb3 compiler: gate extern "{abi}" in ast_lowering
By moving this stability check into AST lowering, we effectively make
it impossible to accidentally miss, as it must happen to generate HIR.
Also, we put the ABI-stability code next to code that actually uses it!
This allows code that wants to reason about backend ABI implementations
to stop worrying about high-level concerns like syntax stability,
while still leaving it as the authority on what ABIs actually exist.

It also makes it easy to refactor things to have more consistent errors.
For now, we only apply this to generalize the existing messages a bit.
2025-02-09 20:36:59 -08:00
bjorn3
1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
Jubilee Young
28140e8541 compiler: reorganize rustc_abi to be more internally uniform
General housekeeping:
- Use less reexports from its rustc_target era
- Unify some imports as a result
- Split the Reg(ister) types into their own files

Generally moving stuff around because it makes the crate more consistent.
2025-02-06 01:39:46 -08:00
bors
0c2c096e1a Auto merge of #135047 - Flakebi:amdgpu-kernel-cc, r=workingjubilee
Add gpu-kernel calling convention

The amdgpu-kernel calling convention was reverted in commit f6b21e90d1 (#120495 and https://github.com/rust-lang/rust-analyzer/pull/16463) due to inactivity in the amdgpu target.

Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for.

Tracking issue: #135467
amdgpu target tracking issue: #135024
2025-01-17 04:36:09 +00:00
Flakebi
e7e5202978
Add gpu-kernel calling convention
The amdgpu-kernel calling convention was reverted in commit
f6b21e90d1 due to inactivity in the amdgpu
target.

Introduce a `gpu-kernel` calling convention that translates to
`ptx_kernel` or `amdgpu_kernel`, depending on the target that rust
compiles for.
2025-01-16 00:26:55 +01:00
Ralf Jung
d760bb6603 fix ZST handling for Windows ABIs on MSVC target 2025-01-10 12:16:49 +01:00
The 8472
56889dd826 exclude unsizable tail from randomization seed calculation 2025-01-10 02:22:57 +01:00
The 8472
a75617c223 Foo<T> != Foo<U> under layout randomization
previously field ordering was using the same seed for all instances of Foo,
now we pass seed values through the layout tree so that not only
the struct itself affects layout but also its fields
2025-01-10 02:22:57 +01:00
Jubilee Young
c0d3634af8 compiler: Add a statement-of-intent to rustc_abi 2024-12-30 15:21:27 -08:00
Ralf Jung
e023590de4 make no-variant types a dedicated Variants variant 2024-12-18 11:01:54 +01:00