Commit Graph

314954 Commits

Author SHA1 Message Date
Farid Zakaria 93f2e80f4a Add -Z large-data-threshold
This flag allows specifying the threshold size for placing static data
in large data sections when using the medium code model on x86-64.

When using -Ccode-model=medium, data smaller than this threshold uses
RIP-relative addressing (32-bit offsets), while larger data uses
absolute 64-bit addressing. This allows the compiler to generate more
efficient code for smaller data while still supporting data larger than
2GB.

This mirrors the -mlarge-data-threshold flag available in GCC and Clang.
The default threshold is 65536 bytes (64KB) if not specified, matching
LLVM's default behavior.
2026-01-07 11:57:48 -08:00
rust-bors[bot] 84c84421cc Auto merge of #150759 - Kobzol:auto-branch, r=marcoieni
Make verify-channel.sh script compatible with new bors

It only dealt with the `auto` branch before.
2026-01-07 12:07:23 +00:00
Jakub Beránek 6f7313e8ad Make verify-channel.sh script compatible with new bors 2026-01-07 13:06:27 +01:00
bors d9617c8d9a Auto merge of #150310 - JonathanBrouwer:cfg_trace2, r=jdonszelmann
Port `#[cfg]` and `#[cfg_attr]` trace attributes to the new attribute parsers

This PR converts `cfg` and `cfg_trace` attributes to the new parsed representation.

The primary challenge is that re-parsing these attributes in the HIR is a performance regression, since these attributes were only used in rustdoc and clippy parsing them in the HIR is extra work that was not done in the compiler before. To solve this, we only parse the attributes once and then store their parsed representation in the AST.
2026-01-06 22:59:32 +00:00
bors 0aced202c2 Auto merge of #150729 - matthiaskrgr:rollup-an2m4zg, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#150026 (Fix macro_metavar_expr_concat behavior with nested repetitions)
 - rust-lang/rust#150521 (resolve: Rename "name bindings" to "name declarations")
 - rust-lang/rust#150704 (MGCA: Const constructors support)
 - rust-lang/rust#150728 (Cleanup some ui tests for const-traits)

r? `@ghost`
`@rustbot` modify labels: rollup
2026-01-06 19:41:29 +00:00
Matthias Krüger 799c06fa9a Rollup merge of #150728 - fee1-dead-contrib:const-traits-test-cleanup, r=fmease
Cleanup some ui tests for const-traits

r? project-const-traits

These tests pretty much behave as expected now.
2026-01-06 18:43:30 +01:00
Matthias Krüger 9c45483fe6 Rollup merge of #150704 - Kivooeo:const-ctor, r=BoxyUwU
MGCA: Const constructors support

part of https://github.com/rust-lang/rust/issues/132980

fixes rust-lang/rust#132985
fixes rust-lang/rust#136138
fixes rust-lang/rust#139596

r? BoxyUwU
2026-01-06 18:43:29 +01:00
Matthias Krüger e5a2b25f4c Rollup merge of #150521 - petrochenkov:decl, r=nnethercote
resolve: Rename "name bindings" to "name declarations"

This was discussed previously in some name resolution specification threads on zulip.
Link: [#t-compiler/help > understanding early name resolution of imports @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/understanding.20early.20name.20resolution.20of.20imports/near/545306658)

The main change is that `NameBinding` is renamed to `Decl`.
The `Name` part is skipped because almost everything in `rustc_resolve` is about names.
So in general the naming looks more compact now (`binding: NameBinding` -> `decl: Decl`).

I didn't rename *everything* including all the local variables, but did rename most of significant interfaces.
Late resolution in particular uses "bindings" in slightly different meanings, I didn't touch that.

Also, some interface comments are added/improved.

Renaming list:
- fn `define_binding_local` -> `plant_decl_into_local_module`
- fn `add_macro_use_binding` -> `add_macro_use_decl`
- fn `binding_description` -> `decl_description`
- enum `PendingBinding` -> `PendingDecl`
- field `ImportKind::Single::bindings` -> `ImportKind::Single::decls`
- field `NameResolution::non_glob_binding` -> `NameResolution::non_glob_decl`
- field `NameResolution::glob_binding` -> `NameResolution::glob_decl`
- fn `best_binding` -> `best_decl`
- fn `import` -> `new_import_decl`
- fn `try_define_local` -> `try_plant_decl_into_local_module`
- fn `new_ambiguity_binding` -> `new_decl_with_ambiguity`
- fn `new_warn_ambiguity_binding` -> `new_decl_with_warn_ambiguity`
- field `UnnecessaryQualification::binding` -> `UnnecessaryQualification::decl`
- struct `MacroRulesBinding` -> `MacroRulesDef`
- field `MacroRulesBinding::binding` -> `MacroRulesDef::decl`
- variant `MacroRulesScope::Binding` -> `MacroRulesScope::Def`
- enum `LexicalScopeBinding` -> `LateDecl`
- variant `LexicalScopeBinding::Item` -> `LateDecl::Decl`
- variant `LexicalScopeBinding::Res` -> `LateDecl::RibDef`
- field `ModuleData::self_binding` -> `ModuleData::self_decl`
- struct `NameBindingData` -> `DeclData`
- type `NameBinding` -> `Decl`
- enum `NameBindingKind` -> `DeclKind`
- variant `NameBindingKind::Res` -> `DeclKind::Def`
- field `NameBindingKind::Import::binding` -> `DeclKind::Import::source_decl`
- field `PrivacyError::binding` -> `PrivacyError::decl`
- field `ExternPreludeEntry::item_binding` -> `ExternPreludeEntry::item_decl`
- field `ExternPreludeEntry::flag_binding` -> `ExternPreludeEntry::flag_decl`
- field `Resolver::binding_parent_modules` -> `Resolver::decl_parent_modules`
- field `Resolver::dummy_binding` -> `Resolver::dummy_decl`
- field `Resolver::builtin_types_bindings` -> `Resolver::builtin_type_decls`
- field `Resolver::builtin_attrs_bindings` -> `Resolver::builtin_attr_decls`
- field `Resolver::registered_tool_bindings` -> `Resolver::registered_tool_decls`
- fn `ResolverArenas::new_res_binding` -> `ResolverArenas::new_def_decl`
- fn `ResolverArenas::new_pub_res_binding` -> `ResolverArenas::new_pub_def_decl`
- fn `ResolverArenas::alloc_name_binding` -> `ResolverArenas::alloc_decl`
- fn `ResolverArenas::alloc_macro_rules_binding` -> `ResolverArenas::alloc_macro_rules_def`
- fn `set_binding_parent_module` -> `set_decl_parent_module`
2026-01-06 18:43:28 +01:00
Matthias Krüger 8add20b77f Rollup merge of #150026 - Delta17920:fix/150002-macro-concat-bug, r=jdonszelmann
Fix macro_metavar_expr_concat behavior with nested repetitions

**The Bug**: The `${concat(...)}` expression was using the wrong loop index when inside nested repetitions (like optional groups), causing it to get "stuck" on the first element and generate duplicate code.

**The Fix**: Updated `metavar_expr_concat` in `transcribe.rs` to correctly search the repetition stack (`tscx.repeats`) for the target variable instead of blindly using the last index.

**Tests**:
    Added `tests/ui/macros/concat-nested-repetition.rs.`

Fixes rust-lang/rust#150002
2026-01-06 18:43:28 +01:00
Deadbeef d101412517 Cleanup some ui tests for const-traits 2026-01-06 17:23:16 +00:00
bors 4d73a008ea Auto merge of #150726 - JonathanBrouwer:rollup-yseerwy, r=JonathanBrouwer
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#144113 (Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items)
 - rust-lang/rust#149880 (rustc_codegen_llvm: update alignment for double on AIX)
 - rust-lang/rust#150122 (Refactor function names of `rustc_ast_lowering`)
 - rust-lang/rust#150412 (use PIDFD_GET_INFO ioctl when available)
 - rust-lang/rust#150670 (THIR pattern building: Move all `thir::Pat` creation into `rustc_mir_build::thir::pattern`)
 - rust-lang/rust#150695 (MGCA: pretty printing for struct expressions and tuple calls )
 - rust-lang/rust#150698 (Improve comment clarity in candidate_may_shadow)
 - rust-lang/rust#150706 (Update wasm-component-ld)
 - rust-lang/rust#150707 (Fix ICE when transmute Assume field is invalid)
 - rust-lang/rust#150708 (Enable merge queue in new bors)

r? `@ghost`
`@rustbot` modify labels: rollup
2026-01-06 15:22:37 +00:00
Vadim Petrochenkov db26d01211 resolve: DeclKind::Import::binding -> DeclKind::Import::source_decl 2026-01-06 18:21:37 +03:00
Vadim Petrochenkov a0ea3b0635 Update more function names and fields from bindings to declarations 2026-01-06 18:21:37 +03:00
Vadim Petrochenkov a67e289b4d Update some function names and fields from bindings to declarations 2026-01-06 18:21:37 +03:00
Vadim Petrochenkov 844e085de6 resolve: MacroRulesScope::Binding -> MacroRulesScope::Def
`MacroRulesBinding` -> `MacroRulesDef`
2026-01-06 18:21:37 +03:00
Vadim Petrochenkov 7a34af2f67 resolve: Rename LexicalScopeBinding::(Item,Res) to LateDecl::(Decl,RibDef) 2026-01-06 18:21:37 +03:00
Vadim Petrochenkov 460f22c388 resolve: Rename NameBinding(Data,Kind) to Decl(Data,Kind)
Also, rename `DeclKind::Res` to `DeclKind::Def`.
2026-01-06 18:21:37 +03:00
Jonathan Brouwer 9c9ecb18bc Rollup merge of #150708 - Kobzol:merge-queue, r=marcoieni
Enable merge queue in new bors

We can proactively merge this now. Note that new bors will still default to being "paused" and not running the merge queue, after being restarted:
- https://github.com/rust-lang/bors/blob/e1fafaa3b89c225069fa2aa1193096e1d66075c3/src/bors/merge_queue.rs#L101
- https://github.com/rust-lang/bors/blob/bf491ee40d1fc877af273f2ec92a2968dee8cdb7/src/github/api/mod.rs#L159
- https://github.com/rust-lang/rust/pull/112049#issuecomment-3714114478

We can resume it quickly with a command, to test how the merging functionality behaves.
2026-01-06 16:19:45 +01:00
Jonathan Brouwer 58b1130a18 Rollup merge of #150707 - Delta17920:fix-transmute-valtree-ice, r=BoxyUwU
Fix ICE when transmute Assume field is invalid

This PR fixes an internal compiler error in `rustc_transmute` where initializing an `Assume` field (like `alignment`) with a non-scalar constant (like a struct) caused a panic.

The fix updates `from_const` to use `try_to_scalar()` instead of assuming the value is always a leaf. It now gracefully returns `None` for invalid types, allowing the compiler to report standard "missing field initialiser" errors instead of crashing.

Fixes rust-lang/rust#150506
2026-01-06 16:19:44 +01:00
Jonathan Brouwer 0d9ea4f74a Rollup merge of #150706 - alexcrichton:update-wasm-component-ld, r=Mark-Simulacrum
Update wasm-component-ld

Same as rust-lang/rust#147495, just keeping it up-to-date.
2026-01-06 16:19:43 +01:00
Jonathan Brouwer 959736de75 Rollup merge of #150698 - hkBst:patch-6, r=jdonszelmann
Improve comment clarity in candidate_may_shadow

I think this should be the right correction, but I'm not sure.
2026-01-06 16:19:43 +01:00
Jonathan Brouwer dd08360136 Rollup merge of #150695 - Kivooeo:pretty-printing, r=BoxyUwU
MGCA: pretty printing for struct expressions and tuple calls

not sure

1. if there any tests that i need to adjust
2. if i should add any test for it
3. if humanity has come up with anything better than checking if that's first iteration or not with flag when printing sequences with separator

in case there is no tests for it and i dont have to add any, there is a demonstration of this  pretty  printing (this is output from `-Z unpretty=hir`)

```
fn test_errors<const N:
    usize>() {
    // accepts_enum::<{ None::<u32> }>();
    accepts_point::<Point1 { a: N, b: N }>();
    accepts_point::<Point(N, N)>();
}
```

btw it does not print const block

for this

```
accepts_point::<{ Point1 { a: const {N + 1}, b: N } }>();
```

it will print

```
accepts_point::<Point1 { a: { N + 1 }, b: N }>();
```

not sure if we want to print const blocks or not

r? BoxyUwU
2026-01-06 16:19:42 +01:00
Jonathan Brouwer ce42a619a2 Rollup merge of #150670 - Zalathar:let-ty, r=Nadrieril
THIR pattern building: Move all `thir::Pat` creation into `rustc_mir_build::thir::pattern`

The code in `thir::cx::block` was the only code outside of `thir::pattern` that created `thir::Pat` nodes.

Moving it makes the signature of `pat_from_hir` a bit messier, but ensures that all `thir::Pat` creation occurs in one module. That will be useful when trying to change `thir::Pat`, e.g. by adding fields to remove the need for wrapper nodes.

There should be no change to compiler output.
2026-01-06 16:19:41 +01:00
Jonathan Brouwer 3b0d35f94b Rollup merge of #150412 - the8472:pidfd-spawn, r=tgross35
use PIDFD_GET_INFO ioctl when available

This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case where the child is spawned but we can't get the pid. And pidfd.{try_}wait will be able to return the exit status even after a process has been reaped. At least on newer kernels.

Tracking issue: https://github.com/rust-lang/rust/issues/82971
2026-01-06 16:19:41 +01:00
Jonathan Brouwer 0a7a92d7b1 Rollup merge of #150122 - reddevilmidzy:refactor, r=lcnr
Refactor function names of `rustc_ast_lowering`

close: rust-lang/rust#150062

I'll rebase after https://github.com/rust-lang/rust/pull/149114 is merged.

Would it be better to change `lower_const_path_to_const_arg` → `lower_const_path_to_const_arg_and_intern`,
`lower_array_length_to_const_arg` → `lower_array_length_to_const_arg_and_intern`?

r? ``@lcnr``
2026-01-06 16:19:40 +01:00
Jonathan Brouwer dea8b8b3c0 Rollup merge of #149880 - durin42:llvm-22-ppc-aix-layout, r=nikic
rustc_codegen_llvm: update alignment for double on AIX

This was recently fixed upstream in LLVM, so we update our default layout to match.

````@rustbot```` label: +llvm-main
2026-01-06 16:19:39 +01:00
Jonathan Brouwer 8b1bf8af85 Rollup merge of #144113 - mu001999-contrib:dead-code/allow-trait, r=jdonszelmann
Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items

https://github.com/rust-lang/rust/blob/master/compiler/rustc_passes/src/dead.rs#L360-L361 won't insert assoc items into the live set, so that impl items cannot be marked live.

This PR lets impls and impl items can inherit lint levels of the corresponding traits and trait items.

Fixes rust-lang/rust#144060

r? ````@petrochenkov````
2026-01-06 16:19:39 +01:00
Kivooeo d32f1c695f add const ctor support 2026-01-06 15:04:25 +00:00
bors 74fd7516da Auto merge of #147893 - fee1-dead-contrib:constheapheapheap, r=oli-obk
`Vec::push` in consts MVP

Example:

```rust
const X: &'static [u32] = {
    let mut v = Vec::with_capacity(6);
    let mut x = 1;
    while x < 42 {
        v.push(x);
        x *= 2;
    }
    assert!(v.len() == 6);
    v.const_make_global()
};

assert_eq!([1, 2, 4, 8, 16, 32], X);
```

Oh this is fun...

* We split out the implementation of `Global` such that it calls `intrinsics::const_allocate` and `intrinsics::const_deallocate` during compile time. This is achieved using `const_eval_select`
* This allows us to `impl const Allocator for Global`
* We then constify everything necessary for `Vec::with_capacity` and `Vec::push`.
* Added `Vec::const_make_global` to leak and intern the final value via `intrinsics::const_make_global`. If we see any pointer in the final value of a `const` that did not call `const_make_global`, we error as implemented in rust-lang/rust#143595.

r? `@rust-lang/wg-const-eval`

To-do for me:
* [x] Assess the rustdoc impact of additional bounds in the method
* [x] ~~Increase test coverage~~ I think this is enough for an unstable feature.
2026-01-06 11:39:17 +00:00
Jonathan Brouwer e9fdf11c66 Convert clippy to use the new parsed representation 2026-01-06 09:04:56 +01:00
Jonathan Brouwer 4429814412 Convert librustdoc to use the new parsed representation 2026-01-06 09:04:46 +01:00
Jonathan Brouwer 5590fc034c Make cfg and cfg_attr trace attributes into early parsed attributes 2026-01-06 09:04:08 +01:00
Jonathan Brouwer 03fb7eeced Create a rustc_ast representation for parsed attributes 2026-01-06 09:03:35 +01:00
delta17920 e603055d89 Fix ICE when transmute Assume field is invalid 2026-01-06 04:38:51 +00:00
bors da476f1942 Auto merge of #150640 - AprilNEA:mgca-merge-associated-const-equality, r=BoxyUwU
Merge `associated_const_equality` feature gate into MGCA

Tracking Issues: rust-lang/rust#132980 rust-lang/rust#92827

Merge `associated_const_equality`(ACE) feature gate into `min_generic_const_args`(MGCA).

- Replaces `features().associated_const_equality()` checks with `features().min_generic_const_args()`
- Updates the parser to gate associated const equality under `min_generic_const_args`
- Moves `associated_const_equality` to the removed features list
- Removes the `associated_const_equality` method from the `Features` trait
- Updates all affected tests and tools (rust-analyzer, clippy)

Closes rust-lang/rust#150617

r? `@BoxyUwU`
2026-01-06 01:36:53 +00:00
reddevilmidzy 56cb5d598b rename the lower_anon_const_to_const_arg and
`lower_anon_const_to_const_arg_direct` to
`lower_anon_const_to_const_arg_and_alloc` and
`lower_anon_const_to_const_arg`
2026-01-06 09:24:41 +09:00
reddevilmidzy b0a581d51d rename the lower_ty and lower_ty_direct to lower_ty_and_alloc and
`lower_ty`
2026-01-06 09:19:03 +09:00
The 8472 fa4a62b066 use PIDFD_GET_INFO ioctl when available
This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case
where the child is spawned but we can't get the pid.
And `pidfd.{try_}wait` will be able to return the exit status even after a process has been reaped.
At least on newer kernels.
2026-01-06 01:13:09 +01:00
bors 7c04f5d216 Auto merge of #150702 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update

Subtree update of `rust-analyzer` to https://github.com/rust-lang/rust-analyzer/commit/6a1246b69ca761480b9278df019f717b549cface.

Created using https://github.com/rust-lang/josh-sync.

r? `@ghost`
2026-01-05 22:21:47 +00:00
Kivooeo 85c8e41f62 add pretty printing 2026-01-05 21:58:01 +00:00
Augie Fackler accfc34e43 rustc_codegen_llvm: update alignment for double on AIX
This was recently fixed upstream in LLVM, so we update our default
layout to match.

@rustbot label: +llvm-main
2026-01-05 14:08:51 -05:00
bors 4fa80a5e73 Auto merge of #150700 - Kobzol:rollup-02y1lh9, r=Kobzol
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#149790 (Remove `Span` from segments of `AttrPath`)
 - rust-lang/rust#150384 (Tidying up tests/ui/issues 16 tests [7/N])
 - rust-lang/rust#150697 (relate.rs: tiny cleanup: eliminate temp vars 2)

r? `@ghost`
`@rustbot` modify labels: rollup
2026-01-05 18:13:45 +00:00
Jakub Beránek 1925afb7b0 Enable merge queue in new bors 2026-01-05 17:18:52 +01:00
Alex Crichton ba13bb44ed Update wasm-component-ld
Same as 147495, just keeping it up-to-date.
2026-01-05 08:07:07 -08:00
bors bd33b83cfd Auto merge of #149784 - fereidani:retain_mut, r=joboet
Improve alloc `Vec::retain_mut` performance

Hi,

While reading the rustc source code, I noticed it uses `smallvec` and `thin-vec` in many places. I started reviewing those crates, optimized their `retain_mut` implementation, and then realized they were using the exact same algorithm as `alloc::vec::Vec` with less unsafe  So now I’m back here with a PR for the standard library 😂.

In my benchmarks, this version is noticeably faster when `retain_mut` actually removes elements (thanks to fewer pointer operations, it just advances `write_index`), while performing identically to the current implementation when nothing is removed.

Let’s see if bors likes this change or not.
2026-01-05 14:55:14 +00:00
Jakub Beránek 469a26439c Rollup merge of #150697 - hkBst:relate-3, r=Kivooeo
relate.rs: tiny cleanup: eliminate temp vars 2

Continuation of rust-lang/rust#150678

r? `@Kivooeo`
2026-01-05 15:54:14 +01:00
Jakub Beránek 5bcdc7c131 Rollup merge of #150384 - reddevilmidzy:t14, r=Kivooeo
Tidying up tests/ui/issues 16 tests [7/N]

> [!NOTE]
> Intermediate commits are intended to help review, but will be squashed add comment commit prior to merge.

part of rust-lang/rust#133895

r? Kivooeo
2026-01-05 15:54:13 +01:00
Jakub Beránek b198dffd98 Rollup merge of #149790 - JonathanBrouwer:attr-path-perf, r=jdonszelmann
Remove `Span` from segments of `AttrPath`

r? jdonszelmann
2026-01-05 15:54:12 +01:00
Marijn Schouten a956b56d6d Improve comment clarity in candidate_may_shadow 2026-01-05 14:10:50 +01:00
Marijn Schouten 3d6a2c5ae1 relate.rs: tiny cleanup: eliminate temp vars 2 2026-01-05 12:31:21 +00:00