Commit Graph

318968 Commits

Author SHA1 Message Date
Matthias Krüger 48cf90f337 Rollup merge of #152915 - CrooseGit:dev/reucru01/error-illegal-sv-init, r=mati865
Error on attempt to construct scalable vector type

If you attempt to construct a scalable vector type rust will ICE.

E.g.:
```rust
#[rustc_scalable_vector(4)]
#[allow(non_camel_case_types)]
struct svint32_t(i32);
fn main() {
    let foo = svint32_t(1);
    // This will ICE
}
```

This PR adds a check that will emit an error if you attempt to use a SV constructor and a test to ensure it works.
2026-02-21 13:03:29 +01:00
Matthias Krüger 069c329209 Rollup merge of #152878 - Zalathar:oneshot, r=workingjubilee
Remove two more flaky assertions from `oneshot` tests

These elapsed-time-upper-bound assertions are inherently flaky in CI, because CI runners will sometimes starve individual threads for a surprisingly long time, so the assertions can fail even if nothing went wrong.

Similar changes for other flaky `oneshot` tests:
- https://github.com/rust-lang/rust/pull/152145
- https://github.com/rust-lang/rust/pull/152648

Example flaky failure:
- https://github.com/rust-lang/rust/pull/152747#issuecomment-3929166655
2026-02-21 13:03:29 +01:00
Matthias Krüger a919df8b1b Rollup merge of #151603 - GrigorenkoPV:stabilize/str_as_str, r=jhpratt
Stabilize `str_as_str`

- Tracking issue: rust-lang/rust#130366
- Needs FCP
- `ByteStr` methods remain gated behind `bstr` feature gate (rust-lang/rust#134915)

Closes rust-lang/rust#130366
2026-02-21 13:03:28 +01:00
Matthias Krüger 7339fc5cec Rollup merge of #152929 - scottmcm:better-alignment-ranges, r=mati865
Tighten the `!range` bounds on alignments in vtables

Right now we're only telling LLVM that they're non-zero, but alignments must be powers of two so can't be more than `isize::MAX+1`.  And we actually never emit anything beyond LLVM's limit of 2²⁹, so outside of 16-bit targets the limit is that.

(Pulled out from rust-lang/rust#152867 which is starting to have too much in it.)
2026-02-21 13:03:28 +01:00
bors 3fc37321c4 Auto merge of #152624 - camsteffen:symbols-audit, r=petrochenkov
Audit Symbols

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152624)*

Remove unused symbols and hoist some symbols to Clippy.
2026-02-21 06:44:20 +00:00
Scott McMurray 0187acccad Include the Align::MAX limit in the !range metadata for loading alignment from a vtable 2026-02-20 20:22:31 -08:00
bors 1c00e989ca Auto merge of #152924 - JonathanBrouwer:rollup-vnwkCh0, r=JonathanBrouwer
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#146832 (Not linting irrefutable_let_patterns on let chains)
 - rust-lang/rust#146972 (Support importing path-segment keyword with renaming)
 - rust-lang/rust#152241 (For panic=unwind on Wasm targets, define __cpp_exception tag)
 - rust-lang/rust#152527 (Remove -Zemit-thin-lto flag)
 - rust-lang/rust#152769 (Do not cancel try builds after first job failure)
 - rust-lang/rust#152907 (Add tests for delegation generics)
 - rust-lang/rust#152455 (Remove the translation `-Z` options and the `Translator` type. )
 - rust-lang/rust#152813 (Skip the `use_existential_projection_new_instead` field in the `Debug` impl)
 - rust-lang/rust#152912 (Expose Span for all DefIds in rustc_public)
2026-02-21 02:52:40 +00:00
Jonathan Brouwer 7655d9370d Rollup merge of #152912 - HKalbasi:rustc_public_def_span, r=makai410
Expose Span for all DefIds in rustc_public

Part of https://github.com/rust-lang/project-stable-mir/issues/118

To be maximally useful, `VariantDef` and `FieldDef` should be changed to be a wrapper around `DefId` instead of holding their parent and index. I can do this change in this PR or a follow-up if it is desired. For now, I added the missing `impl Stable for DefId` in internals so you can convert from rustc internals.
2026-02-20 22:00:59 +01:00
Jonathan Brouwer 47e2fec78d Rollup merge of #152813 - makai410:debug-impl, r=lqd
Skip the `use_existential_projection_new_instead` field in the `Debug` impl

Resolves: rust-lang/rust#152807 .

Simply slap a `#derive_where[skip(Debug)]` on that field.
2026-02-20 22:00:58 +01:00
Jonathan Brouwer b0cdafbd4a Rollup merge of #152455 - JonathanBrouwer:remove_translation, r=jdonszelmann
Remove the translation `-Z` options and the `Translator` type.

This PR implements MCP https://github.com/rust-lang/compiler-team/issues/967

It is split up into individually reviewable commits, each commit passes tests:

* https://github.com/rust-lang/rust/commit/678211956793a2e772414a71700a21525af6e67b Removes the translation compiler options from the session
* https://github.com/rust-lang/rust/commit/8f300d02fe8d2f01a39425925afd4cf3e15a822b Removes the now empty `Translator` type
* https://github.com/rust-lang/rust/commit/ab715c536fbd4ac09409e9a44eea2e25ea8a4f48 Renames `translate_message` to `format_diag_message`, as the function no longer does any translation
* https://github.com/rust-lang/rust/commit/8bcbc3f766af6242dcb52afe1ef4f6b1a9685019 Removes a section describing the removed compiler options from the rustc dev guide
2026-02-20 22:00:57 +01:00
Jonathan Brouwer fd38ec4690 Rollup merge of #152907 - aerooneqq:delegation-generics-new-tests, r=petrochenkov
Add tests for delegation generics

This PR adds tests from rust-lang/rust#151864 as discussed in this [comment](https://github.com/rust-lang/rust/pull/151864#issuecomment-3928053049). Part of rust-lang/rust#118212.

The majority of new tests are added in `mapping` folder, (`ast-hir-engine` folder in rust-lang/rust#151864), those tests test mapping between generic params of delegee and our generated function for delegation (that is why the name of the folder was changed, I think it better reflects what those tests testing). In each mapping test comments were added to each test case and one comment describing the goal of mapping tests was added at the top of each file.

Next, tests for defaults in generic params (`generic-params-defaults.rs`), params with the same name (`generic-params-same-names`), errors in providing user-specified generic args (`generics-gen-args-errors.rs`) and wrong signature of a generated function in impl trait case (`impl-trait-wrong-args-count.rs`, renamed from `wrong-args-count-ice.rs` in rust-lang/rust#151864). `generic-aux-pass.rs` test was not added, as all reuses in this test produce known ICE `DefId::expect_local DefId(..) isn't local` rust-lang/rust#143498 (which will be fixed in rust-lang/rust#151864, however it will not close mentioned issue, as synthetic generic params are not yet supported in new generics implementation).

r? @petrochenkov
2026-02-20 22:00:57 +01:00
Jonathan Brouwer 07b3734dbe Rollup merge of #152769 - Kobzol:try-builds-fail-fast, r=marcoieni
Do not cancel try builds after first job failure

Suggested by @ZuseZ4, who was doing a bunch of parallel try builds recently.

r? @marcoieni
2026-02-20 22:00:56 +01:00
Jonathan Brouwer bbce734ce0 Rollup merge of #152527 - bjorn3:remove_z_emit_thin_lto, r=cuviper
Remove -Zemit-thin-lto flag

As far as I can tell it was introduced in https://github.com/rust-lang/rust/pull/98162 to allow fat LTO with `-Clinker-plugin-lto`. In https://github.com/rust-lang/rust/pull/136840 a change was made to automatically disable ThinLTO summary generation when `-Clinker-plugin-lto -Clto=fat` is used, so we can safely remove it.

Fixes rust-lang/rust#152490
2026-02-20 22:00:56 +01:00
Jonathan Brouwer 1706756052 Rollup merge of #152241 - hoodmane:wasm-unwind-link-cpp-exception, r=alexcrichton
For panic=unwind on Wasm targets, define __cpp_exception tag

Since llvm/llvm-project#159143, llvm no longer weak links the __cpp_exception tag into each object that uses it. They are now defined in compiler-rt. Rust doesn't seem to get them from compiler-rt so llvm decides they need to be imported. This adds them to libunwind.

Same changes applied to compiler-builtins: https://github.com/rust-lang/compiler-builtins/pull/1077

See https://github.com/wasm-bindgen/wasm-bindgen/pull/4938 for a downstream workaround.

cc @sbc100
2026-02-20 22:00:55 +01:00
Jonathan Brouwer ff7d14e17d Rollup merge of #146972 - mu001999-contrib:fix/use-dollar-crate, r=petrochenkov
Support importing path-segment keyword with renaming

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/146972)*

#### Reference PR

- https://github.com/rust-lang/reference/pull/2010
- https://github.com/rust-lang/reference/pull/2136

#### Description

This PR unifies and extends the behavior of importing path-segment keywords (`crate`/`$crate`/`super`/`self`), resolving several long-standing inconsistencies.

Previously, Rust only allowed `use crate as name;` without renaming support for other path keywords. This PR enables importing these keywords with explicit renaming. And it also denies importing these keywords without renaming.

##### What's now allowed

For **`crate`** and **`$crate`**:
- `use crate as name;`
- `use crate::{self as name};`
- `use $crate as name;`
- `use $crate::{self as name};`

For **`super`** (including chained `super::super`):
- `use super as name;`
- `use super::{self as name};`
- `use super::super as name;`
- `use super::super::{self as name};`

For **`self`**:
- `use self as name;`
- `use self::{self as name};`

##### Removed error codes

Two error codes are no longer emitted:

- **E0430**: Previously emitted for duplicate `self` imports like `std::fmt::{self, self}`. The existing E0252 ("name defined multiple times") provides sufficient guidance.
- **E0431**: Previously emitted for `use {self [as name]};` and `use ::{self [as name]};`. These patterns are now allowed or denied but with new clearer errors.
    - For `use {self as name};` and `use ::{self as name};` (in edition 2015), they are allowed now and equivalent to `use crate as name`;
    - For `use {self};` and `use ::{self};` (in edition 2015) without renaming, they are equivalent to `use crate;`, the new clearer error suggests adding an explicit rename.
    - For `use ::{self [as name]};` after edition 2015, it is equivalent to `use ${extern-prelude} [as name];`, it is denied with new errors.

##### Future

We plan to remove error [E0429](https://doc.rust-lang.org/stable/error_codes/E0429.html#error-code-e0429) and support `self` at the end of paths (https://github.com/rust-lang/rust/pull/146972#issuecomment-3719825627). This language extension and lint for redundant `::self` instead of hard error `E0429` will be landed separately in the future.

---

Fixes rust-lang/rust#29036
Fixes rust-lang/rust#35612
Fixes rust-lang/rust#37156
Fixes rust-lang/rust#146967
Fixes rust-lang/rust#149811

r? petrochenkov
2026-02-20 22:00:54 +01:00
Jonathan Brouwer fb6d93917e Rollup merge of #146832 - Natural-selection1:not-in-chains, r=petrochenkov
Not linting irrefutable_let_patterns on let chains

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/146832)*

# Description

this PR makes the lint `irrefutable_let_patterns` not check for `let chains`,
only check for single `if let`, `while let`, and `if let guard`.

# Motivation

Since `let chains` were stabilized, the following code has become common:

```rust
fn max() -> usize { 42 }

fn main() {
    if let mx = max() && mx < usize::MAX { /* */ }
}
```

This code naturally expresses "please call that function and then do something if the return value satisfies a condition".
Putting the let binding outside the if would be bad as then it remains in scope after the if, which is not the intent.

Current Output:

```bash
warning: leading irrefutable pattern in let chain
 --> src/main.rs:7:8
  |
7 |     if let mx = max() && mx < usize::MAX {
  |        ^^^^^^^^^^^^^^
  |
  = note: this pattern will always match
  = help: consider moving it outside of the construct
  = note: `#[warn(irrefutable_let_patterns)]` on by default
```

Another common case is progressively destructuring a struct with enum fields, or an enum with struct variants:

```rust
struct NameOfOuterStruct {
    middle: NameOfMiddleEnum,
    other: (),
}
enum NameOfMiddleEnum {
    Inner(NameOfInnerStruct),
    Other(()),
}
struct NameOfInnerStruct {
    id: u32,
}

fn test(outer: NameOfOuterStruct) {
    if let NameOfOuterStruct { middle, .. } = outer
        && let NameOfMiddleEnum::Inner(inner) = middle
        && let NameOfInnerStruct { id } = inner
    {
        /* */
    }
}
```

Current Output:

```bash
warning: leading irrefutable pattern in let chain
  --> src\main.rs:17:8
   |
17 |     if let NameOfOuterStruct { middle, .. } = outer
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this pattern will always match
   = help: consider moving it outside of the construct
   = note: `#[warn(irrefutable_let_patterns)]` on by default

warning: trailing irrefutable pattern in let chain
  --> src\main.rs:19:12
   |
19 |         && let NameOfInnerStruct { id } = inner
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this pattern will always match
   = help: consider moving it into the body
```

To avoid the warning, the readability would be much worse:

```rust
fn test(outer: NameOfOuterStruct) {
    if let NameOfOuterStruct {
        middle: NameOfMiddleEnum::Inner(NameOfInnerStruct { id }),
        ..
    } = outer
    {
        /* */
    }
}
```

# related issue

* rust-lang/rust#139369

# possible questions

1. Moving the irrefutable pattern at the head of the chain out of it would cause a variable that was intended to be temporary to remain in scope, so we remove it.
   However, should we keep the check for moving the irrefutable pattern at the tail into the body?

2. Should we still lint `entire chain is made up of irrefutable let`?

---

This is my first time contributing non-documentation code to Rust. If there are any irregularities, please feel free to point them out.
: )
2026-02-20 22:00:54 +01:00
Makai 279b8cd822 Skip Debug on use_existential_projection_new_instead 2026-02-21 00:43:29 +08:00
bors 0376d43d44 Auto merge of #152904 - JonathanBrouwer:rollup-8vFeFeZ, r=JonathanBrouwer
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#152759 (Simpler `find_attr!()`)
 - rust-lang/rust#152057 (bootstrap: respect POSIX jobserver)
 - rust-lang/rust#152818 (DOC: do not link to "nightly" in Iterator::by_ref() docstring)
 - rust-lang/rust#152840 (Add bootstrap snapshot tests for {`install`, `install src`})
 - rust-lang/rust#152844 (Rename `DepGraphQuery` to `RetainedDepGraph`)
 - rust-lang/rust#152846 (Clarify some variable names in the query proc-macro)
 - rust-lang/rust#152858 (Fix typo in doc for core::mem::type_info::Struct)
 - rust-lang/rust#152861 (resolve: do not suggest `_` for unresolved imports)
 - rust-lang/rust#152873 (std::ops::ControlFlow - use "a" before `Result`)
 - rust-lang/rust#152877 (std::ops::ControlFlow - use normal comment for internal methods)
 - rust-lang/rust#152883 (Deny final not followed by item)
2026-02-20 16:26:56 +00:00
hkalbasi 1ded3a641c Expose Span for all DefIds in rustc_public 2026-02-20 17:59:47 +03:30
reucru01 a561a4b8e1 Errors on illegal SV init 2026-02-20 14:24:08 +00:00
aerooneqq 7348ffbfbf Add tests 2026-02-20 16:13:02 +03:00
Jonathan Brouwer a196a001b3 Rollup merge of #152883 - mu001999-contrib:fix/final-bad-use, r=Kivooeo
Deny final not followed by item

Fixes rust-lang/rust#152820
2026-02-20 13:25:01 +01:00
Jonathan Brouwer a2abf2a018 Rollup merge of #152877 - DanielEScherzer:patch-3, r=scottmcm
std::ops::ControlFlow - use normal comment for internal methods

Rather than a doc comment, which causes rustdoc to output the impl documentation even though the impl block only has non-public methods.
2026-02-20 13:25:00 +01:00
Jonathan Brouwer be340852ba Rollup merge of #152873 - DanielEScherzer:patch-2, r=jhpratt
std::ops::ControlFlow - use "a" before `Result`

Rather than "an"
2026-02-20 13:24:59 +01:00
Jonathan Brouwer c013bcca0b Rollup merge of #152861 - ozankenangungor:fix-underscore-import-suggestion, r=Kivooeo
resolve: do not suggest `_` for unresolved imports

Fix invalid unresolved-import suggestion when a module contains an item named `_`.

`use _` is never valid syntax, so `_` should not be suggested as a similar name.

Closes rust-lang/rust#152812
2026-02-20 13:24:59 +01:00
Jonathan Brouwer e21941a20b Rollup merge of #152858 - apasel422:patch-1, r=oli-obk
Fix typo in doc for core::mem::type_info::Struct
2026-02-20 13:24:58 +01:00
Jonathan Brouwer 412b0c3efc Rollup merge of #152846 - Zalathar:query-proc-macro, r=nnethercote
Clarify some variable names in the query proc-macro

These are some cleanups to the `rustc_macros::query`, extracted from https://github.com/rust-lang/rust/pull/152833.

r? nnethercote
2026-02-20 13:24:58 +01:00
Jonathan Brouwer eb5f275181 Rollup merge of #152844 - Zalathar:retain-dep-graph, r=JonathanBrouwer
Rename `DepGraphQuery` to `RetainedDepGraph`

This is a revised subset of https://github.com/rust-lang/rust/pull/152836 that only performs an internal renaming, and does not touch the `-Zquery-dep-graph` flag.

The new name and comments for `RetainedDepGraph` should hopefully do a better job of communicating that it is not used in normal compiler operation, even in incremental mode.
2026-02-20 13:24:57 +01:00
Jonathan Brouwer 29871ea667 Rollup merge of #152840 - jieyouxu:bootstrap-install-src-no-docs, r=clubby789
Add bootstrap snapshot tests for {`install`, `install src`}

And `install src` with `build.docs = false`.

This is mostly to get coverage for the baseline to make it easier to review rust-lang/rust#150845.
2026-02-20 13:24:57 +01:00
Jonathan Brouwer cfc274c3bc Rollup merge of #152818 - mgeier:doc-by_ref-link, r=scottmcm
DOC: do not link to "nightly" in Iterator::by_ref() docstring

I happened to see that the link in the docstring https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.by_ref points to the "nightly" docs instead of "stable".

I'm not sure if my fix actually works because I didn't get `cargo doc` to run on my local computer.
2026-02-20 13:24:56 +01:00
Jonathan Brouwer 12c80d252d Rollup merge of #152057 - haampie:hs/fix/bootstrap-respect-jobserver-protocol, r=clubby789
bootstrap: respect POSIX jobserver

When bootstrapping Rust, the `-j N` flag was passed to CMake, which was
then forwarded to Ninja. This prevents the jobserver from being used,
and as a result leads to oversubscription when Rust is just one of the
many packages built as part of a larger software stack.

Since Cargo and the Rust compiler have long supported the jobserver, it
would be good if also bootstrapping Rust itself would participate in the
protocol, leading to composable parallelism.

This change allows bootstrapping to respect an existing FIFO based
jobserver. Old pipe based jobservers are not supported, because they are
brittle: currently the Python scripts in bootstrap do not inherit the
file descriptors, but do pass on `MAKEFLAGS`, which has lead to errors
like "invalid file descriptor" in the past. Because Ninja only supports
FIFO based jobservers, it's better to focus on new jobservers only,
which shouldn't suffer from the "invalid file descriptor" issue.

In summary:

* Bootstrap Cargo passes `MAKEFLAGS` verbatim to subprocesses if it
  advertises a FIFO style jobserver, otherwise it unsets it. This ensures
  subprocesses respect the jobserver during bootstrap.
* `llvm.rs` does not pass `-j` to `cmake` when a FIFO style jobserver is
  set in `MAKEFLAGS`. This ensures Ninja respects the jobserver.
* Bootstrap Cargo no longer unsets `MKFLAGS`: from git blame, GNU Make
  considered it a historical artifact back in 1992, and it is never read
  by GNU Make, it's only set for backwards compatibility in case sub-Makefiles
  read it.

---

I've tested this with the [Spack package manager](https://github.com/spack/spack) starting the POSIX jobserver,
building node.js and rust in parallel with `-j16`, which looks like this:

```console
$ pstree 382710
python3─┬─python3
        └─python3─┬─python3─┬─make───make───6*[ccache───g++───cc1plus]
                  │         └─{python3}
                  └─python3─┬─python3.11───bootstrap───cmake───ninja-build───10*[sh───ccache───g++───cc1plus]
                            └─{python3}
```

As you can see there are 10 `g++` processes running for rust, and `6` for node.js, and
with a mix of `make` and `ninja` as build tools :).

(The only violation I see now is `rust-lld`, but I think that'll be fixed with the LLVM 23
release)
2026-02-20 13:24:56 +01:00
Jonathan Brouwer c0fe6943ae Rollup merge of #152759 - jdonszelmann:simpler-get-attrs, r=jonathanbrouwer
Simpler `find_attr!()`

r? @JonathanBrouwer
cc: @jyn514
2026-02-20 13:24:55 +01:00
bjorn3 c51cd0e691 Deduplicate some code in LLVMRustOptimize 2026-02-20 12:19:41 +00:00
bjorn3 6366a698e3 Remove -Zemit-thin-lto flag
As far as I can tell it was introduced to allow fat LTO with
-Clinker-plugin-lto. Later a change was made to automatically disable
ThinLTO summary generation when -Clinker-plugin-lto -Clto=fat is used,
so we can safely remove it.
2026-02-20 12:19:41 +00:00
Zalathar 19e0c62e10 Rename DepGraphQuery to RetainedDepGraph 2026-02-20 20:55:09 +11:00
Jana Dönszelmann 8e7bc3c7d1 fix src/tools 2026-02-20 10:35:52 +01:00
Jana Dönszelmann df23df54a6 tidy 2026-02-20 09:50:55 +01:00
Jana Dönszelmann be4f92fc45 emit unreachable pattern lint 2026-02-20 09:50:16 +01:00
Jana Dönszelmann decec173ec remove AttributeKind everywhere 2026-02-20 09:50:16 +01:00
Jana Dönszelmann 2bed584742 add lint for using AttributeKind in find_attr 2026-02-20 09:50:16 +01:00
Jana Dönszelmann a2367eca47 star-import AttributeKind 2026-02-20 09:50:16 +01:00
Jana Dönszelmann 04f762d842 allow deprecated for some valid uses 2026-02-20 09:50:16 +01:00
Jana Dönszelmann 54d673dd69 deprecate functions 2026-02-20 09:50:16 +01:00
Jana Dönszelmann 7477a5b48e update docs 2026-02-20 09:50:16 +01:00
Jana Dönszelmann 9a9443950d change all uses 2026-02-20 09:50:16 +01:00
Jana Dönszelmann 07f46cec49 Convenience matcher in find_attrs for crate attrs 2026-02-20 09:50:16 +01:00
Jana Dönszelmann 63edc913fa change all uses 2026-02-20 09:50:16 +01:00
Jana Dönszelmann c3fe049a25 change find_attr macro to search tcx.get_all_attrs automatically 2026-02-20 09:50:16 +01:00
bors 59fd4ef94d Auto merge of #152747 - nnethercote:bring-back-enum-DepKind, r=Zalathar
Bring back `enum DepKind`.

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152747)*

It was removed in rust-lang/rust#115920 to enable it being moved to `rustc_query_system`, a move that has recently been reversed. It's much simpler as an enum.

r? @Zalathar
2026-02-20 06:07:20 +00:00
mu001999 59781157a7 Deny final not followed by item 2026-02-20 12:12:21 +08:00