1597 Commits

Author SHA1 Message Date
Jonathan Brouwer 92190394b9 Rollup merge of #159659 - mejrs:limit, r=petrochenkov
Move `Limit` out of `rustc_hir`

It feels rather out of place in `rustc_hir`, so this PR moves it to `rustc_data_structures`. Part of hopefully moving attributes from `rustc_hir` to their own crate.

~~This also lets `rustc_type_ir` use it~~ actually rustc_type_ir needs to compile on stable and `rustc_data_structures` uses like 30 features 😢
2026-07-22 18:02:21 +02:00
mejrs ac91844c53 Fixup Limit imports 2026-07-21 15:26:08 +02:00
Oli Scherer 4e2ebd6235 Remove some dead code 2026-07-21 11:34:36 +02:00
bors 87e5904f5e Auto merge of #159610 - JonathanBrouwer:rollup-Wil0K5d, r=JonathanBrouwer
Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#159600 (`rust-analyzer` subtree update)
 - rust-lang/rust#158046 (proc_macro: preserve file module spans for inner attrs)
 - rust-lang/rust#159000 (Small cleanups to the incr comp session code)
 - rust-lang/rust#159189 (Account for type alias projections in E0308 "expected/found" shortening logic)
 - rust-lang/rust#159449 (Enable single Location to issue multiple borrows)
 - rust-lang/rust#159544 (Suggest valid command-line crate names)
 - rust-lang/rust#159587 (Improve `AttrItem::span`)
 - rust-lang/rust#159594 (feat(rustc_hir_typeck): suggest `impl Fn` return for capturing closures)
 - rust-lang/rust#159597 (std: use `arc4random_buf` from libc)
 - rust-lang/rust#159599 (Resolver: Record at least 1 ambiguous trait if main decl is not a trait.)
 - rust-lang/rust#158061 (Make `pin!()` more foolproof.)
 - rust-lang/rust#159460 (Do not mark unnormalized const aliases as rigid when normalizing param env)
 - rust-lang/rust#159529 (Add regression test for nested replacement ranges in `collect_tokens`)
 - rust-lang/rust#159571 (Remove unused bundled library lookup for the local crate)
 - rust-lang/rust#159585 (Minor `TokenStream` improvements)
 - rust-lang/rust#159586 (Separate `InterpCx` usage by `ConstAnalysis` phases)
 - rust-lang/rust#159602 (Remove `ItemLike`)
 - rust-lang/rust#159603 (Clarify `push_stream`/`push_tree`)

Failed merges:

 - rust-lang/rust#159590 (Remove some dead code)
2026-07-20 19:20:00 +00:00
Jonathan Brouwer f64867eb92 Rollup merge of #159000 - bjorn3:simplify_incr_comp_session, r=adwinwhite
Small cleanups to the incr comp session code

Found while working on https://github.com/rust-lang/compiler-team/issues/908. I'm working on some more significant changes, but will leave those to a followup PR.

Part of https://github.com/rust-lang/compiler-team/issues/908
2026-07-20 18:06:01 +02:00
bjorn3 d792ea9d7c Remove unreachable code from finalize_session_directory 2026-07-20 13:28:07 +02:00
Urgau 8e6bd6e388 Query-fy and encode canonical symbols 2026-07-19 17:38:56 +02:00
Jacob Pratt d685d023b1 Rollup merge of #159390 - petrochenkov:cleanpro, r=nnethercote
rustc: Avoid passing jobserver proxy around the compiler

It is used once, when marking a `rustc_thread_pool` worker thread as blocked. `rustc_thread_pool` already has access to the jobserver proxy, so we can move its use from outside of `mark_blocked` to inside of it.

(The modified part of `rustc_thread_pool` is a rustc-specific extension, not an original rayon-core API.)

This is a simpler cleanup subset of https://github.com/rust-lang/rust/pull/155997.

r? @nnethercote
2026-07-17 23:33:32 -04:00
Jonathan Brouwer 151c662284 Rollup merge of #158843 - cezarbbb:fix-143981-sdylib-write-interface-panic, r=bjorn3
Fix ICE in `write_interface` when the interface file can't be written

Fixes rust-lang/rust#143981.

`write_interface` opened the `sdylib` interface file with `fs::File::create_buffered(...).unwrap()`, so any failure to create it (like `-o` into a non-existent or unwritable directory) will ICE instead of reporting a normal error. Emit `FailedWritingFile` instead, matching the rlink and dep-graph write paths.

Also drop a stray trailing `"` from the `FailedWritingFile` in `diagnostic.rs` and `error.rs`.
2026-07-17 15:22:04 +02:00
Vadim Petrochenkov cc4af8e81b rustc_interface: Minor cleanup to jobserver initialization 2026-07-17 14:09:43 +03:00
cezarbbb 07069b3a38 Fix ICE in write_interface when the interface file can't be written 2026-07-17 09:00:02 +08:00
Daria Sukhonina c60e5614e1 rustc: Avoid passing jobserver proxy around the compiler
It is used once, when marking a `rustc_thread_pool` worker thread as blocked.
`rustc_thread_pool` already has access to the jobserver proxy, so we can move its use from outside of `mark_blocked` to inside of it.
2026-07-16 17:22:47 +03:00
Jacob Pratt 57f0adccec Rollup merge of #159250 - GuillaumeGomez:rename-diag, r=JonathanBrouwer
Rename `errors.rs` file to `diagnostics.rs` (13/N)

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

r? @JonathanBrouwer
2026-07-14 00:15:25 -04:00
Guillaume Gomez 2a74949017 Update rustc_session::errors import 2026-07-13 22:31:51 +02:00
Jubilee Young 7e1c0b6ebb compiler: Remove -Zmutable-noalias 2026-07-13 10:13:02 -07:00
LorrensP-2158466 72e9ddc07f Wrap the resolver arenas into WorkerLocal in preperation of parallel import resolution. 2026-07-10 11:14:40 +02:00
Jonathan Brouwer 2085491fdf Rollup merge of #156777 - sgasho:test-fix-codegen-llvm-autodiff-2, r=ZuseZ4
Add -Zautodiff_post_passes flag to limit which llvm passes to run after enzyme to make autodiff tests more robust

* Add -Zautodiff_post_passes flag to limit which llvm passes to run after enzyme to make autodiff tests more robust
* Change some llvm ir check in codegen_llvm/autodiff tests

r? @ZuseZ4
2026-07-05 14:12:03 +02:00
sgasho d7e4edd9a1 Add -Zautodiff_post_passes flag to limit which llvm passes to run after enzyme 2026-07-03 00:43:49 +09:00
Paul Murphy c340e8a2ba Allow section override when using patchable-function-entries
Sometimes it is necessary to group patchable function entrypoint
records in distinct linker sections. This is the case for some bpf
functions within the linux kernel which shouldn't be visible to
ftrace.

Extend `-Zpatchable-function-entry` to accept an argument of the form
`prefix_nops,total_nops,record_section`, which places all entry
record into a user specified section.

Likewise, extend the `patchable_function_entry` attribute to accept an
optional `section="name"` option to place a function into a specific
section.

This is made possible by llvm attribute `patchable-function-entry-section`
added in llvm 21.
2026-06-29 08:52:28 -05:00
Jonathan Brouwer 4631799a4a Rollup merge of #158185 - xmakro:perf/stable-crate-ids-lockfree, r=mu001999
perf: Make stable_crate_ids reads lock-free after crate loading
2026-06-26 20:22:20 +02:00
Jacob Pratt a82172d9ca Rollup merge of #158036 - pmur:murp/add-fentry, r=folkertdev
Add -Zinstrument-mcount=fentry to -Zinstrument-mcount

fentry is essentially a simpler version of mcount where the counting function is called before any other function prologue actions happen.

fentry is still used by the linux x86-64 kernel. It's unclear if or when patchable-function-entry will replace it. It is also used by clang for some x86-64 mingw toolchains.

This is only supported on some x86, x86-64, and s390x targets.
2026-06-25 17:53:53 -04:00
bors 973ad0d0ab Auto merge of #158239 - nnethercote:rework-lint-pass-running, r=Urgau
Rework lint pass running



Some cleanups relating to the running of lint passes.

r? @Urgau
2026-06-25 08:22:49 +00:00
aerooneqq 3d19869935 Refactor proc_macro_decls_static 2026-06-22 10:22:53 +03:00
Nicholas Nethercote 9b420de3f7 Rework check_ast_node_inner
It's called in two cases: pre-expansion lists, and early lints. The
appropriate builtin pass is specified at the call site but the
appropriate other passes are chosen within, which is inconsistent.

This commit changes it so everything is chosen within, based on the
boolean `pre_expansion_lint` parameter. `check_ast_node_inner` is split
into `run_passes` and `run_pass`; the extra function is needed because
the genericness of `builtin_lints` is pushed down one level below
`check_ast_node`.
2026-06-22 16:03:45 +10:00
Jonathan Brouwer 45e0dedeaf Rollup merge of #158193 - JonathanBrouwer:late-lint-experiment, r=jdonszelmann
Remove `has_delayed_lints` optimization

Keeping track of `has_delayed_lints` doesn't seem to have a perf effect anymore so let's not make the code more complicated than needed. These flags were previously used so we don't have to iterate over all hir owners, but iterating over all hir owners seems fast enough

cc @jdonszelmann
2026-06-21 14:52:10 +02:00
Jonathan Brouwer 2668f36a40 Rollup merge of #155439 - ranger-ross:cargo-new-build-dir-layout, r=bjorn3,kobzol
Enable Cargo's new build-dir layout

This PR enables the new Cargo `build-dir` layout in boostrap builds with `-Zbuild-dir-new-layout`.

See: [#t-infra/bootstrap > Has anyone tested `./x` with the new build-dir layout?](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Has.20anyone.20tested.20.60.2E.2Fx.60.20with.20the.20new.20build-dir.20layout.3F/with/581660716)

Tracked in: https://github.com/rust-lang/cargo/issues/15010

r? @bjorn3

cc: @epage
2026-06-21 14:52:08 +02:00
Ross Sullivan 61f3e086ac fix: Only add native paths to PATH during macro expansion on windows
This reduces the size of PATH on windows during macro expansion to avoid
hitting windows limits. With the new Cargo build-dir layout this becomes
more important as Cargo now passes more `-L` args which end up bloating
PATH.
2026-06-21 18:44:24 +09:00
Jonathan Brouwer 7a14504a86 Remove has_delayed_lints optimization 2026-06-21 10:01:09 +02:00
xmakro 7c96471b6f perf: Make stable_crate_ids reads lock-free after crate loading 2026-06-20 11:38:00 -07:00
Nicholas Nethercote 43a9857143 Change EarlyCheckNode from a trait to an enum.
It only has two impls, both of which are tuples, which is ugly. An enum
is much simpler and clearer.

Also, `EarlyContextAndPass` doesn't need to be public.
2026-06-19 08:49:59 +10:00
Paul Murphy 6ce0650633 Add -Zinstrument-mcount=fentry to -Zinstrument-mcount
fentry is essentially a simpler version of mcount where the
counting function is called before any other function prologue
actions happen.

fentry is still used by the linux x86-64 kernel. It's unclear if
or when patchable-function-entry will replace it. It is also used
by clang for some x86-64 mingw toolchains.

This is only supported on some x86, x86-64, and s390x targets.
2026-06-17 13:09:33 -05:00
Jonathan Brouwer 3aa45f9798 Rollup merge of #156950 - cezarbbb:staticlib-rename-internal-symbols, r=petrochenkov
Staticlib rename internal symbols

Follow-up to rust-lang/rust#155338.

`-Zstaticlib-rename-internal-symbols` appends a crate-specific suffix (`_rs{StableCrateId}`) to non-exported symbols, resolving duplicate symbol conflicts when linking multiple Rust staticlibs into the same binary.

The implementation collects all defined `GLOBAL/WEAK` symbol names not in the exported set across all .o files, then renames them by extending the strtab and patching symbol name offsets. When combined with `-Zstaticlib-hide-internal-symbols`, the renamed symbols also receive `STV_HIDDEN` visibility.

Supported on ELF targets (Linux, BSD, etc.) and Apple targets (macOS, iOS, etc.). On unsupported targets (Windows), a warning is emitted and the flag has no effect.

r?@bjorn3 @petrochenkov
2026-06-16 22:11:02 +02:00
cezarbbb 796bc58860 add -Zstaticlib-rename-internal-symbols 2026-06-16 09:41:25 +08:00
Camille Gillot 0e9f9312c3 Steal ResolverAstLowering when indexing AST. 2026-06-16 00:10:08 +00:00
Camille GILLOT 5464994cdd Split-up the AST to index it. 2026-06-16 00:10:07 +00:00
Camille Gillot 334a95f9f4 Make lowering incremental.
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2026-06-16 00:08:10 +00:00
Camille Gillot bfe40ed753 Stop stealing ResolverAstLowering. 2026-06-15 23:24:10 +00:00
Guillaume Gomez d4b2610172 Rename rustc_interface/src/errors.rs into rustc_interface/src/diagnostics.rs 2026-06-13 14:51:05 +02:00
Jonathan Brouwer c756ac4695 Rollup merge of #157348 - ashi009:remap-cwd-prefix-incremental, r=davidtwco,Urgau
Don't track cwd for `-Zremap-cwd-prefix` in incremental compilation

## Summary

`-Zremap-cwd-prefix=<to>` defeats incremental compilation whenever the build directory changes (Bazel sandboxes, CI checkouts with per-build paths), even though the remapped output is identical:

```
[incremental] completely ignoring cache because of differing commandline arguments
```

This fixes the cwd half of rust-lang/rust#132132.

### Root cause

`-Zremap-cwd-prefix` and `--remap-path-prefix` have two separate options (`remap_cwd_prefix` and `remap_path_prefix`), but `parse_remap_path_prefix` *merges* them: it resolves `std::env::current_dir()` and pushes `(cwd, to)` onto `remap_path_prefix`, which is `[TRACKED_NO_CRATE_HASH]`. The **absolute** cwd thus enters `dep_tracking_hash(false)` (compared in `rustc_incremental::persist::load`), so the same build from a different directory purges the whole incremental session.

### Fix: apply the cwd prefix where the mapping is built, not where options are tracked

Keep each option holding exactly its own flag, and apply `-Zremap-cwd-prefix` in `file_path_mapping` — i.e. while building the (untracked) applied `FilePathMapping` — instead of in `parse_remap_path_prefix`. The absolute cwd then lives only in the runtime mapping and never in a tracked option.

**Behaviour-preserving for output:** the applied mapping is identical (the cwd entry is still appended last, so it keeps taking precedence over `--remap-path-prefix` as documented), and all emitted paths (debuginfo, diagnostics, metadata) are unchanged.

**Sound for tracking:** the cwd's effect is still tracked, by the two options that *should* carry it —

* `remap_cwd_prefix` (`[TRACKED]`) — the target prefix baked into output;
* `working_dir` (`[TRACKED]`) — and `RealFileName`'s hash already includes the real local path **only** when the path was not fully remapped (`was_fully_remapped()` = `scopes.is_all()`):

  ```rust
  if !self.was_fully_remapped() { self.local.hash(state); }
  self.maybe_remapped.hash(state);
  ```

  So under a restrictive `-Zremap-path-scope` (where the cwd can still leak into output) the real cwd stays tracked via `working_dir`; under full remapping (where it cannot leak) it is correctly ignored. Dropping the cwd from `remap_path_prefix`'s hash is therefore sound in **every** scope.

The **stable** `--remap-path-prefix` flag is entirely unchanged in data and in tracking. No SVH/crate-hash change (`remap_path_prefix` is `TRACKED_NO_CRATE_HASH`); no new types and no special-case hashing.

### Notes

* A unit test (`tests/ui`-style, in `rustc_interface`) guards against the cwd being merged back into the tracked `remap_path_prefix`, while asserting it is still applied via `file_path_mapping`.
* The unstable book entry for `-Zremap-cwd-prefix` is updated to document the incremental-cache behaviour across build directories.
* A `tests/run-make` end-to-end test (build the same sources from two directories sharing one `-Cincremental` dir, asserting cache reuse) would be a good follow-up; happy to add it here if preferred.

### Relation to stabilization (tracking issue rust-lang/rust#89434)

This is a behaviour fix to an unstable flag and does not depend on or block stabilization. It is, however, mildly relevant to one of the open questions in the tracking issue (rust-lang/rust#89434) — *"Will this always be defined to be the same as `--remap-path-prefix=$(pwd)=VALUE`?"*. After this PR the two are **no longer** equivalent for incremental compilation: a literal `--remap-path-prefix=$(pwd)=.` still bakes the absolute cwd into the tracked hash, whereas `-Zremap-cwd-prefix=.` no longer does. Worth keeping in mind whenever that question is revisited (e.g. alongside RFC 3127).

r? compiler
2026-06-12 20:40:49 +02:00
Jacob Pratt fbc2411811 Rollup merge of #157601 - aerooneqq:delegation-glob-useless-target-expr-error, r=petrochenkov
Emit error for unused target expression in glob and list delegations

This PR emits error if unuse  target expression is specified for glob delegation. Second part of rust-lang/rust#156798.

Part of rust-lang/rust#118212.
r? @petrochenkov
2026-06-11 00:34:02 -04:00
aerooneqq 67081117f0 Emit error for unused target expression in glob and list delegations 2026-06-10 14:07:39 +03:00
Jonathan Brouwer d7bcfdb13f Rollup merge of #155338 - cezarbbb:staticlib-symbol-hygiene, r=petrochenkov
Staticlib hide internal symbols

According to issue rust-lang/rust#104707, when building a staticlib, all Rust internal symbols — mangled symbols, `#[rustc_std_internal_symbol]` items, allocator shims, etc. — leak out of the static archive. In contrast, cdylib correctly exports only `#[no_mangle]` symbols via a linker version script.

`-Zstaticlib-hide-internal-symbols` directly post-processes ELF object files in the archive: parsing the `SHT_SYMTAB` sections and setting `STV_HIDDEN` visibility on any `GLOBAL/WEAK` defined symbol that is not in the exported symbol set, without changing the binding. This is an in-place modification (only writing the st_other byte per matching entry), with zero overhead.

Supported on ELF targets (Linux, BSD, etc.) and Apple targets (macOS, iOS, etc.). On unsupported targets (Windows), a warning is emitted and the flag has no effect.

**Update**: The rename counterpart (`-Zstaticlib-rename-internal-symbols`) is in rust-lang/rust#156950.

The test code are as follows:

1.a std rust staticlib:
```rust
use std::collections::HashMap;
use std::panic::{catch_unwind, AssertUnwindSafe};

#[no_mangle]
pub extern "C" fn my_add(a: i32, b: i32) -> i32 { a + b }

#[no_mangle]
pub extern "C" fn my_hash_lookup(key: u64) -> u64 {
    let mut map = HashMap::new();
    for i in 0..100u64 { map.insert(i, i.wrapping_mul(2654435761)); }
    *map.get(&key).unwrap_or(&0)
}

pub fn internal_reverse(s: &str) -> String { s.chars().rev().collect() }

#[no_mangle]
pub extern "C" fn my_format_number(n: i32) -> i32 {
    let s = format!("number: {}", n); s.len() as i32
}

#[no_mangle]
pub extern "C" fn my_safe_div(a: i32, b: i32) -> i32 {
    match catch_unwind(AssertUnwindSafe(|| {
        if b == 0 { panic!("division by zero!"); }
        a / b
    })) {
        Ok(result) => result,
        Err(_) => -1,
    }
}

#[no_mangle]
pub extern "C" fn my_uncaught_panic() { panic!("uncaught panic across FFI"); }
```

1.b downstream c program:
```c
extern int my_add(int a, int b);
extern unsigned long my_hash_lookup(unsigned long key);
extern int my_format_number(int n);
extern int my_safe_div(int a, int b);
extern void my_uncaught_panic(void);

int main() {
    int failures = 0;
    if (my_add(10, 20) != 30) failures++;
    if (my_hash_lookup(5) != 5UL * 2654435761UL) failures++;
    if (my_format_number(42) != 10) failures++;
    if (my_safe_div(100, 5) != 20) failures++;
    if (my_safe_div(100, 0) != -1) failures++;
    pid_t pid = fork();
    if (pid == 0) { alarm(5); my_uncaught_panic(); _exit(0); }
    else { waitpid(pid, &status, 0); }
    return failures;
}
```

The test results with different compiler flags(which might cause binary size reduction) are as follows:
1.c result with `-Zstaticlib-hide-internal-symbols`
```
  settings                   OFF        ON  -Zsave     ALL    OFF.dynsym ON.dynsym
  ------------------------------------------------------------------------
  default                 1.7M      1.5M  204K (12%)    1735       5    1730
  lto_thin                616K      584K  33K (5%)     246       5     241
  lto_fat                 525K      525K    0 (0%)       6       5       1
  opt_s                   1.7M      1.5M  204K (12%)    1735       5    1730
  opt_z                   1.7M      1.5M  204K (12%)    1735       5    1730
  lto_thin_z              602K      570K  32K (5%)     246       5     241
  lto_fat_z               514K      514K    0 (0%)       6       5       1
  full                    514K      514K    0 (0%)       6       5       1
```

1.d result with `-Zstaticlib-hide-internal-symbols + -Zstaticlib-rename-internal-symbols`
```
  settings                   OFF        ON  -Zsave     ALL    OFF.dynsym ON.dynsym
  ------------------------------------------------------------------------
  default                 1.7M      1.5M  162K (9%)    1735       5    1730
  lto_thin                616K      599K  18K (2%)     246       5     241
  lto_fat                 525K      535K  -1% (-1%)       6       5       1
  opt_s                   1.7M      1.5M  162K (9%)    1735       5    1730
  opt_z                   1.7M      1.5M  162K (9%)    1735       5    1730
  lto_thin_z              602K      585K  18K (2%)     246       5     241
  lto_fat_z               514K      524K  -1% (-1%)       6       5       1
  full                    514K      523K  -1% (-1%)       6       5       1
```

2.a no_std rust staticlib
```rust
#![no_std]
#![feature(core_intrinsics)]

use core::panic::PanicInfo;

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! { loop {} }

#[no_mangle]
pub extern "C" fn embedded_add(a: i32, b: i32) -> i32 { a.wrapping_add(b) }

#[no_mangle]
pub extern "C" fn embedded_checksum(data: *const u8, len: usize) -> u8 {
    if data.is_null() { return 0; }
    let slice = unsafe { core::slice::from_raw_parts(data, len) };
    let mut sum: u8 = 0;
    for &byte in slice { sum = sum.wrapping_add(byte); }
    sum
}

fn internal_helper() -> i32 { 42 }
#[no_mangle]
pub extern "C" fn call_internal() -> i32 { internal_helper() }

#[no_mangle]
pub extern "C" fn embedded_trigger_abort() { core::intrinsics::abort(); }
```
2.b downstream c program
```c
extern int embedded_add(int a, int b);
extern unsigned char embedded_checksum(const unsigned char *data, unsigned long len);
extern int call_internal(void);
extern void embedded_trigger_abort(void);

int main() {
    int failures = 0;
    if (embedded_add(10, 20) != 30) failures++;
    unsigned char data[] = {1, 2, 3};
    if (embedded_checksum(data, 3) != 6) failures++;
    if (call_internal() != 42) failures++;
    pid_t pid = fork();
    if (pid == 0) { embedded_trigger_abort(); _exit(0); }
    else { waitpid(pid, &status, 0); }
    return failures;
}
```

The test results with different compiler flags(which might cause binary size reduction) are as follows:
2.c result with `-Zstaticlib-hide-internal-symbols`
```
  settings                   OFF        ON  -Zsave     ALL    OFF.dynsym ON.dynsym
  ------------------------------------------------------------------------
  default                 485K      429K  56K (11%)     490       4     486
  lto_thin                180K      180K    0 (0%)       4       4       0
  lto_fat                 179K      179K    0 (0%)       4       4       0
  opt_s                   485K      429K  56K (11%)     490       4     486
  opt_z                   485K      429K  56K (11%)     490       4     486
  lto_thin_z              180K      180K    0 (0%)       4       4       0
  lto_fat_z               179K      179K    0 (0%)       4       4       0
  full                    179K      179K    0 (0%)       4       4       0
```

2.d result with `-Zstaticlib-hide-internal-symbols + -Zstaticlib-rename-internal-symbols`
```
  settings                   OFF        ON  -Zsave     ALL    OFF.dynsym ON.dynsym
  ------------------------------------------------------------------------
  default                 485K      447K  39K (7%)     490       4     486
  lto_thin                180K      189K  -5% (-5%)       4       4       0
  lto_fat                 179K      189K  -5% (-5%)       4       4       0
  opt_s                   485K      448K  38K (7%)     490       4     486
  opt_z                   485K      448K  38K (7%)     490       4     486
  lto_thin_z              180K      189K  -5% (-5%)       4       4       0
  lto_fat_z               179K      189K  -5% (-5%)       4       4       0
  full                    179K      189K  -5% (-5%)       4       4       0
```

Test results show that this compiler option is beneficial for scenarios where LTO cannot be enabled.

r? @bjorn3 @petrochenkov
2026-06-08 09:41:54 +02:00
cezarbbb 6caae67115 add -Zstaticlib-hide-internal-symbols 2026-06-08 08:33:13 +08:00
bjorn3 f484629863 Assert incr comp in copy_cgu_workproduct_to_incr_comp_cache_dir
It was already only called when incr comp is enabled and this allows
cleaning up the callers a bit.
2026-06-07 13:24:14 +00:00
bjorn3 9419baeee8 Use WorkProductMap instead of FxIndexMap
This is an UnordMap internally. Iteration order for the work product map
should not matter aside from the place it is serialized where sorting by
WorkProductId is sufficient.
2026-06-07 13:24:12 +00:00
Jonathan Brouwer 8ae06c8e46 Rollup merge of #157296 - aerooneqq:delegation-extract-resolve, r=petrochenkov
delegation: split resolution and lowering

This PR splits delegation's AST -> HIR lowering and its resolution. Now we resolve all delegations and then lower them. This should have benefits:

- ~For rust-lang/rust#156798, where it will be convenient to insert diagnostics about specifying target expressions for glob reuses of only static functions (the `delegations_resolutions` map will contain information whether to lower or delete target expression)~
- For rust-lang/rust#155337 and delegations to inherent methods resolution, as from what I tested up until now we should resolve them in iterative manner before AST -> HIR lowering.

Part of rust-lang/rust#118212.
r? @petrochenkov
2026-06-04 15:33:23 +02:00
aerooneqq cf34955dbe Split delegation resolution and lowering 2026-06-04 15:07:31 +03:00
bors 49b19d32b9 Auto merge of #157404 - jhpratt:rollup-npYd5Y2, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#156210 (Emit retags in codegen to support BorrowSanitizer (part 2))
 - rust-lang/rust#157317 (Fix ICE when wrong intra-doc link on type alias)
 - rust-lang/rust#157391 (Reorganize `tests/ui/issues` [4/N])
2026-06-04 03:56:06 +00:00
Jacob Pratt fa82c8dc3e Rollup merge of #156210 - BorrowSanitizer:codegen-emit-retag-2, r=saethlin
Emit retags in codegen to support BorrowSanitizer (part 2)

Tracking issue: rust-lang/rust#154760
[Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/593004012)

This is one of several PRs that will add experimental support for emitting retags as function calls in codegen. Each PR will be a minimal, improved slice of the changes in rust-lang/rust#155965.

This PR adds a new unstable flag `-Zcodegen-emit-retag`, which will enable experimental retag calls in generated code. This flag is a nop for now, but the relevant methods have been added to codegen_ssa, and they are called wherever retags are necessary. Subsequent PRs will complete this implementation.

This does not depend on rust-lang/rust#156208.

r? @RalfJung
2026-06-03 21:49:45 -04:00
bors 76dfce2cb2 Auto merge of #145477 - cjgillot:codegen-mode, r=oli-obk
Introduce `TypingMode::Codegen` to avoid layout cycles on coroutines



Computing layout of coroutines depends on their `optimized_mir`. At the same time, MIR opts can require using layouts to work. For instance to evaluate constants. This leads to cycles and clumsy workarounds.

This PR creates a new typing mode for layout computations:
- when a coroutine's layout is requested with `TypingMode::PostAnalysis` or earlier, return `LayourError::TooGeneric`;
- when a coroutine's layout is requested with `TypingMode::Codegen`, actually compute it.

`TypingMode::Codegen` is meant be be used by codegen code, and analyses that require coroutine layout, like transmute check and coroutine recursion check.

With this PR, we can remove all `is_coroutine` checks from `rustc_mir_transform` and unlock simplifying coroutine MIR.

Perf is not terrific. This PR causes recomputation of a few queries, and I had to insert workarounds.
2026-06-03 23:14:30 +00:00