Commit Graph

300570 Commits

Author SHA1 Message Date
bors
e3843659e9 Auto merge of #114669 - cjgillot:metadata-wp, r=petrochenkov
Make metadata a workproduct and reuse it

This PR aims to skip the generation of metadata by reusing the infrastructure that already exists for compiled codegen-units, namely "workproducts".

This can yield substantial gains (~10%) when we can demonstrate that metadata does not change between an incremental session and the next. This is the case if the crate is unchanged, or if all the changes are in upstream crates and have no effect on it. This latter case is most interesting, as it arises regularly for users with several crates in their workspace.

TODO:
- [x] Materialize the fact that metadata encoding relies on the relative order of definitions;
- [x] Refactor the handling of doc links.
2025-07-04 18:06:20 +00:00
Scott McMurray
e0c54c3a9b Rename transmute_immediatetransmute_scalar 2025-07-04 10:35:51 -07:00
vinícius x
babbafb1c1 remove syntaxTree from docs 2025-07-04 14:27:03 -03:00
Lukas Markeffsky
71176a28e6 clean up GVN TypeId test 2025-07-04 19:14:26 +02:00
Ayush Singh
f4ef1a769a std: sys: net: uefi: tcp4: Implement write
A blocking implementation of tcp4 write.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-04 21:53:16 +05:30
Wilfred Hughes
e779ea0ea7 fix: Avoid .unwrap() when running the discover command
Previously, the following configuration in settings.json:

    "rust-analyzer.workspace.discoverConfig": {
        "command": [
            "oops",
            "develop-json",
            "{arg}"
        ],
        "progressLabel": "rust-analyzer",
        "filesToWatch": [
            "BUCK",
            "TARGETS"
        ]
    },

Would previously cause a crash in rust-analyzer:

    thread 'LspServer' panicked at crates/rust-analyzer/src/main_loop.rs:776:84:
    called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }

Instead, use more specific panic messages.
2025-07-04 16:55:53 +01:00
Folkert de Vries
a3277a1bbb test rust calling a C C-variadic function 2025-07-04 17:27:24 +02:00
dianqk
1339b90550 Update LLVM submodule 2025-07-04 23:05:40 +08:00
dianqk
32115c3a17 Add a regression test for ld64 2025-07-04 23:04:56 +08:00
bors
0c4fa2690d Auto merge of #143434 - matthiaskrgr:rollup-eyr4rcb, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#140643 (Refactor StableMIR)
 - rust-lang/rust#143286 (Make -Ztrack-diagnostics emit like a note)
 - rust-lang/rust#143308 (Remove `PointerLike` trait)
 - rust-lang/rust#143387 (Make __rust_alloc_error_handler_should_panic a function)
 - rust-lang/rust#143400 (Port `#[rustc_pass_by_value]` to the new attribute system)
 - rust-lang/rust#143417 (bump termize dep)
 - rust-lang/rust#143420 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-04 14:37:30 +00:00
Ralf Jung
23b3be5ada Merge pull request #4443 from RalfJung/concurrency-ub-detection
declare data race and weak memory support as non-experimental
2025-07-04 14:29:11 +00:00
Matthias Krüger
3a5da6c4d8 Rollup merge of #143420 - Kobzol:rdg-push, r=jieyouxu
rustc-dev-guide subtree update

Subtree update of https://github.com/rust-lang/rustc-dev-guide.

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

r? `@jieyouxu`
2025-07-04 16:22:38 +02:00
Matthias Krüger
8e4cca85b5 Rollup merge of #143417 - klensy:termize, r=jieyouxu
bump termize dep

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

Clippy depends on termize 0.1.1, https://github.com/rust-lang/rust-clippy/pull/15207
2025-07-04 16:22:37 +02:00
Matthias Krüger
f3e7ec5560 Rollup merge of #143400 - GrigorenkoPV:attributes/lints, r=jdonszelmann
Port `#[rustc_pass_by_value]` to the new attribute system

Part of rust-lang/rust#131229

r? `@oli-obk`
2025-07-04 16:22:36 +02:00
Matthias Krüger
2faf66d091 Rollup merge of #143387 - dpaoliello:shouldpanicfn, r=bjorn3
Make __rust_alloc_error_handler_should_panic a function

Fixes rust-lang/rust#143253

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

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

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

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

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

r? `@bjorn3`
2025-07-04 16:22:36 +02:00
Matthias Krüger
2e9b29406a Rollup merge of #143286 - Muscraft:track-diagnostics-note, r=WaffleLapkin
Make -Ztrack-diagnostics emit like a note

[#t-compiler/diagnostics > Rendering -Ztrack-diagnostics like a note](https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/Rendering.20-Ztrack-diagnostics.20like.20a.20note/with/526608647)

As discussed on the Zulip thread above, I want to make `-Ztrack-diagnostics` emit like a `note`. This is because I find its current output jarring, and the fact that it gets rendered completely left-aligned, [even in the middle of a snippet](86e05cd300/tests/ui/track-diagnostics/track6.stderr), seems like something that should be changed. Turning it into a `note` seems like the best choice, as it would align it with the rest of the output, and `note` is already used for somewhat similar things, like seeing why a lint was fired.

---

Note: turning `-Ztrack-diagnostics` into a `note` will also make `annotate-snippets` API a bit cleaner
2025-07-04 16:22:35 +02:00
Matthias Krüger
18b374d5a7 Rollup merge of #143308 - compiler-errors:no-pointer-like, r=oli-obk
Remove `PointerLike` trait

r? oli-obk
2025-07-04 16:22:35 +02:00
Matthias Krüger
324aa5d4ba Rollup merge of #143286 - Muscraft:track-diagnostics-note, r=WaffleLapkin
Make -Ztrack-diagnostics emit like a note

[#t-compiler/diagnostics > Rendering -Ztrack-diagnostics like a note](https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/Rendering.20-Ztrack-diagnostics.20like.20a.20note/with/526608647)

As discussed on the Zulip thread above, I want to make `-Ztrack-diagnostics` emit like a `note`. This is because I find its current output jarring, and the fact that it gets rendered completely left-aligned, [even in the middle of a snippet](86e05cd300/tests/ui/track-diagnostics/track6.stderr), seems like something that should be changed. Turning it into a `note` seems like the best choice, as it would align it with the rest of the output, and `note` is already used for somewhat similar things, like seeing why a lint was fired.

---

Note: turning `-Ztrack-diagnostics` into a `note` will also make `annotate-snippets` API a bit cleaner
2025-07-04 16:22:35 +02:00
Matthias Krüger
da25619e2a Rollup merge of #140643 - makai410:smir-refactor-migrate, r=oli-obk,celinval
Refactor StableMIR

This PR refactors stable-mir according to the guidance in [this doc](https://hackmd.io/jBRkZLqAQL2EVgwIIeNMHg). It reverses the dependency between `rustc_smir` and `stable_mir`, making `rustc_smir` completely agnostic  of `stable_mir`.

Under the new architecture, the `rustc_smir` crate would retain direct access to rustc queries, while `stable_mir` should proxy all such requests through `rustc_smir` instead of accessing rustc's internals directly. `stable_mir` would only be responsible for the conversion between internal and stable constructs.

This PR mainly introduces these changes:

- **Bridge / Tables<'tcx, B: Bridge>**

```rust
/// A trait defining types that are used to emulate StableMIR components, which is really
/// useful when programming in stable_mir-agnostic settings.
pub trait Bridge {
    type DefId: Copy + Debug + PartialEq + IndexedVal;
    type AllocId: Copy + Debug + PartialEq + IndexedVal;
    type Span: Copy + Debug + PartialEq + IndexedVal;
    type Ty: Copy + Debug + PartialEq + IndexedVal;
    type InstanceDef: Copy + Debug + PartialEq + IndexedVal;
    type TyConstId: Copy + Debug + PartialEq + IndexedVal;
    type MirConstId: Copy + Debug + PartialEq + IndexedVal;
    type Layout: Copy + Debug + PartialEq + IndexedVal;
    type Error: SmirError;
}

pub struct Tables<'tcx, B: Bridge> {
    tcx: TyCtxt<'tcx>,
    pub(crate) def_ids: IndexMap<DefId, B::DefId>,
    pub(crate) alloc_ids: IndexMap<AllocId, B::AllocId>,
    pub(crate) spans: IndexMap<rustc_span::Span, B::Span>,
    pub(crate) types: IndexMap<Ty<'tcx>, B::Ty>,
    pub(crate) instances: IndexMap<ty::Instance<'tcx>, B::InstanceDef>,
    pub(crate) ty_consts: IndexMap<ty::Const<'tcx>, B::TyConstId>,
    pub(crate) mir_consts: IndexMap<mir::Const<'tcx>, B::MirConstId>,
    pub(crate) layouts: IndexMap<rustc_abi::Layout<'tcx>, B::Layout>,
}
```

Since `rustc_smir` needs these stable types somewhere, using associated types is a good approach.

- **SmirContainer / SmirInterface**

```rust
/// A container which is used for TLS.
pub struct SmirContainer<'tcx, B: Bridge> {
    pub tables: RefCell<Tables<'tcx, B>>,
    pub cx: RefCell<SmirCtxt<'tcx, B>>,
}

impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> {
    // ...
}

/// Provides direct access to rustc's internal queries.
///
/// The [`crate::stable_mir::compiler_interface::SmirInterface`] must go through
/// this context to obtain rustc-level information.
pub struct SmirCtxt<'tcx, B: Bridge> {
    tcx: TyCtxt<'tcx>,
    _marker: PhantomData<B>,
}
```

This PR moves `Tables` from `SmirCtxt` to a new `SmirContainer` struct, since mutable borrows of `tables` should only be managed by `SmirInterface`. This change prevents `SmirCtxt` from holding separate borrows and requires passing `tables` explicitly when needed:
```rust
impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> {
    // ...
    /// Get the body of an Instance which is already monomorphized.
    pub fn instance_body(
        &self,
        instance: ty::Instance<'tcx>,
        tables: &mut Tables<'tcx, B>,
    ) -> Option<Body<'tcx>> {
        tables
            .instance_has_body(instance)
            .then(|| BodyBuilder::new(self.tcx, instance).build(tables))
    }
    // ...
}
```

This PR introduces `SmirContainer` as a separate struct rather than bundling it into a `SmirInterface` struct. This separation makes the architecture more modular and easier to reason about.

- **context/traits.rs**

We use this file to define traits that are used for encapsulating the associated functions in the rustc's internals. This is much easier to use and maintain than directly cramming everything into `SmirCtxt`. Here is a real-world use case:
```rust
impl RustcInternal for ExistentialTraitRef {
    type T<'tcx> = rustc_ty::ExistentialTraitRef<'tcx>;

    fn internal<'tcx>(
        &self,
        tables: &mut Tables<'_, BridgeTys>,
        cx: &SmirCtxt<'tcx, BridgeTys>,
    ) -> Self::T<'tcx> {
        use rustc_smir::context::SmirExistentialTraitRef;
        cx.new_from_args(self.def_id.0.internal(tables, cx), self.generic_args.internal(tables, cx))
    }
}
```

- **Separation of `rustc_smir::alloc`**

The previous `rustc_smir::alloc` had many direct calls to rustc queries. This PR splits it into two parts: `rustc_smir::alloc` and `stable_mir::alloc`. Following the same pattern as `SmirCtxt` and `SmirInterface`, the `rustc_smir::alloc` handles all direct interactions with rustc queries and performs the actual memory allocations, while the `stable_mir::alloc` is responsible for constructing stable components.

- **Removal of `convert/error.rs`**

We use `SmirError::from_internal` instead, since implementing `Stable` for these internal errors would be redundant—`tables` is not actually used. If we later need to add something like `LayoutError` to `stable_mir`, we could implement it as follows:
```rust
impl SmirError for stable_mir::LayoutError {
    fn from_internal<T: Debug>(err: T) -> Self {
        // ...
    }
}
```

**Unresolved questions:**

- There are still a few direct calls to rustc's internals scattered across `impl Stable`s, but most of them appear to be relatively stable, e.g., `mir::interpret::ConstAllocation::inner(self)` and `mir::syntax::SwitchTargets::otherwise(self)`.

r? `@celinval`
2025-07-04 16:22:34 +02:00
Camille GILLOT
17ce06a459 Add comment and move assertion. 2025-07-04 14:02:18 +00:00
Camille GILLOT
904bc2958f Lighten formatting. 2025-07-04 14:02:18 +00:00
Camille GILLOT
761d366415 Reuse metadata file from work products. 2025-07-04 14:02:17 +00:00
Camille GILLOT
c7ee3a5e3f Save metadata among work products. 2025-07-04 14:02:17 +00:00
Camille GILLOT
b4a0cd9995 Remove names_imported_by_glob_use query. 2025-07-04 14:01:09 +00:00
Camille GILLOT
2d3ff91add Remove names_imported_by_glob_use query. 2025-07-04 14:01:09 +00:00
Antoni Boucher
312dcd7779 Update to nightly-2025-07-04 2025-07-04 09:47:14 -04:00
Laurențiu Nicola
4b506ca0e1 Merge pull request #20170 from Veykril/push-vtsmzopsunsw
Improve flycheck and build script progress reporting
2025-07-04 13:46:09 +00:00
Antoni Boucher
a0e7630995 Merge branch 'master' into sync_from_rust_2025_07_04 2025-07-04 09:45:56 -04:00
Ralf Jung
0d656e0de5 declare data race and weak memory support as non-experimental 2025-07-04 15:07:19 +02:00
xizheyin
2111525850 Add test false-sealed-traits-note.rs
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-04 20:54:45 +08:00
Samuel Tardieu
60a978d2e9 Simplify clippy lints page further (#15208)
Follow-up of rust-lang/rust-clippy#15140.

This time, I removed some unneeded `<span>` wrappings and some unneeded
CSS classes. As usual, no changes in the UI.

Before this PR: 1876091
With this PR: 1751097
Reduction: -6.6%

r? @samueltardieu

changelog: Reduce page size and number of DOM elements on clippy lints
page
2025-07-04 12:54:02 +00:00
Tshepang Mbambo
33c70d98e8 Merge pull request #2492 from rust-lang/tshepang-patch-1
external-repos.md: small fixes
2025-07-04 14:22:48 +02:00
Tshepang Mbambo
f167f9b49e external-repos.md: small fixes 2025-07-04 14:13:15 +02:00
Guillaume Gomez
dd1a52f8b6 Simplify clippy lints page further 2025-07-04 13:57:38 +02:00
Marijn Schouten
1a1b52acbf clippy fix: indentation 2025-07-04 11:52:17 +00:00
许杰友 Jieyou Xu (Joe)
dbad97664e Merge pull request #2491 from Kobzol/switch-to-rustc-josh-sync 2025-07-04 19:32:44 +08:00
Jakub Beránek
9d83749cdd Document rustc-josh-sync 2025-07-04 13:14:23 +02:00
bors
556d20a834 Auto merge of #143247 - cjgillot:metadata-no-red, r=petrochenkov
Avoid depending on forever-red DepNode when encoding metadata.

Split from https://github.com/rust-lang/rust/pull/114669 for perf

r? `@petrochenkov`
2025-07-04 10:23:18 +00:00
Samuel Tardieu
da2f0ad53c Reduce page size and number of DOM elements on clippy lints page (#15140)
This is the first pass of "reducing the size of the clippy lints page"
I'm currently going through. This first one reduces the size page but
mostly reduces the number of DOM elements.

Page size change:
* Before this PR: 1938957
* With this PR: 1876167
* Reduction: -3.2%

r? @Alexendoo

changelog: Reduce page size and number of DOM elements on clippy lints
page
2025-07-04 10:09:34 +00:00
Lukas Wirth
f3325a5a6a Improve flycheck and build script progress reporting 2025-07-04 11:52:09 +02:00
Lukas Wirth
3bfe103082 Merge pull request #20169 from Veykril/push-quvvsupnqqwv
Skip unnecessary `eq` work in `BodySourceMap`
2025-07-04 09:47:36 +00:00
Jakub Beránek
13dca5e1ba Update CI workflow to use rustc-josh-sync 2025-07-04 11:44:58 +02:00
Jakub Beránek
92144e1ee1 Remove josh-sync tooling and update README 2025-07-04 11:41:19 +02:00
Lukas Wirth
c49987f5a4 Skip unnecessary eq work in BodySourceMap 2025-07-04 11:36:06 +02:00
Lukas Wirth
1494a27faf Merge pull request #20031 from jnyfah/some-branch
Fix: Resolve HIR display length issues and improve adjustment tooltips
2025-07-04 09:20:14 +00:00
Lukas Wirth
b7dbf143bb Merge pull request #20168 from Veykril/push-wsozylrmsyns
minor: Handle match arm commas in `make::match_arm`
2025-07-04 09:19:22 +00:00
Samuel Tardieu
876e05d307 bump termize (#15207)
Bump termize to remove one more dep with winapi
(https://github.com/JohnTitor/termize/releases/tag/v0.2.0)

changelog: none
2025-07-04 09:19:03 +00:00
许杰友 Jieyou Xu (Joe)
ad9759701a Merge pull request #2489 from Kobzol/pull 2025-07-04 17:12:10 +08:00
Lukas Wirth
0b4cbdf556 minor: Handle match arm commas in make::match_arm
Co-authored-by: Giga Bowser <45986823+Giga-Bowser@users.noreply.github.com>
2025-07-04 11:08:28 +02:00
Jakub Beránek
c33dd1b306 Merge ref 'c96a69059ecc' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: c96a69059e
Filtered ref: 7b9552d4c39c31aabf6749629da2d4a7e6e1cd60

This merge was created using https://github.com/rust-lang/josh-sync.
2025-07-04 11:07:48 +02:00