Commit Graph

24440 Commits

Author SHA1 Message Date
Jacob Pratt 3574d5748e Rollup merge of #154264 - rustbot:docs-update, r=ehuss
Update books

## rust-embedded/book

1 commits in e88aa4403b4bf2071c8df9509160477e40179099..2463edeb8003c5743918b3739a9f6870b86396f5
2026-03-11 17:49:58 UTC to 2026-03-11 17:49:58 UTC

- Update teaching material duration for bare-metal Rust (rust-embedded/book#409)

## rust-lang/reference

7 commits in c49e89cc8c7c2c43ca625a8d5b7ad9a53a9ce978..7446bf9697c95d155eef33c6a9d91fbd29a5e359
2026-03-18 01:46:01 UTC to 2026-03-10 18:10:22 UTC

- Update `must_use` to use the attribute template (rust-lang/reference#1892)
- Add a rule that enum discriminants may not use generic parameters (rust-lang/reference#2206)
- Actually move out of Box in moving-out-of-Box test (rust-lang/reference#2204)
- Add special cases and links relating to dereferencing boxes (rust-lang/reference#2075)
- Move shebang into its own subchapter (rust-lang/reference#2199)
- Fields of enums and unions should be allowed to overlap (rust-lang/reference#2168)
- [type layout] Clarify size and alignment of pointers to unsized types (rust-lang/reference#2201)
2026-03-23 23:42:52 -04:00
Jacob Pratt 429c8d4ffb Rollup merge of #154017 - GuillaumeGomez:duplicated-locs-scraped, r=Urgau
Fix invalid add of duplicated call locations for the rustdoc scraped examples feature

Fixes rust-lang/rust#153837.

The bug was visible in the highlighting of the scrape examples code samples: the same part of the code was marked as "highlight" (by the scraped examples feature) twice, eventually leading to a wrong state of the HTML DOM status.

To fix the bug, I added a set to not re-add a location if it's already present.

r? @Urgau
2026-03-23 23:42:52 -04:00
Jacob Pratt 8a2bd0fe2f Rollup merge of #153964 - GuillaumeGomez:fix-trait-impl-doc-cfg, r=lolbinarycat
Fix `doc_cfg` not working as expected on trait impls

Fixes https://github.com/rust-lang/rust/issues/153655.

I spent waaaaay too much time on this fix. So the current issue is that rustdoc gets its items in two passes:
1. All items
2. Trait/blanket/auto impls

Because of that, the trait impls are not stored "correctly" in the rustdoc AST, meaning that the `propagate_doc_cfg` pass doesn't work correctly on them. So initially, I tried to "clean" the impls at the same time as the other items. However, it created a monstruous amount of bugs and issues and after two days, I decided to give up on this approach (might be worth fixing that in the future!). You can see what I tried [here](https://github.com/rust-lang/rust/compare/main...GuillaumeGomez:trait-impls-doc_cfg?expand=1).

So instead, since the impls are stored at the end, I create placeholders for impls and in `propagate_doc_cfg`, I store the `cfg` "context" (more clear when reading the code 😛) and re-use it later on when the "real" impl comes up.

r? @lolbinarycat
2026-03-23 23:42:49 -04:00
bors 6f22f61305 Auto merge of #154273 - JonathanBrouwer:rollup-TJZsnIo, r=JonathanBrouwer
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#122668 (Add APIs for dealing with titlecase)
 - rust-lang/rust#153041 (Remove `ATTRIBUTE_ORDER`)
 - rust-lang/rust#153912 (Avoid prematurely choosing a glob import)
 - rust-lang/rust#154093 (const validity checking: do not recurse to references inside MaybeDangling)
 - rust-lang/rust#154257 (Revert eagerly normalize in generalize)
 - rust-lang/rust#154179 (tests/ui/async-await/gat-is-send-across-await.rs: New regression test)
 - rust-lang/rust#154224 (Remove more `BuiltinLintDiag` variants)
 - rust-lang/rust#154245 (Allow applying autodiff macros to trait functions.)
2026-03-23 22:28:18 +00:00
Eric Huss ae3d87c2a8 Update shebang reference names
This updates the rule names for shebang which were changed in
https://github.com/rust-lang/reference/pull/2192 and
https://github.com/rust-lang/reference/pull/2199.
2026-03-23 14:28:42 -07:00
Guillaume Gomez 73fe4c5a3b Add regression test for #153655 2026-03-23 21:25:46 +01:00
Jonathan Brouwer a9b484936c Rollup merge of #154245 - ZuseZ4:autodiff-trait-support, r=JonathanBrouwer,jdonszelmann
Allow applying autodiff macros to trait functions.

It will use enzyme to generate a default derivative implementation, which can be overwritten by the user.

closes: https://github.com/rust-lang/rust/issues/153329

r? @JonathanBrouwer
2026-03-23 20:18:36 +01:00
Jonathan Brouwer e158c29ec9 Rollup merge of #154179 - Enselic:gat-is-send-across-await, r=petrochenkov
tests/ui/async-await/gat-is-send-across-await.rs: New regression test

The test began passing in `nightly-2025-10-16`. Probably by c50aebba78 (rust-lang/rust#144064) because it fixed two "does not live long enough" errors. The test fails to compile with `nightly-2025-10-15` with such an error:

    $ rustc +nightly-2025-10-15 --edition 2018 tests/ui/async-await/gat-is-send-across-await.rs
    error: `impl G` does not live long enough
      --> tests/ui/async-await/gat-is-send-across-await.rs:16:24
       |
    16 |       let _: &dyn Send = &async move {
       |  ________________________^
    17 | |         let _gat = g.as_gat();
    18 | |         async{}.await
    19 | |     };
       | |_____^

Closes rust-lang/rust#111852 since that's where the test comes from.
2026-03-23 20:18:35 +01:00
Jonathan Brouwer 7f8f600807 Rollup merge of #154257 - jdonszelmann:revert-eagerly-normalize-in-generalize, r=lcnr
Revert eagerly normalize in generalize

r? @lcnr

Reverts https://github.com/rust-lang/rust/pull/151746

We'll likely pull eager normalization out of generalization

Fixes rust-lang/rust#154173
Fixes rust-lang/rust#154244
2026-03-23 20:18:34 +01:00
Jonathan Brouwer 62a3eab283 Rollup merge of #154093 - RalfJung:validity-maybedangling, r=WaffleLapkin
const validity checking: do not recurse to references inside MaybeDangling

This arguably should be allowed, but we currently reject it:
```rust
#![feature(maybe_dangling)]
use std::mem::MaybeDangling;

const X: MaybeDangling<&bool> = unsafe { std::mem::transmute(&5u8) };
```

r? @WaffleLapkin
2026-03-23 20:18:34 +01:00
Jonathan Brouwer 924b91147b Rollup merge of #153912 - mu001999-contrib:fix-153842, r=petrochenkov
Avoid prematurely choosing a glob import

Fixes rust-lang/rust#153842

Use the following without introducing trait to explain:
```rust
mod a {
    pub use crate::x::y as x; // single import #1
}

mod b {
    pub mod x {
        pub mod y {}
    }
}

use a::x; // single import #2
use b::*; // glob import #3

fn main() {}
```

In current implementation, when `#1` is first resolved, `crate::x` is temporarily taken from glob import `#3` as `crate::b::x`. This happens because `single_import_can_define_name` will see that `#2` cannot define `x` (because it depends on `#1` and `#1` is ignored) and then return `false`. Later, during finalization, `crate::x` in `#1` resolves through single import `#2` instead, which no longer matches the initially cached module `crate::b::x` and triggers the ICE.

I think the resolver should keep this unresolved because `#2` may still define `x` to avoid prematurely choosing a glob import.

r? petrochenkov
2026-03-23 20:18:33 +01:00
Jonathan Brouwer 7011667a9f Rollup merge of #153041 - JonathanBrouwer:attribute_order, r=jdonszelmann
Remove `ATTRIBUTE_ORDER`

r? @jdonszelmann

There's only a few attributes that use `KeepInnermost` and I think I like the consistency of just making them all `KeepOutermost`
2026-03-23 20:18:33 +01:00
bors f66622c7ec Auto merge of #152931 - khyperia:always-check-constarghastype, r=BoxyUwU
Always check `ConstArgHasType` even when otherwise ignoring



fixes https://github.com/rust-lang/rust/issues/149774

helping @BoxyUwU finish up https://github.com/rust-lang/rust/pull/150322, this is a simple tweak/finishing-up of that PR.

this is a breaking change that crater detected has some issues with in Boxy's PR, and hence needs a t-types FCP. I can go and help fix those crates if/once the break is signed off on.
2026-03-23 19:06:58 +00:00
bors eb9d3caf05 Auto merge of #154253 - JonathanBrouwer:rollup-LLZUsz2, r=JonathanBrouwer
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#154241 (`rust-analyzer` subtree update)
 - rust-lang/rust#153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets)
 - rust-lang/rust#154105 (bootstrap: Pass `--features=rustc` to rustc_transmute)
 - rust-lang/rust#153069 ([BPF] add target feature allows-misaligned-mem-access)
 - rust-lang/rust#154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer)
 - rust-lang/rust#154191 (refactor RangeFromIter overflow-checks impl)
 - rust-lang/rust#154207 (Refactor query loading)
 - rust-lang/rust#153540 (drop derive helpers during attribute parsing)
 - rust-lang/rust#154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.)
 - rust-lang/rust#154161 (On E0277 tweak help when single type impls traits)
 - rust-lang/rust#154218 (interpret/validity: remove unreachable error kind)
 - rust-lang/rust#154225 (diagnostics: avoid ICE in confusable_method_name for associated functions)
 - rust-lang/rust#154228 (Improve inline assembly error messages)
2026-03-23 15:46:13 +00:00
Jonathan Brouwer 0e4a759501 Fix link_ordinal test 2026-03-23 14:00:22 +01:00
Jonathan Brouwer 34ef9a6146 Remove ATTRIBUTE_ORDER 2026-03-23 13:57:23 +01:00
Jana Dönszelmann e28b48565f add regression test 2026-03-23 12:16:14 +01:00
Jonathan Brouwer 64716caf69 Rollup merge of #154182 - Unique-Usman:ua/constnotype2, r=estebank
diagnostics: avoid ICE for undeclared generic parameter in impl

Avoid an ICE for:

    struct A;
    impl A<B> {}

The compiler no longer panics and can proceed to emit existing diagnostics.

Adds `tests/ui/missing/undeclared-generic-parameter.rs`.

Fixes rust-lang/rust#154165 and introduced by rust-lang/rust#152913
2026-03-23 12:15:00 +01:00
Jonathan Brouwer 82dda891d4 Rollup merge of #154174 - cyrgani:incomplete-mcp, r=JonathanBrouwer
allow `incomplete_features` in most UI tests

This PR allows the `incomplete_features` lint for all UI tests except for the three directories with the largest number of tests (`traits`, `specialization` and `const-generics`) triggering this lint to keep the size of this PR manageable. The remaining three directories will be handled in followup PRs.

Part of https://github.com/rust-lang/rust/issues/154168.
2026-03-23 12:14:59 +01:00
Jonathan Brouwer 364844d8a0 Rollup merge of #154167 - ujjwalvishwakarma2006:move-lto-tests, r=Kivooeo
ui/lto: move and rename two tests from issues/

Move:
- `tests/ui/issues/issue-44056.rs` -> `tests/ui/lto/lto-avx-target-feature.rs`
    - The first test enables both AVX target features and LTO but does not exercise AVX-specific behavior. The test primarily checks that LTO builds successfully with these flags; place it under `ui/lto` for consistency.
- `tests/ui/issues/issue-51947.rs` -> `tests/ui/lto/lto-weak-merge-functions.rs`
    - The second test exercises weak linkage interacting with LTO (merge-functions), so it should belong in `ui/lto`.

I have also added a commented line at the top of each test file indicating the issue it originated from.
2026-03-23 12:14:59 +01:00
Jonathan Brouwer a87d694af2 Rollup merge of #150630 - Mark-Simulacrum:rephrase-compression-warn, r=JonathanBrouwer
Unknown -> Unsupported compression algorithm

Both zstd and zlib are *known* compression algorithms, they just may not be supported by the backend. We shouldn't mislead users into e.g. thinking they made a typo.

cc https://github.com/rust-lang/rust/issues/120953
2026-03-23 12:14:55 +01:00
Jonathan Brouwer 699e1b395e Rollup merge of #153931 - cyrgani:old-consts, r=Mark-Simulacrum
remove usages of to-be-deprecated numeric constants

Split out from rust-lang/rust#146882.
2026-03-23 12:14:55 +01:00
Jonathan Brouwer 7d43ebc519 Rollup merge of #153312 - b-naber:namespaced-crate-names-pt1, r=petrochenkov
Packages as namespaces part 1

Part 1 of https://github.com/rust-lang/rust/pull/152299

r? @petrochenkov
2026-03-23 12:14:52 +01:00
Jonathan Brouwer b20e49f5e6 Rollup merge of #152543 - petrochenkov:rprivtit2, r=fmease
privacy: Fix type privacy holes in RPITITs

A subset of https://github.com/rust-lang/rust/pull/146470.

Private types in RPITITs now report hard errors.
Private types in bounds of associated types still only report the `private_bounds` lint due to unacceptable amount of breakage (https://github.com/rust-lang/rust/pull/146470#issuecomment-3682850214).

Closes https://github.com/rust-lang/rust/issues/144139
2026-03-23 12:14:51 +01:00
Jana Dönszelmann 34a8766575 Revert "Regression test for trait-system-refactor#262"
This reverts commit 244b6d5ca8.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann e613b82e4e Revert "bless some tests"
This reverts commit 6edf58fab8.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann 1fa1611e9f Revert "address review"
This reverts commit d665c0b371.
2026-03-23 12:09:34 +01:00
Jonathan Brouwer 1448ab91d2 Rollup merge of #154228 - folkertdev:mention-invalid-template-modifier, r=nnethercote
Improve inline assembly error messages

by

- using `DiagSymbolList` to get nicely formatted lists
- mentioning the `modifier` when an invalid modifier is used. This is useful in case the span cannot be resolved (which I ran into).
2026-03-23 12:01:03 +01:00
Jonathan Brouwer 50018abcdb Rollup merge of #154225 - Unique-Usman:ua/rustc_confusable, r=Kivooeo
diagnostics: avoid ICE in confusable_method_name for associated functions

Avoid unconditionally slicing `inputs()[1..]`, which assumes a `self` parameter. Use `is_method()` to conditionally skip the receiver, preventing out-of-bounds access and fixing suggestions for associated functions.
2026-03-23 12:01:02 +01:00
Jonathan Brouwer 773db3e325 Rollup merge of #154161 - estebank:e0277-ty-impls, r=Kivooeo
On E0277 tweak help when single type impls traits

When encountering an unmet predicate, when we point at the trait impls that do exist, if they are all for the same self type, tweak the wording to make it less verbose.
2026-03-23 12:01:01 +01:00
Jonathan Brouwer 37d76a5e0a Rollup merge of #153540 - scrabsha:sasha/drop-derive-helpers, r=jdonszelmann
drop derive helpers during attribute parsing
2026-03-23 12:01:00 +01:00
Jonathan Brouwer 61b4c77781 Rollup merge of #154191 - pitaj:fix-154124, r=tgross35
refactor RangeFromIter overflow-checks impl

Crates with different overflow-checks settings accessing the same RangeFromIter resulted in incorrect values being yielded

Fixes rust-lang/rust#154124

r? @tgross35
2026-03-23 12:00:59 +01:00
Jonathan Brouwer 9e25329fd6 Rollup merge of #154085 - aytey:fix-at-or-pattern-parens, r=chenyukang
Parenthesize or-patterns in prefix pattern positions in pretty printer

The AST pretty printer was dropping parentheses around or-patterns when they appeared inside `@` bindings, `&` references, or `box` patterns. For example:

- `v @ (1 | 2 | 3)` was printed as `v @ 1 | 2 | 3`
- `&(1 | 2 | 3)` was printed as `&1 | 2 | 3`
- `box (1 | 2 | 3)` was printed as `box 1 | 2 | 3`

Since `|` has the lowest precedence among pattern operators, all of these are parsed incorrectly without parentheses — e.g. `v @ 1 | 2 | 3` becomes `(v @ 1) | 2 | 3`, binding `v` only to the first alternative.

This caused E0408 ("variable not bound in all patterns") when the expanded output was fed back to the compiler, affecting crates like html5ever and wgpu-core that use macros expanding to or-patterns after `@`.

The fix adds a `print_pat_paren_if_or` helper that wraps `PatKind::Or` subpatterns in parentheses, and uses it in the `@`, `&`, and `box` printing arms. This is similar in spirit to the existing `FixupContext` parenthesization approach used for expression printing.

## Example

**before** (`rustc 1.96.0-nightly (3b1b0ef4d 2026-03-11)`):

```rust
#![feature(prelude_import)]
#![no_std]
#![feature(box_patterns)]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;

//@ pretty-compare-only
//@ pretty-mode:expanded
//@ pp-exact:or-pattern-paren.pp

macro_rules! or_pat { ($($name:pat),+) => { $($name)|+ } }

fn check_at(x: Option<i32>) {
    match x {
        Some(v @ 1 | 2 | 3) =>

            {
            ::std::io::_print(format_args!("{0}\n", v));
        }
        _ => {}
    }
}
fn check_ref(x: &i32) { match x { &1 | 2 | 3 => {} _ => {} } }
fn check_box(x: Box<i32>) { match x { box 1 | 2 | 3 => {} _ => {} } }
fn main() { check_at(Some(2)); check_ref(&1); check_box(Box::new(1)); }
```

**after** (this branch):

```rust
#![feature(prelude_import)]
#![no_std]
#![feature(box_patterns)]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;

//@ pretty-compare-only
//@ pretty-mode:expanded
//@ pp-exact:or-pattern-paren.pp

macro_rules! or_pat { ($($name:pat),+) => { $($name)|+ } }

fn check_at(x: Option<i32>) {
    match x {
        Some(v @ (1 | 2 | 3)) =>

            {
            ::std::io::_print(format_args!("{0}\n", v));
        }
        _ => {}
    }
}
fn check_ref(x: &i32) { match x { &(1 | 2 | 3) => {} _ => {} } }
fn check_box(x: Box<i32>) { match x { box (1 | 2 | 3) => {} _ => {} } }
fn main() { check_at(Some(2)); check_ref(&1); check_box(Box::new(1)); }
```

Notice `v @ 1 | 2 | 3` becomes `v @ (1 | 2 | 3)`, `&1 | 2 | 3` becomes `&(1 | 2 | 3)`, and `box 1 | 2 | 3` becomes `box (1 | 2 | 3)`. Without parens, the or-pattern binds incorrectly — only the first alternative gets the `@`/`&`/`box`, causing E0408.
2026-03-23 12:00:59 +01:00
Jonathan Brouwer 8b69918e72 Rollup merge of #153069 - blueshift-gg:BPF_unaligned, r=chenyukang
[BPF] add target feature allows-misaligned-mem-access

This PR adds the allows-misaligned-mem-access target feature to the BPF target. The feature can enable misaligned memory access support in the LLVM backend, aligning Rust’s BPF target behavior with the corresponding LLVM update introduced in [llvm/llvm-project#167013](https://github.com/llvm/llvm-project/pull/167013) (included in LLVM 22).
2026-03-23 12:00:58 +01:00
Manuel Drehwald 26c9f7255a Allow applying autodiff macros to trait functions.
It will use enzyme to generate a default derivative implementation,
which can be overwritten by the user.
2026-03-23 11:27:15 +01:00
Folkert de Vries 6f08437788 improve inline assembly error messages
by

- using `DiagSymbolList` to get nicely formatted lists
- mentioning the `modifier` when an invalid modifier is used. This is useful in case the span cannot be resolved (which I ran into).
2026-03-22 23:18:29 +01:00
Usman Akinyemi fa3e85a7e8 diagnostics: avoid ICE in confusable_method_name for associated functions
Avoid unconditionally slicing `inputs()[1..]`, which assumes a `self`
parameter. Use `is_method()` to conditionally skip the receiver,
preventing out-of-bounds access and fixing suggestions for associated
functions.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-03-23 01:50:44 +05:30
Peter Jaszkowiak 8befc9d082 refactor RangeFromIter overflow-checks impl
Crates with different overflow-checks settings accessing the same RangeFromIter resulted in incorrect values being yielded
2026-03-22 13:31:50 -06:00
Mark Rousskov 6458ca5349 Unknown -> Unsupported compression algorithm
Both zstd and zlib are *known* compression algorithms, they just may not
be supported by the backend. We shouldn't mislead users into e.g.
thinking they made a typo.
2026-03-22 08:27:50 -04:00
ujjwalVishwakarma2006 dd2b2084c9 Add comment at the top in two test files referencing the issue they originate from 2026-03-22 15:18:42 +05:30
Sasha Pourcelot 1c6a8feef8 check earlier for attributes that are placed in where predicate 2026-03-22 07:51:23 +00:00
Sasha Pourcelot 5491c3529b check earlier for misused crate-level attributes 2026-03-22 07:51:23 +00:00
cyrgani 9b0be7857a allow incomplete_features in most UI tests 2026-03-21 20:10:07 +00:00
ujjwalVishwakarma2006 9b7dff982e Move and rename LTO-specific test files from tests/ui/issues/ to tests/ui/lto/ 2026-03-22 00:06:06 +05:30
Usman Akinyemi b31dc4ab49 diagnostics: avoid ICE for undeclared generic parameter in impl
Avoid an ICE for:

    struct A;
    impl A<B> {}

The compiler no longer panics and can proceed to emit existing diagnostics.

Adds `tests/ui/missing/undeclared-generic-parameter.rs`.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-03-21 21:54:46 +05:30
Martin Nordholts aed54f219e tests/ui/async-await/gat-is-send-across-await.rs: New regression test
The test began passing in `nightly-2025-10-16`. Probably by c50aebba78
because it fixed two "does not live long enough" errors. The test fails
to compile with `nightly-2025-10-15` with such an error:

    $ rustc +nightly-2025-10-15 --edition 2018 tests/ui/async-await/gat-is-send-across-await.rs
    error: `impl G` does not live long enough
      --> tests/ui/async-await/gat-is-send-across-await.rs:16:24
       |
    16 |       let _: &dyn Send = &async move {
       |  ________________________^
    17 | |         let _gat = g.as_gat();
    18 | |         async{}.await
    19 | |     };
       | |_____^
2026-03-21 16:42:02 +01:00
b-naber e844c24122 resolve namespaced crates with open modules 2026-03-21 12:38:17 +00:00
bors e52f547ed4 Auto merge of #154160 - JonathanBrouwer:rollup-4jbkEbt, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#154154 (Emit fewer errors for incorrect rtn and `=` -> `:` typos in bindings)
 - rust-lang/rust#154155 (tests/ui/async-await/drop-option-future.rs: New regression test)
 - rust-lang/rust#146961 (Allow passing `expr` metavariable as `cfg` predicate)
 - rust-lang/rust#154118 (don't suggest non-deriveable traits for unions)
 - rust-lang/rust#154120 (Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`)
 - rust-lang/rust#154156 (Moving issue-52049 to borrowck)
2026-03-21 07:20:47 +00:00
Esteban Küber 3ad92c9f23 On E0277 tweak help when single type impls traits
When encountering an unmet predicate, when we point at the trait impls that do exist, if they are all for the same self type, tweak the wording to make it less verbose.
2026-03-21 02:24:36 +00:00
Jonathan Brouwer 6d2a545c09 Rollup merge of #154156 - aryannrd:move-issue-52049-to-borrowck, r=Kivooeo
Moving issue-52049 to borrowck
2026-03-21 00:42:49 +01:00