1
Fork 0
Commit graph

4730 commits

Author SHA1 Message Date
bjorn3
ae5f2c2d5c Fix rustc test suite 2025-02-24 14:53:41 +00:00
bjorn3
fb85ef70fc Rustup to rustc 1.87.0-nightly (f8a913b13 2025-02-23) 2025-02-24 14:21:50 +00:00
bjorn3
c9e68eb0e1 Sync from rust f8a913b138 2025-02-24 14:03:45 +00:00
Matthias Krüger
35a43a4833 Rollup merge of #137180 - compiler-errors:sym-regions, r=oli-obk
Give `global_asm` a fake body to store typeck results, represent `sym fn` as a hir expr to fix `sym fn` operands with lifetimes

There are a few intertwined problems with `sym fn` operands in both inline and global asm macros.

Specifically, unlike other anon consts, they may evaluate to a type with free regions in them without actually having an item-level type annotation to give them a "proper" type. This is in contrast to named constants, which always have an item-level type annotation, or unnamed constants which are constrained by their position (e.g. a const arg in a turbofish, or a const array length).

Today, we infer the type of the operand by looking at the HIR typeck results; however, those results are region-erased, so during borrowck we ICE since we don't expect to encounter erased regions. We can't just fill this type with something like `'static`, since we may want to use real (free) regions:

```rust
fn foo<'a>() {
  asm!("/* ... */", sym bar::<&'a ()>);
}
```

The first idea may be to represent `sym fn` operands using *inline* consts instead of anon consts. This makes sense, since inline consts can reference regions from the parent body (like the `'a` in the example above). However, this introduces a problem with `global_asm!`, which doesn't *have* a parent body; inline consts *must* be associated with a parent body since they are not a body owner of their own. In #116087, I attempted to fix this by using two separate `sym` operands for global and inline asm. However, this led to a lot of confusion and also some unattractive code duplication.

In this PR, I adjust the lowering of `global_asm!` so that it's lowered in a "fake" HIR body. This body contains a single expression which is `ExprKind::InlineAsm`; we don't *use* this HIR body, but it's used in typeck and borrowck so that we can properly infer and validate the the lifetimes of `sym fn` operands.

I then adjust the lowering of `sym fn` to instead be represented with a HIR expression. This is both because it's no longer necessary to represent this operand as an anon const, since it's *just* a path expression, and also more importantly to sidestep yet another ICE (https://github.com/rust-lang/rust/issues/137179), which has to do with the existing code breaking an invariant of def-id creation and anon consts. Specifically, we are not allowed to synthesize a def-id for an anon const when that anon const contains expressions with def-ids whose parent is *not* that anon const. This is somewhat related to https://github.com/rust-lang/rust/pull/130443#issuecomment-2445678945, which is also a place in the compiler where synthesizing anon consts leads to def-id parenting issue.

As a side-effect, this consolidates the type checking for inline and global asm, so it allows us to simplify `InlineAsmCtxt` a bit. It also allows us to delete a bit of hacky code from anon const `type_of` which was there to detect `sym fn` operands specifically. This also could be generalized to support `const` asm operands with types with lifetimes in them. Since we specifically reject these consts today, I'm not going to change the representation of those consts (but they'd just be turned into inline consts).

r? oli-obk -- mostly b/c you're patient and also understand the breadth of the code that this touches, please reassign if you don't want to review this.

Fixes #111709
Fixes #96304
Fixes #137179
2025-02-23 00:16:19 +01:00
Matthias Krüger
8b0f63244c Rollup merge of #135501 - tgross35:stdlib-dependencies-private, r=bjorn3
Inject `compiler_builtins` during postprocessing and ensure it is made private

Follow up of https://github.com/rust-lang/rust/pull/135278

Do the following:

* Inject `compiler_builtins` during postprocessing, rather than injecting `extern crate compiler_builtins as _` into the AST
* Do not make dependencies of `std` private by default (this was added in #135278)
* Make sure sysroot crates correctly mark their dependencies private/public
* Ensure that marking a dependency private makes its dependents private by default as well, unless otherwise specified
* Do the `compiler_builtins` update that has been blocked on this

There is more detail in the commit messages. This includes the changes I was working on in https://github.com/rust-lang/rust/pull/136226.

try-job: test-various
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: i686-mingw-1
try-job: i686-mingw-2
2025-02-23 00:16:18 +01:00
bjorn3
5ff55a4783 Rustup to rustc 1.87.0-nightly (794c12416 2025-02-21) 2025-02-22 11:42:10 +00:00
bjorn3
52338f4e06 Sync from rust 794c12416b 2025-02-22 11:37:13 +00:00
Michael Goulet
ea760dd099 Make a fake body to store typeck results for global_asm 2025-02-22 00:12:07 +00:00
Michael Goulet
9dd86e64cc Make asm a named field 2025-02-22 00:05:09 +00:00
Trevor Gross
8622c818e2 Use public-dependencies in all sysroot crates
In [1], most dependencies of `std` and other sysroot crates were marked
private, but this did not happen for `alloc` and `test`. Update these
here, marking public standard library crates as the only non-private
dependencies.

[1]: https://github.com/rust-lang/rust/pull/111076
2025-02-21 17:37:03 +00:00
Zachary S
410a68a907 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
bjorn3
3fc1a58521 Rustup to rustc 1.87.0-nightly (827a0d638 2025-02-18) 2025-02-19 09:25:24 +00:00
bjorn3
849dae0986 Sync from rust 827a0d638d 2025-02-19 09:13:21 +00:00
Jubilee
616fe134c2 cg_clif: Tweak formatting of global comments
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2025-02-18 01:29:23 -08:00
Jubilee Young
44af9d30ff cg_clif: use exclusively ABI alignment 2025-02-17 15:10:51 -08:00
Nicholas Nethercote
b141440f86 Move some Map methods onto TyCtxt.
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17 13:21:02 +11:00
bjorn3
a8774c3dab Merge branch 'sync_from_rust' 2025-02-15 14:16:35 +00:00
bjorn3
0b90953a2d Merge commit '557ed8ebb7' into sync_cg_clif-2025-02-15 2025-02-15 14:13:01 +00:00
bjorn3
557ed8ebb7 Rustup to rustc 1.86.0-nightly (d8810e3e2 2025-02-14) 2025-02-15 12:30:44 +00:00
bjorn3
91397074fc Sync from rust d8810e3e2d 2025-02-15 11:24:22 +00:00
bjorn3
de27d8593d Update to newer Ubuntu in CI for distributing precompiled artifacts
GHA is going to remove support for ubuntu-20.04 in a couple of months
2025-02-14 10:57:29 +00:00
bjorn3
aa9cbd7c3c Rustup to rustc 1.86.0-nightly (a567209da 2025-02-13) 2025-02-14 10:17:47 +00:00
bjorn3
c0c106d4aa Sync from rust a567209daa 2025-02-14 10:08:19 +00:00
clubby789
66bcca11ed Make -O mean -C opt-level=3 2025-02-13 19:47:55 +00:00
bjorn3
8dda1ebfb6 Update rustfmt.toml to match the rust repo 2025-02-13 14:54:50 +00:00
bjorn3
cdadd5f4cd Use correct size for stack slot in inline asm codegen 2025-02-13 14:29:49 +00:00
bjorn3
27e8329b20 Slightly optimize dynamic realignment in create_stack_slot 2025-02-13 14:23:18 +00:00
bjorn3
c27715bf66 Use abi rather than preferred alignment everywhere
Turns out the size of a type is not necessarily a multiple of the
preferred alignment, which broke the realignment logic in
create_stack_slot.
2025-02-13 14:22:57 +00:00
Jacob Pratt
7a4b898b2d Rollup merge of #136660 - compiler-errors:BikeshedGuaranteedNoDrop, r=lcnr
Use a trait to enforce field validity for union fields + `unsafe` fields + `unsafe<>` binder types

This PR introduces a new, internal-only trait called `BikeshedGuaranteedNoDrop`[^1] to faithfully model the field check that used to be implemented manually by `allowed_union_or_unsafe_field`.

942db6782f/compiler/rustc_hir_analysis/src/check/check.rs (L84-L115)

Copying over the doc comment from the trait:

```rust
/// Marker trait for the types that are allowed in union fields, unsafe fields,
/// and unsafe binder types.
///
/// Implemented for:
/// * `&T`, `&mut T` for all `T`,
/// * `ManuallyDrop<T>` for all `T`,
/// * tuples and arrays whose elements implement `BikeshedGuaranteedNoDrop`,
/// * or otherwise, all types that are `Copy`.
///
/// Notably, this doesn't include all trivially-destructible types for semver
/// reasons.
///
/// Bikeshed name for now.
```

As far as I am aware, there's no new behavior being guaranteed by this trait, since it operates the same as the manually implemented check. We could easily rip out this trait and go back to using the manually implemented check for union fields, however using a trait means that this code can be shared by WF for `unsafe<>` binders too. See the last commit.

The only diagnostic changes are that this now fires false-negatives for fields that are ill-formed. I don't consider that to be much of a problem though.

r? oli-obk

[^1]: Please let's not bikeshed this name lol. There's no good name for `ValidForUnsafeFieldsUnsafeBindersAndUnionFields`.
2025-02-13 03:53:30 -05:00
Michael Goulet
c6ddd335a8 Implement and use BikeshedGuaranteedNoDrop for union/unsafe field validity 2025-02-13 03:45:04 +00:00
bors
f9116db090 Auto merge of #136954 - jhpratt:rollup-koefsot, r=jhpratt
Rollup of 12 pull requests

Successful merges:

 - #134090 (Stabilize target_feature_11)
 - #135025 (Cast allocas to default address space)
 - #135841 (Reject `?Trait` bounds in various places where we unconditionally warned since 1.0)
 - #136217 (Mark condition/carry bit as clobbered in C-SKY inline assembly)
 - #136699 (std: replace the `FromInner` implementation for addresses with private conversion functions)
 - #136806 (Fix cycle when debug-printing opaque types from RPITIT)
 - #136807 (compiler: internally merge `PtxKernel` into `GpuKernel`)
 - #136818 (Implement `read*_exact` for `std:io::repeat`)
 - #136927 (Correctly escape hashtags when running `invalid_rust_codeblocks` lint)
 - #136937 (Update books)
 - #136945 (Add diagnostic item for `std::io::BufRead`)
 - #136947 (Reinstate nnethercote in the review rotation.)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-13 02:13:24 +00:00
Jacob Pratt
7b12050ad9 Rollup merge of #136807 - workingjubilee:merge-gpus-to-get-the-arcradeongeforce, r=bjorn3
compiler: internally merge `PtxKernel` into `GpuKernel`

r? ``@bjorn3`` for review
2025-02-12 20:10:00 -05:00
bors
159080c92e Auto merge of #135994 - 1c3t3a:rename-unsafe-ptr, r=oli-obk
Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptr

The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method.
This came up during the review of
https://github.com/rust-lang/rust/pull/134424.

r? `@Noratrieb`
2025-02-12 23:18:14 +00:00
bjorn3
ecad689332 Rustup to rustc 1.86.0-nightly (92bedea1c 2025-02-11) 2025-02-12 16:09:55 +00:00
bjorn3
4836002ed0 Sync from rust 92bedea1c5 2025-02-12 14:48:04 +00:00
Matthias Krüger
603534fbf4 Rollup merge of #136714 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.146

Exposes the error function so we can expose this in the standard library [1].

[1]: https://github.com/rust-lang/compiler-builtins/pull/753
2025-02-10 16:38:26 +01:00
Bastian Kersting
732132f6b1 Extend the renaming to coerce_unsafe_ptr 2025-02-10 13:01:55 +00:00
Jubilee Young
f97679d6ba cg_clif: stop worrying about Conv::PtxKernel 2025-02-09 23:15:14 -08:00
bjorn3
6bd92ef9cb Rustfmt 2025-02-08 22:12:13 +00:00
bjorn3
28a241f7a9 Merge branch 'sync_from_rust' 2025-02-07 21:02:27 +00:00
Trevor Gross
7d73de8557 Update compiler-builtins to 0.1.146
Exposes the error function so we can expose this in the standard
library [1].

[1]: https://github.com/rust-lang/compiler-builtins/pull/753
2025-02-07 20:58:28 +00:00
bjorn3
04e580fcc5 Merge commit '8332329f83' into sync_cg_clif-2025-02-07 2025-02-07 20:58:27 +00:00
bjorn3
8332329f83 Fix rustc test suite 2025-02-07 20:33:50 +00:00
bjorn3
6c4b94bf33 Rustup to rustc 1.86.0-nightly (942db6782 2025-02-06) 2025-02-07 20:01:00 +00:00
bjorn3
8bbe4a022d Sync from rust 942db6782f 2025-02-07 19:32:21 +00:00
bjorn3
46333985ce Remove outdated fixme 2025-02-07 14:14:42 +00:00
bjorn3
c92520a3b5 Workaround bug in the linker-warning test
It incorrectly replaces rustc_codegen_cranelift in paths with rustc. It
also doesn't handle panic=abort correctly.
2025-02-07 14:07:31 +00:00
bjorn3
03764709ca Disable extern_weak test on macOS 2025-02-07 11:34:04 +00:00
bjorn3
b004312ee4 Implement arm64 vaddlvq_u8 and vld1q_u8_x4 vendor intrinsics
This is required for using the bytecount crate on arm64.
2025-02-07 11:01:59 +00:00
bjorn3
ed91b73179 Simplify usage of UnsafeMessage::send 2025-02-06 17:25:59 +00:00