1886 Commits

Author SHA1 Message Date
Jana Dönszelmann
6087d89004
fixup limit handling code 2025-09-08 15:07:12 -07:00
bors
b3cfb8faf8 Auto merge of #138736 - azhogin:azhogin/sanitizers-target-modificators, r=rcvalle
Sanitizers target modificators

Depends on bool flag fix: https://github.com/rust-lang/rust/pull/138483.

Some sanitizers need to be target modifiers, and some do not. For now, we should mark all sanitizers as target modifiers except for these: AddressSanitizer, LeakSanitizer

For kCFI, the helper flag -Zsanitizer-cfi-normalize-integers should also be a target modifier.

Many test errors was with sanizer flags inconsistent with std deps. Tests are fixed with `-C unsafe-allow-abi-mismatch`.
2025-09-04 22:51:33 +00:00
Nicholas Nethercote
301655eafe Revert introduction of [workspace.dependencies].
This was done in #145740 and #145947. It is causing problems for people
using r-a on anything that uses the rustc-dev rustup package, e.g. Miri,
clippy.

This repository has lots of submodules and subtrees and various
different projects are carved out of pieces of it. It seems like
`[workspace.dependencies]` will just be more trouble than it's worth.
2025-09-02 19:12:54 +10:00
Stuart Cook
2246dda682
Rollup merge of #145947 - nnethercote:workspace-members-2, r=Kobzol
Add more to the `[workspace.dependencies]` section in the top-level `Cargo.toml`

Following on from rust-lang/rust#145740.

r? `@Kobzol`
2025-08-29 12:54:12 +10:00
Jonathan Brouwer
f328709276
Improve error messages around invalid literals in attribute arguments
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-28 20:05:04 +02:00
Nicholas Nethercote
12dc789bc6 Add libc to [workspace.dependencies]. 2025-08-28 20:10:54 +10:00
Jonathan Brouwer
aab5e0bf1f
Move NativeLibKind from rustc_session to rustc_hir 2025-08-27 20:24:59 +02:00
Nicholas Nethercote
c50d2cc807 Add tracing to [workspace.dependencies]. 2025-08-27 14:21:19 +10:00
Nicholas Nethercote
82c4b9c51b Add bitflags to [workspace.dependencies]. 2025-08-27 13:59:32 +10:00
Jana Dönszelmann
4b35cde904
Support lints in early attribute parsing 2025-08-24 09:14:49 +02:00
bors
c5a6a7bdd8 Auto merge of #145567 - clubby789:cargo_update, r=clubby789
Weekly `cargo update` (with libc pin)

Supersedes rust-lang/rust#145516
Manually pins libc for `compiler` and `rustbook` (both of which use rustix), with fixmes to remove this later.
```
compiler & tools dependencies:
     Locking 28 packages to latest compatible versions
    Updating anyhow v1.0.98 -> v1.0.99
    Updating bitflags v2.9.1 -> v2.9.2
    Updating clap v4.5.43 -> v4.5.45
    Updating clap_builder v4.5.43 -> v4.5.44
    Updating clap_derive v4.5.41 -> v4.5.45
    Updating curl v0.4.48 -> v0.4.49
    Updating curl-sys v0.4.82+curl-8.14.1 -> v0.4.83+curl-8.15.0
    Updating cxx v1.0.166 -> v1.0.168
    Updating cxx-build v1.0.166 -> v1.0.168
    Updating cxxbridge-cmd v1.0.166 -> v1.0.168
    Updating cxxbridge-flags v1.0.166 -> v1.0.168
    Updating cxxbridge-macro v1.0.166 -> v1.0.168
    Updating glob v0.3.2 -> v0.3.3
    Updating object v0.37.2 -> v0.37.3
    Updating proc-macro2 v1.0.95 -> v1.0.101
    Updating rayon v1.10.0 -> v1.11.0
    Updating rayon-core v1.12.1 -> v1.13.0
    Updating serde-untagged v0.1.7 -> v0.1.8
    Updating socket2 v0.5.10 -> v0.6.0
    Updating syn v2.0.104 -> v2.0.106
    Updating thiserror v2.0.12 -> v2.0.15
    Updating thiserror-impl v2.0.12 -> v2.0.15
    Updating uuid v1.17.0 -> v1.18.0
    Updating wasm-encoder v0.236.0 -> v0.236.1
    Updating wasmparser v0.236.0 -> v0.236.1
    Updating wast v236.0.0 -> v236.0.1
    Updating wat v1.236.0 -> v1.236.1
note: pass `--verbose` to see 35 unchanged dependencies behind latest

library dependencies:
     Locking 2 packages to latest compatible versions
    Updating libc v0.2.174 -> v0.2.175
    Updating object v0.37.2 -> v0.37.3
note: pass `--verbose` to see 2 unchanged dependencies behind latest

rustbook dependencies:
     Locking 13 packages to latest compatible versions
    Updating anyhow v1.0.98 -> v1.0.99
    Updating bitflags v2.9.1 -> v2.9.2
    Updating cc v1.2.32 -> v1.2.33
    Updating clap v4.5.43 -> v4.5.45
    Updating clap_builder v4.5.43 -> v4.5.44
    Updating clap_complete v4.5.56 -> v4.5.57
    Updating clap_derive v4.5.41 -> v4.5.45
    Updating proc-macro2 v1.0.95 -> v1.0.101
    Updating syn v2.0.104 -> v2.0.106
    Updating terminal_size v0.4.2 -> v0.4.3
    Updating thiserror v2.0.12 -> v2.0.15
    Updating thiserror-impl v2.0.12 -> v2.0.15
```
2025-08-23 16:59:21 +00:00
Josh Triplett
b5c714cfc1 Migrate BuiltinLintDiag::UnexpectedBuiltinCfg to use LintDiagnostic directly 2025-08-22 02:01:01 -07:00
Josh Triplett
c99320156d Refactor lint buffering to avoid requiring a giant enum
Lint buffering currently relies on a giant enum `BuiltinLintDiag`
containing all the lints that might potentially get buffered. In
addition to being an unwieldy enum in a central crate, this also makes
`rustc_lint_defs` a build bottleneck: it depends on various types from
various crates (with a steady pressure to add more), and many crates
depend on it.

Having all of these variants in a separate crate also prevents detecting
when a variant becomes unused, which we can do with a dedicated type
defined and used in the same crate.

Refactor this to use a dyn trait, to allow using `LintDiagnostic` types
directly.

This requires boxing, but all of this is already on the slow path
(emitting an error).

Because the existing `BuiltinLintDiag` requires some additional types in
order to decorate some variants, which are only available later in
`rustc_lint`, use an enum `DecorateDiagCompat` to handle both the `dyn
LintDiagnostic` case and the `BuiltinLintDiag` case.
2025-08-22 01:59:56 -07:00
Andrew Zhogin
6d637dfecc -Zsanitize and -Zsanitizer-cfi-normalize-integers flags are now target modifiers with custom consistency check function 2025-08-21 16:08:00 +07:00
Karol Zwolak
9a29e1693d mention lint group in default level lint note 2025-08-19 21:27:10 +02:00
github-actions
21e9889306 cargo update
compiler & tools dependencies:
     Locking 28 packages to latest compatible versions
    Updating anyhow v1.0.98 -> v1.0.99
    Updating bitflags v2.9.1 -> v2.9.2
    Updating clap v4.5.43 -> v4.5.45
    Updating clap_builder v4.5.43 -> v4.5.44
    Updating clap_derive v4.5.41 -> v4.5.45
    Updating curl v0.4.48 -> v0.4.49
    Updating curl-sys v0.4.82+curl-8.14.1 -> v0.4.83+curl-8.15.0
    Updating cxx v1.0.166 -> v1.0.168
    Updating cxx-build v1.0.166 -> v1.0.168
    Updating cxxbridge-cmd v1.0.166 -> v1.0.168
    Updating cxxbridge-flags v1.0.166 -> v1.0.168
    Updating cxxbridge-macro v1.0.166 -> v1.0.168
    Updating glob v0.3.2 -> v0.3.3
    Updating object v0.37.2 -> v0.37.3
    Updating proc-macro2 v1.0.95 -> v1.0.101
    Updating rayon v1.10.0 -> v1.11.0
    Updating rayon-core v1.12.1 -> v1.13.0
    Updating serde-untagged v0.1.7 -> v0.1.8
    Updating socket2 v0.5.10 -> v0.6.0
    Updating syn v2.0.104 -> v2.0.106
    Updating thiserror v2.0.12 -> v2.0.15
    Updating thiserror-impl v2.0.12 -> v2.0.15
    Updating uuid v1.17.0 -> v1.18.0
    Updating wasm-encoder v0.236.0 -> v0.236.1
    Updating wasmparser v0.236.0 -> v0.236.1
    Updating wast v236.0.0 -> v236.0.1
    Updating wat v1.236.0 -> v1.236.1
note: pass `--verbose` to see 35 unchanged dependencies behind latest

library dependencies:
     Locking 2 packages to latest compatible versions
    Updating libc v0.2.174 -> v0.2.175
    Updating object v0.37.2 -> v0.37.3
note: pass `--verbose` to see 2 unchanged dependencies behind latest

rustbook dependencies:
     Locking 13 packages to latest compatible versions
    Updating anyhow v1.0.98 -> v1.0.99
    Updating bitflags v2.9.1 -> v2.9.2
    Updating cc v1.2.32 -> v1.2.33
    Updating clap v4.5.43 -> v4.5.45
    Updating clap_builder v4.5.43 -> v4.5.44
    Updating clap_complete v4.5.56 -> v4.5.57
    Updating clap_derive v4.5.41 -> v4.5.45
    Updating proc-macro2 v1.0.95 -> v1.0.101
    Updating syn v2.0.104 -> v2.0.106
    Updating terminal_size v0.4.2 -> v0.4.3
    Updating thiserror v2.0.12 -> v2.0.15
    Updating thiserror-impl v2.0.12 -> v2.0.15
2025-08-18 11:28:41 +00:00
Miguel Ojeda
1a29d9c23f Add -Zindirect-branch-cs-prefix option
This is intended to be used for Linux kernel RETPOLINE builds.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2025-08-17 16:51:42 +02:00
Alice Ryhl
1cd7080c3a Add -Zindirect-branch-cs-prefix (from draft PR) 2025-08-17 16:50:23 +02:00
Jakub Beránek
30c967ddba
Rollup merge of #145408 - Kobzol:deduplicate-search-paths, r=petrochenkov
Deduplicate -L search paths

For each -L passed to the compiler, we eagerly scan the whole directory. If it has a lot of files, that results in a lot of allocations. So it's needless to do this if some -L paths are actually duplicated (which can happen e.g. in the situation in the linked issue).

This PR both deduplicates the args, and also teaches rustdoc not to pass duplicated args to merged doctests.

Fixes: https://github.com/rust-lang/rust/issues/145375
2025-08-15 16:03:58 +02:00
Stuart Cook
98bf7f93d4
Rollup merge of #145005 - tardyp:lto_big_filesize, r=bjorn3
strip prefix of temporary file names when it exceeds filesystem name length limit

When doing lto, rustc generates filenames that are concatenating many information.

In the case of this testcase, it is concatenating crate name and rust file name, plus some hash, and the extension. In some other cases it will concatenate even more information reducing the maximum effective crate name to about 110 chars on linux filesystems where filename max length is 255

This commit is ensuring that the temporary file names are limited in size, while still reasonably ensuring the unicity (with hashing of the stripped part)

Fix: rust-lang/rust#49914
2025-08-15 16:16:34 +10:00
Jakub Beránek
8b387d84fe
Deduplicate -L paths passed to rustc 2025-08-14 22:38:21 +02:00
ywxt
075ce31bd3 Fix parallel rustc not being reproducible due to unstable sorting of items. 2025-08-13 08:59:32 +08:00
Pierre Tardy
bc14ad38a3 strip prefix of temporary file names when it exceeds filesystem name length limit
When doing lto, rustc generates filenames that are concatenating many information.

In the case of this testcase, it is concatenating crate name and rust file name, plus some hash, and the extension.
In some other cases it will concatenate even more information reducing the maximum effective crate name to about 110 chars on linux filesystems where
filename max length is 255

This commit is ensuring that the temporary file names are limited in size, while still reasonabily ensuring the unicity (with hashing of the stripped part)
2025-08-10 15:50:40 +02:00
Zalathar
81ed042c8c coverage: Remove all unstable support for MC/DC instrumentation 2025-08-06 22:38:52 +10:00
Zalathar
f496e83fe9 coverage: Simplify access to debug/testing -Zcoverage-options flags 2025-08-04 13:48:41 +10:00
Zalathar
51e62a09a3 coverage: Remove -Zcoverage-options=no-mir-spans
This flag turned out to be less useful than anticipated, and interferes with
work towards expansion support.
2025-08-04 13:48:40 +10:00
bors
65b6cdb6a6 Auto merge of #144562 - matthiaskrgr:rollup-mlvn7qo, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#144072 (update `Atomic*::from_ptr` and `Atomic*::as_ptr` docs)
 - rust-lang/rust#144151 (`tests/ui/issues/`: The Issues Strike Back [1/N])
 - rust-lang/rust#144300 (Clippy fixes for miropt-test-tools)
 - rust-lang/rust#144399 (Add a ratchet for moving all standard library tests to separate packages)
 - rust-lang/rust#144472 (str: Mark unstable `round_char_boundary` feature functions as const)
 - rust-lang/rust#144503 (Various refactors to the codegen coordinator code (part 3))
 - rust-lang/rust#144530 (coverage: Infer `instances_used` from `pgo_func_name_var_map`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-28 08:50:59 +00:00
Matthias Krüger
ec86930c1d
Rollup merge of #144503 - bjorn3:lto_refactors3, r=petrochenkov
Various refactors to the codegen coordinator code (part 3)

Continuing from https://github.com/rust-lang/rust/pull/144062 this removes an option without any known users, uses the object crate in favor of LLVM for getting the LTO bitcode and improves the coordinator channel handling.
2025-07-28 08:36:54 +02:00
bors
d242a8bd5a Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLii
Some `let chains` clean-up

Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one

r? compiler
2025-07-28 05:25:23 +00:00
Kivooeo
b8eb046e6e use let chains in mir, resolve, target 2025-07-28 06:10:36 +05:00
bjorn3
948f7798d7 Remove support for -Zcombine-cgu
Nobody seems to actually use this, while still adding some extra
complexity to the already rather complex codegen coordinator code.
It is also not supported by any backend other than the LLVM backend.
2025-07-26 13:52:24 +00:00
Jakub Beránek
4ef18ab062
Allow pretty printing paths with -Zself-profile-events=args 2025-07-25 22:24:21 +02:00
León Orell Valerian Liehr
2a8bb6eda1
Rollup merge of #144218 - Noratrieb:target-spec-json-de-jank, r=fee1-dead
Use serde for target spec json deserialize

The previous manual parsing of `serde_json::Value` was a lot of complicated code and extremely error-prone. It was full of janky behavior like sometimes ignoring type errors, sometimes erroring for type errors, sometimes warning for type errors, and sometimes just ICEing for type errors (the icing on the top).

Additionally, many of the error messages about allowed values were out of date because they were in a completely different place than the FromStr impls. Overall, the system caused confusion for users.

I also found the old deserialization code annoying to read. Whenever a `key!` invocation was found, one had to first look for the right macro arm, and no go to definition could help.

This PR replaces all this manual parsing with a 2-step process involving serde.
First, the string is parsed into a `TargetSpecJson` struct. This struct is a 1:1 representation of the spec JSON. It already parses all the enums and is very simple to read and write.
Then, the fields from this struct are copied into the actual `Target`. The reason for this two-step process instead of just serializing into a `Target` is because of a few reasons

 1. There are a few transformations performed between the two formats
 2. The default logic is implemented this way. Otherwise all the default field values would have to be spelled out again, which is suboptimal. With this logic, they fall out naturally, because everything in the json struct is an `Option`.

Overall, the mapping is pretty simple, with the vast majority of fields just doing a 1:1 mapping that is captured by two macros. I have deliberately avoided making the macros generic to keep them simple.

All the `FromStr` impls now have the error message right inside them, which increases the chance of it being up to date. Some "`from_str`" impls were turned into proper `FromStr` impls to support this.

The new code is much less involved, delegating all the JSON parsing logic to serde, without any manual type matching.

This change introduces a few breaking changes for consumers. While it is possible to use this format on stable, it is very much subject to change, so breaking changes are expected. The hope is also that because of the way stricter behavior, breaking changes are easier to deal with, as they come with clearer error messages.

1. Invalid types now always error, everywhere. Previously, they would sometimes error, and sometimes just be ignored (which meant the users JSON was still broken, just silently!)
2. This now makes use of `deny_unknown_fields` instead of just warning on unused fields, which was done previously. Serde doesn't make it easy to get such warning behavior, which was the primary reason that this now changed. But I think error behavior is very reasonable too. If someone has random stale fields in their JSON, it is likely because these fields did something at some point but no longer do, and the user likely wants to be informed of this so they can figure out what to do.

   This is also relevant for the future. If we remove a field but someone has it set, it probably makes sense for them to take a look whether they need this and should look for alternatives, or whether they can just delete it. Overall, the JSON is made more explicit.

This is the only expected breakage, but there could also be small breakage from small mistakes. All targets roundtrip though, so it can't be anything too major.

fixes rust-lang/rust#144153
2025-07-24 15:08:22 +02:00
Noratrieb
dad96b107c Use serde for target spec json deserialize
The previous manual parsing of `serde_json::Value` was a lot of
complicated code and extremely error-prone. It was full of janky
behavior like sometimes ignoring type errors, sometimes erroring for
type errors, sometimes warning for type errors, and sometimes just
ICEing for type errors (the icing on the top).

Additionally, many of the error messages about allowed values were out
of date because they were in a completely different place than the
FromStr impls. Overall, the system caused confusion for users.

I also found the old deserialization code annoying to read. Whenever a
`key!` invocation was found, one had to first look for the right macro
arm, and no go to definition could help.

This PR replaces all this manual parsing with a 2-step process involving
serde.
First, the string is parsed into a `TargetSpecJson` struct. This struct
is a 1:1 representation of the spec JSON. It already parses all the
enums and is very simple to read and write.
Then, the fields from this struct are copied into the actual `Target`.
The reason for this two-step process instead of just serializing into a
`Target` is because of a few reasons

 1. There are a few transformations performed between the two formats
 2. The default logic is implemented this way. Otherwise all the default
    field values would have to be spelled out again, which is
    suboptimal. With this logic, they fall out naturally, because
    everything in the json struct is an `Option`.

Overall, the mapping is pretty simple, with the vast majority of fields
just doing a 1:1 mapping that is captured by two macros. I have
deliberately avoided making the macros generic to keep them simple.

All the `FromStr` impls now have the error message right inside them,
which increases the chance of it being up to date. Some "`from_str`"
impls were turned into proper `FromStr` impls to support this.

The new code is much less involved, delegating all the JSON parsing
logic to serde, without any manual type matching.

This change introduces a few breaking changes for consumers. While it is
possible to use this format on stable, it is very much subject to
change, so breaking changes are expected. The hope is also that because
of the way stricter behavior, breaking changes are easier to deal with,
as they come with clearer error messages.

1. Invalid types now always error, everywhere. Previously, they would
   sometimes error, and sometimes just be ignored (which meant the users
   JSON was still broken, just silently!)
2. This now makes use of `deny_unknown_fields` instead of just warning
   on unused fields, which was done previously. Serde doesn't make it
   easy to get such warning behavior, which was the primary reason that
   this now changed. But I think error behavior is very reasonable too.
   If someone has random stale fields in their JSON, it is likely
   because these fields did something at some point but no longer do,
   and the user likely wants to be informed of this so they can figure
   out what to do.

   This is also relevant for the future. If we remove a field but
   someone has it set, it probably makes sense for them to take a look
   whether they need this and should look for alternatives, or whether
   they can just delete it. Overall, the JSON is made more explicit.

This is the only expected breakage, but there could also be small
breakage from small mistakes. All targets roundtrip though, so it can't
be anything too major.
2025-07-21 19:32:44 +02:00
Manuel Drehwald
634016478e add -Zoffload=Enable flag behind -Zunstable-options, to enable gpu (host) code generation 2025-07-18 16:24:00 -07:00
bors
6c0a912e5a Auto merge of #144109 - matthiaskrgr:rollup-mz0mrww, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled)
 - rust-lang/rust#143271 (Store the type of each GVN value)
 - rust-lang/rust#143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions)
 - rust-lang/rust#143719 (Emit warning when there is no space between `-o` and arg)
 - rust-lang/rust#143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests)
 - rust-lang/rust#143891 (Port `#[coverage]` to the new attribute system)
 - rust-lang/rust#143967 (constify `Option` methods)
 - rust-lang/rust#144008 (Fix false positive double negations with macro invocation)
 - rust-lang/rust#144010 (Boostrap: add warning on `optimize = false`)
 - rust-lang/rust#144049 (rustc-dev-guide subtree update)
 - rust-lang/rust#144056 (Copy GCC sources into the build directory even outside CI)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-18 05:43:22 +00:00
Matthias Krüger
26f5936cf9
Rollup merge of #143719 - xizheyin:142812-1, r=jieyouxu
Emit warning when there is no space between `-o` and arg

Closes rust-lang/rust#142812

`getopt` doesn't seem to have an API to check this, so we have to check the args manually.

r? compiler
2025-07-18 04:27:51 +02:00
bors
1aa5b22465 Auto merge of #143545 - compiler-errors:coroutine-obl, r=oli-obk
`-Zhigher-ranked-assumptions`: Consider WF of coroutine witness when proving outlives assumptions

### TL;DR

This PR introduces an unstable flag `-Zhigher-ranked-assumptions` which tests out a new algorithm for dealing with some of the higher-ranked outlives problems that come from auto trait bounds on coroutines. See:

* rust-lang/rust#110338

While it doesn't fix all of the issues, it certainly fixed many of them, so I'd like to get this landed so people can test the flag on their own code.

### Background

Consider, for example:

```rust
use std::future::Future;

trait Client {
    type Connecting<'a>: Future + Send
    where
        Self: 'a;

    fn connect(&self) -> Self::Connecting<'_>;
}

fn call_connect<C>(c: C) -> impl Future + Send
where
    C: Client + Send + Sync,
{
    async move { c.connect().await }
}
```

Due to the fact that we erase the lifetimes in a coroutine, we can think of the interior type of the async block as something like: `exists<'r, 's> { C, &'r C, C::Connecting<'s> }`. The first field is the `c` we capture, the second is the auto-ref that we perform on the call to `.connect()`, and the third is the resulting future we're awaiting at the first and only await point. Note that every region is uniquified differently in the interior types.

For the async block to be `Send`, we must prove that both of the interior types are `Send`. First, we have an `exists<'r, 's>` binder, which needs to be instantiated universally since we treat the regions in this binder as *unknown*[^exist]. This gives us two types: `{ &'!r C, C::Connecting<'!s> }`. Proving `&'!r C: Send` is easy due to a [`Send`](https://doc.rust-lang.org/nightly/std/marker/trait.Send.html#impl-Send-for-%26T) impl for references.

Proving `C::Connecting<'!s>: Send` can only be done via the item bound, which then requires `C: '!s` to hold (due to the `where Self: 'a` on the associated type definition). Unfortunately, we don't know that `C: '!s` since we stripped away any relationship between the interior type and the param `C`. This leads to a bogus borrow checker error today!

### Approach

Coroutine interiors are well-formed by virtue of them being borrow-checked, as long as their callers are invoking their parent functions in a well-formed way, then substitutions should also be well-formed. Therefore, in our example above, we should be able to deduce the assumption that `C: '!s` holds from the well-formedness of the interior type `C::Connecting<'!s>`.

This PR introduces the notion of *coroutine assumptions*, which are the outlives assumptions that we can assume hold due to the well-formedness of a coroutine's interior types. These are computed alongside the coroutine types in the `CoroutineWitnessTypes` struct. When we instantiate the binder when proving an auto trait for a coroutine, we instantiate the `CoroutineWitnessTypes` and stash these newly instantiated assumptions in the region storage in the `InferCtxt`. Later on in lexical region resolution or MIR borrowck, we use these registered assumptions to discharge any placeholder outlives obligations that we would otherwise not be able to prove.

### How well does it work?

I've added a ton of tests of different reported situations that users have shared on issues like rust-lang/rust#110338, and an (anecdotally) large number of those examples end up working straight out of the box! Some limitations are described below.

### How badly does it not work?

The behavior today is quite rudimentary, since we currently discharge the placeholder assumptions pretty early in region resolution. This manifests itself as some limitations on the code that we accept.

For example, `tests/ui/async-await/higher-ranked-auto-trait-11.rs` continues to fail. In that test, we must prove that a placeholder is equal to a universal for a param-env candidate to hold when proving an auto trait, e.g. `'!1 = 'a` is required to prove `T: Trait<'!1>` in a param-env that has `T: Trait<'a>`. Unfortunately, at that point in the MIR body, we only know that the placeholder is equal to some body-local existential NLL var `'?2`, which only gets equated to the universal `'a` when being stored into the return local later on in MIR borrowck.

This could be fixed by integrating these assumptions into the type outlives machinery in a more first-class way, and delaying things to the end of MIR typeck when we know the full relationship between existential and universal NLL vars. Doing this integration today is quite difficult today.

`tests/ui/async-await/higher-ranked-auto-trait-11.rs` fails because we don't compute the full transitive outlives relations between placeholders. In that test, we have in our region assumptions that some `'!1 = '!2` and `'!2 = '!3`, but we must prove `'!1 = '!3`.

This can be fixed by computing the set of coroutine outlives assumptions in a more transitive way, or as I mentioned above, integrating these assumptions into the type outlives machinery in a more first-class way, since it's already responsible for the transitive outlives assumptions of universals.

### Moving forward

I'm still quite happy with this implementation, and I'd like to land it for testing. I may work on overhauling both the way we compute these coroutine assumptions and also how we deal with the assumptions during (lexical/nll) region checking. But for now, I'd like to give users a chance to try out this new `-Zhigher-ranked-assumptions` flag to uncover more shortcomings.

[^exist]: Instantiating this binder with infer regions would be incomplete, since we'd be asking for *some* instantiation of the interior types, not proving something for *all* instantiations of the interior types.
2025-07-18 02:23:50 +00:00
xizheyin
af39c0c57c
Emit warning when there is no space between -o and confusing arg
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-16 23:40:49 +08:00
Michael Goulet
512cf3ae88 Gate things properly 2025-07-15 16:02:26 +00:00
tiif
e331de149f Fix CI 2025-07-15 13:48:30 +00:00
tiif
7356ff7517 Implement other logics 2025-07-15 13:48:30 +00:00
Rémy Rakic
3f194a86ee stabilize -Clink-self-contained=-linker on x64 linux
This stabilizes a subset of the `-Clink-self-contained` components on x64 linux:
the rust-lld opt-out.

The opt-in is not stabilized, as interactions with other stable flags require
more internal work, but are not needed for stabilizing using rust-lld by default.

Similarly, since we only switch to rust-lld on x64 linux, the opt-out is
only stabilized there. Other targets still require `-Zunstable-options`
to use it.
2025-07-08 09:21:35 +00:00
Rémy Rakic
2e6d82c9c9 stabilize -Clinker-features=-lld on x64 linux
This stabilizes a subset of the `-Clinker-features` components on x64 linux:
the lld opt-out.

The opt-in is not stabilized, as interactions with other stable flags require
more internal work, but are not needed for stabilizing using rust-lld by default.

Similarly, since we only switch to rust-lld on x64 linux, the opt-out is
only stabilized there. Other targets still require `-Zunstable-options`
to use it.
2025-07-08 09:04:21 +00:00
bors
2f8eeb2bba Auto merge of #143182 - xdoardo:more-addrspace, r=workingjubilee
Allow custom default address spaces and parse `p-` specifications in the datalayout string

Some targets, such as CHERI, use as default an address space different from the "normal" default address space `0` (in the case of CHERI, [200 is used](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-877.pdf)). Currently, `rustc` does not allow to specify custom address spaces and does not take into consideration [`p-` specifications in the datalayout string](https://llvm.org/docs/LangRef.html#langref-datalayout).

This patch tries to mitigate these problems by allowing targets to define a custom default address space (while keeping the default value to address space `0`) and adding the code to parse the `p-` specifications in `rustc_abi`. The main changes are that `TargetDataLayout` now uses functions to refer to pointer-related informations, instead of having specific fields for the size and alignment of pointers in the default address space; furthermore, the two `pointer_size` and `pointer_align` fields in `TargetDataLayout` are replaced with an `FxHashMap` that holds info for all the possible address spaces, as parsed by the `p-` specifications.

The potential performance drawbacks of not having ad-hoc fields for the default address space will be tested in this PR's CI run.

r? workingjubilee
2025-07-07 17:28:14 +00:00
Martin Nordholts
aa364cac52 compiler: Deduplicate must_emit_unwind_tables() comments
There is one comment at a call site and one comment in the function
definition that are mostly saying the same thing. Fold the call site
comment into the function definition comment to reduce duplication.

There are actually some inaccuracies in the comments but let's
deduplicate before we address the inaccuracies.
2025-07-07 09:34:34 +02:00
Edoardo Marangoni
93f1201c06
compiler: Parse p- specs in datalayout string, allow definition of custom default data address space 2025-07-07 09:04:53 +02:00
Matthias Krüger
8e4cca85b5
Rollup merge of #143417 - klensy:termize, r=jieyouxu
bump termize dep

Bumps termize to drop one more winapi dep. Only change is really moving from winapi: https://github.com/JohnTitor/termize/releases/tag/v0.2.0

Clippy depends on termize 0.1.1, https://github.com/rust-lang/rust-clippy/pull/15207
2025-07-04 16:22:37 +02:00
Matthias Krüger
2faf66d091
Rollup merge of #143387 - dpaoliello:shouldpanicfn, r=bjorn3
Make __rust_alloc_error_handler_should_panic a function

Fixes rust-lang/rust#143253

`__rust_alloc_error_handler_should_panic` is a static but was being exported as a function.

For most targets this doesn't matter, but Arm64EC Windows uses different decorations for exported variables vs functions, hence it fails to link when `-Z oom=abort` is enabled.

We've had issues in the past with statics like this (see rust-lang/rust#141061) but the tldr; is that Arm64EC needs symbols correctly exported as either a function or data, and data MUST and MUST ONLY be marked `dllimport` when the symbol is being imported from another binary, which is non-trivial to calculate for these compiler-generated statics.

So, instead, the easiest thing to do is to make `__rust_alloc_error_handler_should_panic` a function instead.

Since `__rust_alloc_error_handler_should_panic` isn't involved in any linking shenanigans, I've marked it as `AlwaysInline` with the hopes that the various backends will see that it is just returning a constant and perform the same optimizations as the previous implementation.

r? `@bjorn3`
2025-07-04 16:22:36 +02:00
klensy
e631555a48 bump termize dep 2025-07-04 11:43:43 +03:00