Commit Graph

284365 Commits

Author SHA1 Message Date
Jana Dönszelmann
7c085f7ffd
add rustc_macro_edition_2021 2025-03-19 17:37:35 +01:00
bors
c4b38a5967 Auto merge of - matthiaskrgr:rollup-fwwqmr7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 -  (exit: document interaction with C)
 -  (Leave a breadcrumb towards bootstrap config documentation in `bootstrap.toml`)
 -  (Implement `read_buf` for Hermit)
 -  (rustdoc-json: Add tests for `#[repr(...)]`)
 -  (Extract `for_each_immediate_subpat` from THIR pattern visitors)
 -  (Unvacation myself)
 -  (Add `#[cfg(test)]` for Transition in dfa in `rustc_transmute`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-19 09:28:24 +00:00
bors
1370611c0a Auto merge of - jieyouxu:temp-disable-fuchsia, r=Kobzol
Temporarily disable Fuchsia test job to unblock queue

See <https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/fuchsia.20failure/with/506637259> for efforts to fix the test job.

This PR temporarily disables the Fuchsia test job to unblock the queue, so that neither the Fuchsia maintainers nor T-infra maintainers should feel pressured to fix the job ASAP.

Please feel free to re-enable once the test job is fixed.
FYI `@erickt` since you or other Fuchsia maintainers will need to revert this change to merge Fuchsia test job fixes in the future.

r? infra-ci
2025-03-19 06:16:45 +00:00
Jieyou Xu
351e0f7a31
Temporarily disable Fuchsia test job to unblock queue
See
<https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/fuchsia.20failure/with/506637259>
for efforts to fix the test job.
2025-03-19 13:43:34 +08:00
Matthias Krüger
f364f3ec71
Rollup merge of - mu001999-contrib:add-cfg, r=nnethercote
Add `#[cfg(test)]` for Transition in dfa in `rustc_transmute`

`Transition` is only used in the `Transitions::insert` in test after 

Detected by 
2025-03-18 10:09:31 +01:00
Matthias Krüger
20096eabdb
Rollup merge of - jieyouxu:unvac, r=jieyouxu
Unvacation myself

Feeling better now.

r? ghost
2025-03-18 10:09:31 +01:00
Matthias Krüger
6e48c984bd
Rollup merge of - Zalathar:immediate-subpat, r=compiler-errors
Extract `for_each_immediate_subpat` from THIR pattern visitors

This is extracted from some larger changes I've been working on, trying to introduce a “THIR pattern id” to refer to THIR pattern nodes without a direct reference.

The future of those changes is somewhat uncertain, due to some [proposed changes involving upvar inference](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/upvar.20inference.20on.20THIR.3F). So I'm taking my preparatory changes that make sense on their own, and extracting them into one or more independent PRs.

---

This particular patch takes two different functions that were both matching on `PatKind` to traverse subpatterns, and extracts the core match into a single helper function.
2025-03-18 10:09:30 +01:00
Matthias Krüger
bf98654e6c
Rollup merge of - aDotInTheVoid:reprdoc-json, r=GuillaumeGomez
rustdoc-json: Add tests for `#[repr(...)]`

Works towards  and 

Based on , but with only the test changes. CC ```@obi1kenobi```

r? ```@GuillaumeGomez```
2025-03-18 10:09:30 +01:00
Matthias Krüger
800b8fbe39
Rollup merge of - thaliaarchi:io-optional-methods/hermit, r=tgross35
Implement `read_buf` for Hermit

Following https://github.com/hermit-os/kernel/pull/1606, it is now safe to implement `Read::read_buf` for file descriptors on Hermit.

cc ```@mkroening```
2025-03-18 10:09:29 +01:00
Matthias Krüger
42293e3c68
Rollup merge of - moxian:bootstrap-breadcrumb, r=jieyouxu
Leave a breadcrumb towards bootstrap config documentation in `bootstrap.toml`

I was curious as to the possible bootstrap options I can put in config.toml, but had some trouble figuring it out. There is no obvious documentation in `config.toml` (obviously), the documentation in src/bootstrap/defaults is *nice*, but also rather sparse, by design.
I had to dive into the parsing code, and stuble upon [a very helpful doc comment](30f168ef81/src/bootstrap/src/core/config/config.rs (L181)) there to realize that `config.example.toml` *exists*, and that it does, indeed, answer all of my questions.

So I figured it might be worth making this journey a bit easier for future contributors and add mention the `config.example.toml` directly in `config.toml`.

Now, since  is in-flight which would rename `config(.example)?.toml` to `bootstrap(.example)?.toml`, I figure it's better to wait until that one lands, and submit the "new", "correct" filename upfront, instead of landing `config.toml` now and updating it to `boostrap.toml` later.

`@rustbot` blocked 
2025-03-18 10:09:28 +01:00
Matthias Krüger
098db784c7
Rollup merge of - RalfJung:exit, r=the8472
exit: document interaction with C

Cc https://github.com/rust-lang/rust/issues/126600
2025-03-18 10:09:28 +01:00
bors
75530e9f72 Auto merge of - Ayush1325:uefi-fs-2, r=jhpratt,nicholasbishop
uefi: fs: Implement exists

Also adds the initial file abstractions.

The file opening algorithm is inspired from UEFI shell. It starts by classifying if the Path is Shell mapping, text representation of device path protocol, or a relative path and converts into an absolute text representation of device path protocol.

After that, it queries all handles supporting
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and opens the volume that matches the device path protocol prefix (similar to Windows drive). After that, it opens the file in the volume using the remaining pat.

It also introduces OwnedDevicePath and BorrowedDevicePath abstractions to allow working with the base UEFI and Shell device paths efficiently.

DevicePath in UEFI behaves like an a group of nodes laied out in the memory contiguously and thus can be modeled using iterators.

This is an effort to break the original PR (https://github.com/rust-lang/rust/pull/129700) into much smaller chunks for faster upstreaming.
2025-03-18 09:09:12 +00:00
mu001999
835357749b
Add #[cfg(test)] for Transition in dfa 2025-03-18 07:17:16 +00:00
bors
259fdb5212 Auto merge of - matthiaskrgr:rollup-kk1gogr, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 -  (Move `hir::Item::ident` into `hir::ItemKind`.)
 -  (Clarify "owned data" in E0515.md)
 -  (Store test diffs in job summaries and improve analysis formatting)
 -  (Only use `DIST_TRY_BUILD` for try jobs that were not selected explicitly)
 -  (Fix ICE: attempted to remap an already remapped filename)
 -  (rustc_target: Add target feature constraints for LoongArch)
 -  (Flatten `if`s in `rustc_codegen_ssa`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-18 05:58:46 +00:00
Jieyou Xu
a2b7ccb0fa
Unvacation myself 2025-03-18 13:51:29 +08:00
Zalathar
8bb8d74182 Extract for_each_immediate_subpat from THIR pattern visitors 2025-03-18 15:55:47 +11:00
Ayush Singh
2e70cfc04d
uefi: fs: Implement exists
Also adds the initial file abstractions.

The file opening algorithm is inspired from UEFI shell. It starts by
classifying if the Path is Shell mapping, text representation of device
path protocol, or a relative path and converts into an absolute text
representation of device path protocol.

After that, it queries all handles supporting
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and opens the volume that matches the
device path protocol prefix (similar to Windows drive). After that, it
opens the file in the volume using the remaining pat.

It also introduces OwnedDevicePath and BorrowedDevicePath abstractions
to allow working with the base UEFI and Shell device paths efficiently.

DevicePath in UEFI behaves like an a group of nodes laied out in the
memory contiguously and thus can be modeled using iterators.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-18 08:11:16 +05:30
Thalia Archibald
c5fc1931a0 Implement read_buf for Hermit 2025-03-17 16:53:37 -07:00
bors
493c38ba37 Auto merge of - bjorn3:mangle_rustc_std_internal_symbol, r=wesleywiser,jieyouxu
Mangle rustc_std_internal_symbols functions

This reduces the risk of issues when using a staticlib or rust dylib compiled with a different rustc version in a rust program. Currently this will either (in the case of staticlib) cause a linker error due to duplicate symbol definitions, or (in the case of rust dylibs) cause rustc_std_internal_symbols functions to be silently overridden. As rust gets more commonly used inside the implementation of libraries consumed with a C interface (like Spidermonkey, Ruby YJIT (curently has to do partial linking of all rust code to hide all symbols not part of the C api), the Rusticl OpenCL implementation in mesa) this is becoming much more of an issue. With this PR the only symbols remaining with an unmangled name are rust_eh_personality (LLVM doesn't allow renaming it) and `__rust_no_alloc_shim_is_unstable`.

Helps mitigate https://github.com/rust-lang/rust/issues/104707

try-job: aarch64-gnu-debug
try-job: aarch64-apple
try-job: x86_64-apple-1
try-job: x86_64-mingw-1
try-job: i686-mingw-1
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: test-various
try-job: armhf-gnu
2025-03-17 22:16:22 +00:00
Matthias Krüger
597500db8b
Rollup merge of - yotamofek:pr/codegen_ssa/flatten-ifs, r=lcnr
Flatten `if`s in `rustc_codegen_ssa`

Best viewed [while ignoring whitespace](https://github.com/rust-lang/rust/pull/138619/files?diff=unified&w=1)
2025-03-17 22:49:08 +01:00
Matthias Krüger
aa53a72dff
Rollup merge of - heiher:issue-116344, r=RalfJung
rustc_target: Add target feature constraints for LoongArch

Part of https://github.com/rust-lang/rust/issues/116344

r? `@RalfJung`
2025-03-17 22:49:07 +01:00
Matthias Krüger
cd4dfd77fa
Rollup merge of - charmitro:already-remapped-filename, r=GuillaumeGomez,Urgau
Fix ICE: attempted to remap an already remapped filename

This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes 
2025-03-17 22:49:07 +01:00
Matthias Krüger
c19ce9df8d
Rollup merge of - Kobzol:try-job-auto-tests, r=marcoieni
Only use `DIST_TRY_BUILD` for try jobs that were not selected explicitly

Some CI jobs (x64 Linux, ARM64 Linux and x64 MSVC) use the `opt-dist` tool to build an optimized toolchain using PGO and BOLT. When performing a default try build for x64 Linux, in most cases we want to run perf. on that artifact. To reduce the latency of this common use-case, `opt-dist` skips building several components not needed for perf., and it also skips running post-optimization tests, when it detects that the job is executed as a try job (not a merge/auto job).

This is useful, but it also means that if you *want* to run the tests, you had to go to `jobs.yml` and manually comment this environment variable, create a WIP commit, do a try build, and then remove the WIP commit, which is annoying (in the similar way that modifying what gets run in try builds was annoying before we had the `try-job` annotations).

I thought that we could introduce some additional PR description marker like `try-job-run-tests`, but it's hard to discover that such things exist.

Instead, I think that there's a much simpler heuristic for determining whether `DIST_TRY_BUILD` should be used (that I implemented in this PR):
- If you do just ``@bors` try`, without any custom try jobs selected, `DIST_TRY_BUILD` will be activated, to finish the build as fast as possible.
- If you specify any custom try jobs, you are most likely doing experiments and you want to see if tests pass and everything builds as it should. The `DIST_TRY_BUILD` variable will thus *not* be set in this case.

In this way, if you want to run dist tests, you can just add the `try-job: dist-x86_64-linux` line to the PR description, and you don't need to create any WIP commits.

r? `@marcoieni`
2025-03-17 22:49:06 +01:00
Matthias Krüger
5786233b81
Rollup merge of - Kobzol:test-diff-try-build, r=marcoieni
Store test diffs in job summaries and improve analysis formatting

This PR stores the test diffs that we already have in the post-merge workflow also into individual job summaries. This makes it easier to compare test (and later also other) diffs per job, which will be especially useful for try jobs, so that we can actually see the test diffs *before* we merge a given PR.

As a drive-by, I also made a bunch of cleanups in `citool` and in the formatting of the summary and post-merge analyses. These changes are split into self-contained commits.

The analysis can be tested locally with the following command:
```bash
$ curl https://ci-artifacts.rust-lang.org/rustc-builds/<current-sha>/metrics-<job-name>.json > metrics.json
$ cargo run --manifest-path src/ci/citool/Cargo.toml postprocess-metrics metrics.json --job-name <job-name> --parent <parent-sha> > out.md
```
For example, for [this PR](https://github.com/rust-lang/rust/pull/138523):
```bash
$ curl https://ci-artifacts.rust-lang.org/rustc-builds/282865097d138c7f0f7a7566db5b761312dd145c/metrics-aarch64-gnu.json > metrics.json
$ cargo run --manifest-path src/ci/citool/Cargo.toml postprocess-metrics metrics.json --job-name aarch64-gnu --parent d9e5539a39 > out.md
```

Best reviewed commit by commit.

r? `@marcoieni`

try-job: aarch64-gnu
try-job: dist-x86_64-linux
2025-03-17 22:49:05 +01:00
Matthias Krüger
01062ba233
Rollup merge of - hkBst:patch-3, r=wesleywiser
Clarify "owned data" in E0515.md

This clarifies the explanation of why this is not allowed and also what to do instead.

Fixes 

PS There was suggestion of adding a link to the book. I did not yet do that, but if desired that could be added.
2025-03-17 22:49:05 +01:00
Matthias Krüger
e1acc68c9d
Rollup merge of - nnethercote:hir-ItemKind-idents, r=fmease
Move `hir::Item::ident` into `hir::ItemKind`.

 `hir::Item` has an `ident` field.

- It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, Trait`, TraitAalis`.

- It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`, `Impl`.

- For `Use`, it is non-empty for `UseKind::Single` and empty for `UseKind::{Glob,ListStem}`.

All of this is quite non-obvious; the only documentation is a single comment saying "The name might be a dummy name in case of anonymous items". Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out.

This is step towards `kw::Empty` elimination ().

r? `@fmease`
2025-03-17 22:49:04 +01:00
Jakub Beránek
c9d314773e Small review improvements 2025-03-17 21:48:39 +01:00
Nicholas Nethercote
f2ddbcd24b Move hir::Item::ident into hir::ItemKind.
`hir::Item` has an `ident` field.

- It's always non-empty for these item kinds: `ExternCrate`, `Static`,
  `Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`,
  Trait`, TraitAalis`.

- It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`,
  `Impl`.

- For `Use`, it is non-empty for `UseKind::Single` and empty for
  `UseKind::{Glob,ListStem}`.

All of this is quite non-obvious; the only documentation is a single
comment saying "The name might be a dummy name in case of anonymous
items". Some sites that handle items check for an empty ident, some
don't. This is a very C-like way of doing things, but this is Rust, we
have sum types, we can do this properly and never forget to check for
the exceptional case and never YOLO possibly empty identifiers (or
possibly dummy spans) around and hope that things will work out.

The commit is large but it's mostly obvious plumbing work. Some notable
things.

- A similar transformation makes sense for `ast::Item`, but this is
  already a big change. That can be done later.

- Lots of assertions are added to item lowering to ensure that
  identifiers are empty/non-empty as expected. These will be removable
  when `ast::Item` is done later.

- `ItemKind::Use` doesn't get an `Ident`, but `UseKind::Single` does.

- `lower_use_tree` is significantly simpler. No more confusing `&mut
  Ident` to deal with.

- `ItemKind::ident` is a new method, it returns an `Option<Ident>`. It's
  used with `unwrap` in a few places; sometimes it's hard to tell
  exactly which item kinds might occur. None of these unwraps fail on
  the test suite. It's conceivable that some might fail on alternative
  input. We can deal with those if/when they happen.

- In `trait_path` the `find_map`/`if let` is replaced with a loop, and
  things end up much clearer that way.

- `named_span` no longer checks for an empty name; instead the call site
  now checks for a missing identifier if necessary.

- `maybe_inline_local` doesn't need the `glob` argument, it can be
  computed in-function from the `renamed` argument.

- `arbitrary_source_item_ordering::check_mod` had a big `if` statement
  that was just getting the ident from the item kinds that had one. It
  could be mostly replaced by a single call to the new `ItemKind::ident`
  method.

- `ItemKind` grows from 56 to 64 bytes, but `Item` stays the same size,
  and that's what matters, because `ItemKind` only occurs within `Item`.
2025-03-18 06:29:50 +11:00
bors
43a2e9d2c7 Auto merge of - matthiaskrgr:rollup-hmjbqva, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 -  (Stabilize `asm_goto` feature gate)
 -  (Denote `ControlFlow` as `#[must_use]`)
 -  (mir_build: Avoid some useless work when visiting "primary" bindings)
 -  (Emit function declarations for functions with `#[linkage="extern_weak"]`)
 -  (Install licenses into `share/doc/rust/licenses`)
 -  (rustdoc-json: Don't also include `#[deprecated]` in `Item::attrs`)
 -  (Avoid double lowering of idents)

Failed merges:

 -  ([bootstrap] Distribute split debuginfo if present)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-17 19:04:14 +00:00
Yotam Ofek
36f6bc5e3d Flatten ifs in rustc_codegen_ssa 2025-03-17 18:56:52 +00:00
Ralf Jung
c133e22f7c move new section into platform-specific behavior, as it is unix-specific 2025-03-17 17:56:22 +01:00
bors
8279176ccd Auto merge of - Shourya742:2025-02-15-change-config.toml-to-bootstrap.toml, r=onur-ozkan,jieyouxu,kobzol
change config.toml to bootstrap.toml

Currently, both Bootstrap and Cargo uses same name as their configuration file, which can be confusing. This PR is based on a discussion to rename `config.toml` to `bootstrap.toml` for Bootstrap. Closes: https://github.com/rust-lang/rust/issues/126875.

I have split the PR into atomic commits to make it easier to review. Once the changes are finalized, I will squash them. I am particularly concerned about the changes made to modules that are not part of Bootstrap. How should we handle those changes? Should we ping the respective maintainers?
2025-03-17 15:51:28 +00:00
bit-aloo
4579615b14
modify config.toml->bootstrap.toml for new upstream changes 2025-03-17 21:12:23 +05:30
Matthias Krüger
1e58d51290
Rollup merge of - nnethercote:avoid-double-lower_ident, r=compiler-errors
Avoid double lowering of idents

It's easy to double lower idents and spans because they don't change type when lowered.

r? `@cjgillot`
2025-03-17 16:34:52 +01:00
Matthias Krüger
b15e663dbd
Rollup merge of - aDotInTheVoid:deprecate-deprecations, r=GuillaumeGomez
rustdoc-json: Don't also include `#[deprecated]` in `Item::attrs`

Closes 

Not sure if this should bump `FORMAT_VERSION` or not. CC `@Enselic` `@LukeMathWalker` `@obi1kenobi`

r? `@GuillaumeGomez,` best reviewed commit-by-commit
2025-03-17 16:34:51 +01:00
Matthias Krüger
78d141fca0
Rollup merge of - cuviper:licenses, r=jieyouxu
Install licenses into `share/doc/rust/licenses`

This changes the path from "licences" to "licenses" for consistency
across the repo, including the usage directly around this line. This is
a US/UK spelling difference, but I believe the US spelling is also more
common in open source in general.
2025-03-17 16:34:50 +01:00
Matthias Krüger
8f5c09b37c
Rollup merge of - 1c3t3a:external-weak-cfi, r=rcvalle
Emit function declarations for functions with `#[linkage="extern_weak"]`

Currently, when declaring an extern weak function in Rust, we use the following syntax:
```rust
unsafe extern "C" {
   #[linkage = "extern_weak"]
   static FOO: Option<unsafe extern "C" fn() -> ()>;
}
```
This allows runtime-checking the extern weak symbol through the Option.

When emitting LLVM-IR, the Rust compiler currently emits this static as an i8, and a pointer that is initialized with the value of the global i8 and represents the nullabilty e.g.
```
`@FOO` = extern_weak global i8
`@_rust_extern_with_linkage_FOO` = internal global ptr `@FOO`
```

This approach does not work well with CFI, where we need to attach CFI metadata to a concrete function declaration, which was pointed out in https://github.com/rust-lang/rust/issues/115199.

This change switches to emitting a proper function declaration instead of a global i8. This allows CFI to work for extern_weak functions. Example:
```
`@_rust_extern_with_linkage_FOO` = internal global ptr `@FOO`
...
declare !type  !type  !type  !type  extern_weak void `@FOO(double)` unnamed_addr 
```

We keep initializing the Rust internal symbol with the function declaration, which preserves the correct behavior for runtime checking the Option.

r? `@rcvalle`

cc `@jakos-sec`

try-job: test-various
2025-03-17 16:34:50 +01:00
Matthias Krüger
fd4ad33242
Rollup merge of - Zalathar:visit-primary, r=oli-obk
mir_build: Avoid some useless work when visiting "primary" bindings

While looking over `visit_primary_bindings`, I noticed that it does a bunch of extra work to build up a collection of “user-type projections”, even though 2/3 of its call sites don't even use them. Those callers can get the same result via `thir::Pat::walk_always`.

(And it turns out that doing so also avoids creating some redundant user-type entries in MIR for some binding constructs.)

I also noticed that even when the user-type projections *are* used, the process of building them ends up eagerly cloning some nested vectors at every recursion step, even in cases where they won't be used because the current subpattern has no bindings. To avoid this, the visit method now assembles a linked list on the stack containing the information that *would* be needed to create projections, and only creates the concrete projections as needed when a primary binding is encountered.

Some relevant prior PRs:
- 
- 0bfe184b1a in 

---

There should be no user-visible change in compiler output.
2025-03-17 16:34:48 +01:00
Matthias Krüger
9adf2189f5
Rollup merge of - compiler-errors:control-flow, r=Amanieu,lnicola
Denote `ControlFlow` as `#[must_use]`

I've repeatedly hit bugs in the compiler due to `ControlFlow` not being marked `#[must_use]`. There seems to be an accepted ACP to make the type `#[must_use]` (https://github.com/rust-lang/libs-team/issues/444), so this PR implements that part of it.

Most of the usages in the compiler that trigger this new warning are "root" usages (calling into an API that uses control-flow internally, but for which the callee doesn't really care) and have been suppressed by `let _ = ...`, but I did legitimately find one instance of a missing `?` and one for a never-used `ControlFlow` value in .

Presumably this needs an FCP too, so I'm opening this and nominating it for T-libs-api.

This PR also touches the tools (incl. rust-analyzer), but if this went into FCP, I'd split those out into separate PRs which can land before this one does.

r? libs-api
`@rustbot` label: T-libs-api I-libs-api-nominated
2025-03-17 16:34:47 +01:00
Matthias Krüger
3d3f817ff9
Rollup merge of - nbdd0121:asm, r=traviscross,nnethercote
Stabilize `asm_goto` feature gate

Stabilize `asm_goto` feature (tracked by ). The issue will remain open and be updated to track `asm_goto_with_outputs`.

Reference PR: https://github.com/rust-lang/reference/pull/1693

# Stabilization Report

This feature adds a `label <block>` operand type to `asm!`. `<block>` must be a block expression with type unit or never. The address of the block is substituted and the assembly may jump to the block. When block completes the `asm!` block returns and continues execution.

The block starts a new safety context and unsafe operations within must have additional `unsafe`s; the effect of `unsafe` that surrounds `asm!` block is cancelled. See https://github.com/rust-lang/rust/issues/119364#issuecomment-2316037703 and https://github.com/rust-lang/rust/pull/131544.

It's currently forbidden to use `asm_goto` with output operands; that is still unstable under `asm_goto_with_outputs`.

Example:

```rust
unsafe {
    asm!(
        "jmp {}",
        label {
            println!("Jumped from asm!");
        }
    );
}
```

Tests:
- tests/ui/asm/x86_64/goto.rs
- tests/ui/asm/x86_64/goto-block-safe.stderr
- tests/ui/asm/x86_64/bad-options.rs
- tests/codegen/asm/goto.rs
2025-03-17 16:34:47 +01:00
WANG Rui
0ee99cf240 rustc_target: Add target feature constraints for LoongArch
Part of https://github.com/rust-lang/rust/issues/116344
2025-03-17 22:45:35 +08:00
bjorn3
bebc5026b1 Only run symbols-all-mangled test on ELF targets 2025-03-17 14:08:10 +00:00
bjorn3
3866d1c30c Ignore symbols that don't contain rust as substring for executables
For staticlib we still keep checking symbols that don't contain rust as
substring.
2025-03-17 14:08:10 +00:00
bjorn3
83c0398856 Add test that all symbols we expect to be mangled are actually mangled 2025-03-17 14:08:10 +00:00
bjorn3
0b0ccd403b Fix miri 2025-03-17 14:08:10 +00:00
bjorn3
b754ef727c Remove implicit #[no_mangle] for #[rustc_std_internal_symbol] 2025-03-17 14:08:09 +00:00
bjorn3
c0639ef8e4 Mangle #[rustc_std_internal_symbol] to include the rustc version unless #[no_mangle] is used 2025-03-17 14:06:56 +00:00
bjorn3
42de015549 Mark imports of #[rustc_std_internal_symbol] items with this attribute
This ensures that they will be correctly mangled in a future commit.
2025-03-17 14:06:56 +00:00
bjorn3
60b785fc8d Mark #[rustc_std_internal_symbol] as extern indicator
It currently implies #[no_mangle] which is alread an extern indicator,
but this will change in a future commit.
2025-03-17 14:06:56 +00:00
bjorn3
98b9d0232f Allow #[rustc_std_internal_symbol] on foreign items 2025-03-17 14:06:56 +00:00