34578 Commits

Author SHA1 Message Date
bors
d452c93b55 Auto merge of #140176 - dpaoliello:arm64ecdec, r=wesleywiser
Fix linking statics on Arm64EC

Arm64EC builds recently started to fail due to the linker not finding a symbol:
```
symbols.o : error LNK2001: unresolved external symbol #_ZN3std9panicking11EMPTY_PANIC17hc8d2b903527827f1E (EC Symbol)
          C:\Code\hello-world\target\arm64ec-pc-windows-msvc\debug\deps\hello_world.exe : fatal error LNK1120: 1 unresolved externals
```

It turns out that `EMPTY_PANIC` is a new static variable that was being exported then imported from the standard library, but when exporting LLVM didn't prepend the name with `#` (as only functions are prefixed with this character), whereas Rust was prefixing with `#` when attempting to import it.

The fix is to have Rust not prefix statics with `#` when importing.

Adding tests discovered another issue: we need to correctly mark static exported from dylibs with `DATA`, otherwise MSVC's linker assumes they are functions and complains that there is no exit thunk for them.

CI found another bug: we only apply `DllImport` to non-local statics that aren't foreign items (i.e., in an `extern` block), that is we want to use `DllImport` for statics coming from other Rust crates. However, `__rust_no_alloc_shim_is_unstable` is a static generated by the Rust compiler if required, but downstream crates consider it a foreign item since it is declared in an `extern "Rust"` block, thus they do not apply `DllImport` to it and so fails to link if it is exported by the previous crate as `DATA`. The fix is to apply `DllImport` to foreign items that are marked with the `rustc_std_internal_symbol` attribute (i.e., we assume they aren't actually foreign and will be in some Rust crate).

Fixes #138541

---
try-job: dist-aarch64-msvc
try-job: dist-x86_64-msvc
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
2025-05-09 00:43:28 +00:00
bors
85905359cf Auto merge of #140732 - onur-ozkan:use-in-tree-rustfmt, r=Kobzol
make it possible to run in-tree rustfmt with `x run rustfmt`

Currently, there is no way to run in-tree `rustfmt` using `x fmt` or `x test tidy` commands. This PR implements `rustfmt` on `x run`, which allows bootstrap to run the in-tree `rustfmt`.

Fixes #140723
2025-05-08 11:53:39 +00:00
bors
4c2b4ca4f2 Auto merge of #140106 - dianne:deref-pat-usefulness, r=Nadrieril
allow deref patterns to participate in exhaustiveness analysis

Per [this proposal](https://hackmd.io/4qDDMcvyQ-GDB089IPcHGg#Exhaustiveness), this PR allows deref patterns to participate in exhaustiveness analysis. Currently all deref patterns enforce `DerefPure` bounds on their scrutinees, so this assumes all patterns it's analyzing are well-behaved. This also doesn't support [mixed exhaustiveness](https://hackmd.io/4qDDMcvyQ-GDB089IPcHGg#Mixed-exhaustiveness), and instead emits an error if deref patterns are used together with normal constructors. I think mixed exhaustiveness would be nice to have (especially if we eventually want to support arbitrary `Deref` impls[^1]), but it'd require more work to get reasonable diagnostics[^2].

Tracking issue for deref patterns: #87121

r? `@Nadrieril`

[^1]: Regardless of whether we support limited exhaustiveness checking for untrusted `Deref` or always require other arms to be exhaustive, I think it'd be useful to allow mixed matching for user-defined smart pointers. And it'd be strange if it worked there but not for `Cow`.

[^2]: I think listing out witnesses of non-exhaustiveness can be confusing when they're not necessarily disjoint, and when you only need to cover some of them, so we'd probably want special formatting and/or explanatory subdiagnostics. And if it's implemented similarly to unions, we'd probably also want some way of merging witnesses; the way witnesses for unions can appear duplicated is pretty unfortunate. I'm not sure yet how the diagnostics should look, especially for deeply nested patterns.
2025-05-08 02:16:45 +00:00
bors
cdc27d1c08 Auto merge of #140590 - lcnr:closure-in-dead-code, r=compiler-errors
borrowck nested items in dead code

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

r? `@compiler-errors`
2025-05-07 19:49:36 +00:00
bors
1e092772a2 Auto merge of #139758 - Zoxc:thread-local-graph, r=oli-obk
Use thread local dep graph encoding

This adds thread local encoding of dep graph nodes. Each thread has a `MemEncoder` that gets flushed to the global `FileEncoder` when it exceeds 64 kB. Each thread also has a local cache of dep indices. This means there can now be empty gaps in `SerializedDepGraph`.

Indices are marked green and also allocated by the new atomic operation `DepNodeColorMap::try_mark_green` as the encoder lock is removed.
2025-05-07 12:39:54 +00:00
bors
e9430af94e Auto merge of #140735 - GuillaumeGomez:rollup-dlhbxsg, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #139518 (Stabilize precise capture syntax in style guide)
 - #140398 (Fix backtrace for cygwin)
 - #140719 (fix typo in autorefs lint doc example)
 - #140724 (Update `compiler-builtins` to 0.1.158)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-07 09:31:15 +00:00
Guillaume Gomez
f2921b99d9
Rollup merge of #140398 - Berrysoft:cygwin-backtrace, r=tgross35
Fix backtrace for cygwin

Closes #140304

Depends on:
- [x] https://github.com/rust-lang/backtrace-rs/pull/704

This PR could not be merged until the above PR is merged. I'll update the submodule then.

EDIT: submodule updated.
2025-05-07 10:50:49 +02:00
Guillaume Gomez
cd85099e22
Rollup merge of #139518 - xizheyin:issue-138527, r=traviscross
Stabilize precise capture syntax in style guide

Closes #138527

r? `@jieyouxu`
2025-05-07 10:50:48 +02:00
bors
24390f60d6 Auto merge of #137995 - hkBst:parse_format_reuse_unescape, r=nnethercote
Remove duplicate impl of string unescape from parse_format

r? `@nnethercote`
2025-05-07 06:18:39 +00:00
dianne
eb446f92fd add stubbed-out cases for rust-analyzer
rust-analyzer doesn't construct `DerefPattern(_)` constructors, so these
shouldn't crash. It looks like this is how slice patterns are
implemented too.
2025-05-06 18:53:55 -07:00
bors
3732587143 Auto merge of #140514 - m-ou-se:proc-macro-span-file, r=Amanieu
Stabilize proc_macro::Span::{file, local_file}.

Stabilizes this part of https://github.com/rust-lang/rust/issues/54725:

```rust
impl Span {
    pub fn file(&self) -> String; // Mapped/artificial file name, for display purposes.

    pub fn local_file(&self) -> Option<PathBuf>; // Real file name as it exists on the local file system.
}
```

See also the naming discussion in https://github.com/rust-lang/rust/issues/139903
2025-05-06 22:03:11 +00:00
bors
3f31806a93 Auto merge of #140561 - compiler-errors:gather-fewer-locals, r=lcnr
Do not gather local all together at the beginning of typeck

r? lcnr
2025-05-06 10:27:27 +00:00
Marijn Schouten
618c3de146 Remove duplicate impl of string unescape 2025-05-06 10:00:22 +00:00
bors
65576ebbd7 Auto merge of #140695 - Zalathar:rollup-i32gzbo, r=Zalathar
Rollup of 12 pull requests

Successful merges:

 - #139550 (Fix `-Zremap-path-scope` rmeta handling)
 - #139764 (Consistent trait bounds for ExtractIf Debug impls)
 - #139773 (Implement `Iterator::last` for `vec::IntoIter`)
 - #140035 (Implement RFC 3503: frontmatters)
 - #140251 (coverage-dump: Resolve global file IDs to filenames)
 - #140393 (std: get rid of `sys_common::process`)
 - #140532 (Fix RustAnalyzer discovery of rustc's `stable_mir` crate)
 - #140598 (Steer docs to `utf8_chunks` and `Iterator::take`)
 - #140634 (Use more accurate ELF flags on MIPS)
 - #140673 (Clean rustdoc tests folder)
 - #140678 (Be a bit more relaxed about not yet constrained infer vars in closure upvar analysis)
 - #140687 (Update mdbook to 0.4.49)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-06 06:37:30 +00:00
Stuart Cook
c332523848
Rollup merge of #140687 - ehuss:update-mdbook, r=jieyouxu
Update mdbook to 0.4.49

This is a routine update to pull in some fixes and updates.

Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0449
2025-05-06 16:28:43 +10:00
Stuart Cook
d76c112cbf
Rollup merge of #140678 - compiler-errors:dont-ice-on-infer-in-upvar, r=lcnr
Be a bit more relaxed about not yet constrained infer vars in closure upvar analysis

See the writeup in `tests/ui/closures/opaque-upvar.rs`.

TL;DR is that this has to do with the fact that the recursive revealing uses, which have not yet been constrained from the defining use by the time that closure upvar inference is performed, remain as infer vars during upvar analysis. We don't really care, though, since anywhere we structurally match on a type in upvar analysis, we already call `structurally_resolve_type` right before `.kind()`, which would emit a true ambiguity error.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/197

r? lcnr
2025-05-06 16:28:43 +10:00
Stuart Cook
a356d2290b
Rollup merge of #140673 - GuillaumeGomez:clean-rustdoc-tests, r=notriddle
Clean rustdoc tests folder

We were starting to have way too many tests in the `tests/rustdoc/` folder so I moved some of them in sub-folders. We now have less than 300 tests at the "top level" so I guess it's good enough for now.

So this PR just moves tests in sub-folders and that's pretty much it. 😃

r? ``@notriddle``
2025-05-06 16:28:42 +10:00
Stuart Cook
d2b43ed549
Rollup merge of #140634 - smrobtzz:mips-elf-fixes, r=workingjubilee
Use more accurate ELF flags on MIPS

Changes the MIPS ELF flags used for metadata objects to be closer to what LLVM uses so the linker doesn't complain
2025-05-06 16:28:42 +10:00
Stuart Cook
87317deeaa
Rollup merge of #140598 - ShE3py:iter-misc-docs, r=workingjubilee
Steer docs to `utf8_chunks` and `Iterator::take`

- Adds `limit` as an alias of `take` (as this is [what Java calls this operation](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#limit-long-));
- Says that [`Utf8Chunks`](https://doc.rust-lang.org/std/str/struct.Utf8Chunks.html) comes from [`[u8]::utf8_chunks`](https://doc.rust-lang.org/std/primitive.slice.html#method.utf8_chunks).

``@rustbot`` label +A-docs
2025-05-06 16:28:41 +10:00
Stuart Cook
1043f02fa8
Rollup merge of #140532 - celinval:chores-smir-ra, r=oli-obk
Fix RustAnalyzer discovery of rustc's `stable_mir` crate

This fixes issues with RustAnalyzer not finding `stable_mir` crate since RA discovery traverses the dependency graph of `rustc_driver` crate.

This change also aligns with the long term architecture plan for these crates, since we are moving towards having stable_mir depend on rustc_smir and not the other way around. See [this doc](https://hackmd.io/jBRkZLqAQL2EVgwIIeNMHg) for more details.

I believe a similar function will come handy eventually for `stable_mir` users, but I'm keeping it as part of `rustc_internal` since its current format initializes the StableMir context and requires `TyCtxt`.

Finally, I added the `rustc_internal` module re-export under a feature since the APIs from this module shall not be stabilized.
2025-05-06 16:28:41 +10:00
Stuart Cook
338e5405f7
Rollup merge of #140393 - joboet:sys_common_process, r=thomcc
std: get rid of `sys_common::process`

Move the public `CommandEnvs` into the `process` module (and make it a wrapper type for an internal iterator type) and everything else into `sys::process` as per #117276.

Something went wrong with a force push, so I can't reopen #139020. This is unchanged from that PR, apart from a rebase.

r? ```@thomcc```
2025-05-06 16:28:40 +10:00
Stuart Cook
c75511867b
Rollup merge of #140251 - Zalathar:coverage-dump-path, r=clubby789
coverage-dump: Resolve global file IDs to filenames

The coverage-dump tool, used by coverage tests, currently includes “global file ID” numbers in its dump output.

This PR adds support for parsing coverage filename information from LLVM assembly `.ll` files, and resolving those file IDs to the corresponding filename, for inclusion in dump output.

This makes dump output more informative, especially for test cases involving multiple files, and will be important for testing expansion region support in the future.

---

The bootstrap changes don't necessarily have to land at the same time (e.g. they could be deferred to after the stage0 redesign if requested), but I would prefer to land them now if possible.
2025-05-06 16:28:40 +10:00
Stuart Cook
9f4e2cc51d
Rollup merge of #140035 - fee1-dead-contrib:push-oszwkkvmpkks, r=jieyouxu,wesleywiser
Implement RFC 3503: frontmatters

Tracking issue: #136889

Supercedes #137193. This implements [RFC 3503](https://github.com/rust-lang/rfcs/blob/master/text/3503-frontmatter.md).

This might break rust-analyzer. Will look into how to fix that.

Suggestions welcome for how to improve diagnostics.
2025-05-06 16:28:39 +10:00
Stuart Cook
1cc33c8c35
Rollup merge of #139773 - thaliaarchi:vec-into-iter-last, r=workingjubilee
Implement `Iterator::last` for `vec::IntoIter`

Avoid iterating everything when we have random access to the last element.
2025-05-06 16:28:39 +10:00
Stuart Cook
7fedfb16c9
Rollup merge of #139764 - dtolnay:extractif, r=Amanieu
Consistent trait bounds for ExtractIf Debug impls

Closes #137654. Refer to that issue for a table of the **4** different impl signatures we previously had in the standard library for Debug impls of various ExtractIf iterator types.

The one we are standardizing on is the one so far only used by `alloc::collections::linked_list::ExtractIf`, which is _no_ `F: Debug` bound, _no_ `F: FnMut` bound, only `T: Debug` bound.

This PR applies the following signature changes:

```diff
/* alloc::collections::btree_map */

    pub struct ExtractIf<'a, K, V, F, A = Global>
    where
-       F: 'a + FnMut(&K, &mut V) -> bool,
        Allocator + Clone,

    impl Debug for ExtractIf<'a, K, V, F,
+       A,
    >
    where
        K: Debug,
        V: Debug,
-       F: FnMut(&K, &mut V) -> bool,
+       A: Allocator + Clone,
```

```diff
/* alloc::collections::btree_set */

    pub struct ExtractIf<'a, T, F, A = Global>
    where
-       T: 'a,
-       F: 'a + FnMut(&T) -> bool,
        Allocator + Clone,

    impl Debug for ExtractIf<'a, T, F, A>
    where
        T: Debug,
-       F: FnMut(&T) -> bool,
        A: Allocator + Clone,
```

```diff
/* alloc::collections::linked_list */

    impl Debug for ExtractIf<'a, T, F,
+       A,
    >
    where
        T: Debug,
+       A: Allocator,
```

```diff
/* alloc::vec */

    impl Debug for ExtractIf<'a, T, F, A>
    where
        T: Debug,
-       F: Debug,
        A: Allocator,
-       A: Debug,
```

```diff
/* std::collections::hash_map */

    pub struct ExtractIf<'a, K, V, F>
    where
-       F: FnMut(&K, &mut V) -> bool,

    impl Debug for ExtractIf<'a, K, V, F>
    where
+       K: Debug,
+       V: Debug,
-       F: FnMut(&K, &mut V) -> bool,
```

```diff
/* std::collections::hash_set */

    pub struct ExtractIf<'a, T, F>
    where
-       F: FnMut(&T) -> bool,

    impl Debug for ExtractIf<'a, T, F>
    where
+       T: Debug,
-       F: FnMut(&T) -> bool,
```

I have made the following changes to bring these types into better alignment with one another.

- Delete `F: Debug` bounds. These are especially problematic because Rust closures do not come with a Debug impl, rendering the impl useless.

- Delete `A: Debug` bounds. Allocator parameters are unstable for now, but in the future this would become an API commitment that we do not debug-print a representation of the allocator when printing an iterator.

- Delete `F: FnMut` bounds. Requires `hashbrown` PR: https://github.com/rust-lang/hashbrown/pull/616. **API commitment:** we commit to not doing RefCell voodoo inside ExtractIf to have some way for its Debug impl (which takes &amp;self) to call a FnMut closure, if this is even possible.

- Add `T: Debug` bounds (or `K`/`V`), even on Debug impls that do not currently make use of them, but might in the future. **Breaking change.** Must backport into Rust 1.87 (current beta) or do a de-stabilization PR in beta to delay those types by one release.

- Render using `debug_struct` + `finish_non_exhaustive`, instead of `debug_tuple`.

- Do not render the _entire_ underlying collection.

- Show a "peek" field indicating the current position of the iterator.
2025-05-06 16:28:38 +10:00
Stuart Cook
d3b976f68e
Rollup merge of #139550 - Urgau:rmeta-remap-path-scope, r=nnethercote
Fix `-Zremap-path-scope` rmeta handling

This PR fixes the conditional remapping (`-Zremap-path-scope`) of rmeta file paths ~~by using the `debuginfo` scope~~ by conditionally embedding the local path in addition to the remapped path.

Fixes https://github.com/rust-lang/rust/issues/139217
2025-05-06 16:28:38 +10:00
bors
712e178a6d Auto merge of #131160 - ismailarilik:handle-potential-query-instability-lint-for-rustc-middle, r=oli-obk
Handle `rustc_middle` cases of `rustc::potential_query_instability` lint

This PR removes `#![allow(rustc::potential_query_instability)]` line from [`compiler/rustc_middle/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/lib.rs#L29) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors.

A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447

r? `@compiler-errors`
2025-05-06 01:36:23 +00:00
bors
d6ad86fc43 Auto merge of #140664 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2025-05-05 19:14:42 +00:00
Deadbeef
9fce1dfac5 Implement RFC 3503: frontmatters
Supercedes #137193
2025-05-05 23:10:08 +08:00
bors
676ac98bc7 Auto merge of #140651 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2025-05-05 15:00:09 +00:00
bors
5e850d851f Auto merge of #140453 - Zoxc:next-disambiguator, r=oli-obk
Remove global `next_disambiguator` state and handle it with a `DisambiguatorState` type

This removes `Definitions.next_disambiguator` as it doesn't guarantee deterministic def paths when `create_def` is called in parallel. Instead a new `DisambiguatorState` type is passed as a mutable reference to `create_def` to help create unique def paths. `create_def` calls with distinct  `DisambiguatorState` instances must ensure that that the def paths are unique without its help.

Anon associated types did rely on this global state for uniqueness and are changed to use (method they're defined in + their position in the method return type) as the `DefPathData` to ensure uniqueness. This also means that the method they're defined in appears in error messages, which is nicer.

`DefPathData::NestedStatic` is added to use for nested data inside statics instead of reusing `DefPathData::AnonConst` to avoid conflicts with those.

cc `@oli-obk`
2025-05-05 11:50:43 +00:00
Lukas Wirth
3b57c00151
Merge pull request #19739 from Veykril/push-kpozprqnsmkk
Disable fixpoint for variance computation temporarily
2025-05-05
2025-05-04 04:26:25 +00:00
Lukas Wirth
7d51ec376a Disable fixpoint for variance computation temporarily 2025-05-04 06:09:34 +02:00
Lukas Wirth
bfb717ac09
Merge pull request #19735 from A4-Tacks/improve-let-snippet
Improve the let code snippet
2025-05-04 04:06:56 +00:00
bors
1502c64b88 Auto merge of #140535 - dtolnay:hashbrown, r=tgross35
Update hashbrown dependency to unblock ExtractIf improvements

Release notes: https://github.com/rust-lang/hashbrown/releases/tag/v0.15.3

Relevant to me, this release includes https://github.com/rust-lang/hashbrown/pull/616 which unblocks https://github.com/rust-lang/rust/pull/139764.
2025-05-03 23:49:11 +00:00
bors
04c94e8d32 Auto merge of #140502 - nikic:llvm-20.1.4, r=dianqk
Update to LLVM 20.1.4

Fixes https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/Why.20is.20the.20compiler.20failing.20on.20below.20code.3F.
2025-05-03 17:03:37 +00:00
bors
707ec70aa2 Auto merge of #140464 - oli-obk:successors-mut-perf, r=petrochenkov
Use a closure instead of three chained iterators

Fixes the perf regression from #123948

That PR had chained a third option to the iterator which apparently didn't optimize well
2025-05-03 10:43:38 +00:00
A4-Tacks
850d122fd4
Improve let snippet 2025-05-03 17:04:11 +08:00
A4-Tacks
d922c20158
Improve the let code snippet 2025-05-03 13:15:32 +08:00
bors
9455557b97 Auto merge of #140442 - osiewicz:collector-walk-less-fine-grained-locking, r=wesleywiser
mono collector: Reduce # of locking while walking the graph

While profiling Zed's dev build I've noticed that while most of the time `upstream_monomorphizations` takes a lot of time in monomorpization_collector, in some cases (e.g. build of `editor` itself) the rest of monomorphization_collector_graph_walk dominates it. Most of the time is spent in collect_items_rec.

This PR aims to reduce the number of locks taking place; instead of locking output MonoItems once per children of current node, we do so once per *current node*. We also get to reuse locks for mentioned and used items. While this commit does not reduce Wall time of Zed's build, it does shave off CPU time (measured with `cargo build -j1`) from 48s to 47s. I've also tested it with parallel frontend against Zed and ripgrep and found no regressions.
2025-05-03 00:24:14 +00:00
Lukas Wirth
6f9c62dfec
Merge pull request #19733 from ShoyuVanilla/issue-19724
fix: Implement mut to const ptr cast for method resolution
2025-05-02 20:48:24 +00:00
Lukas Wirth
3bf5d7f7f9
Merge pull request #19732 from ShoyuVanilla/issue-19730
fix: Correct assoc ty bound var starting index
2025-05-02 20:46:54 +00:00
Shoyu Vanilla
4aa98bf1d7 fix: Implement mut to const ptr cast for method resolution 2025-05-03 03:01:40 +09:00
bors
473e234d69 Auto merge of #140406 - Urgau:autorefs-perf, r=nnethercote
perf: delay checking of `#[rustc_no_implicit_autorefs]` in autoref lint

Try to address the regression seen in https://github.com/rust-lang/rust/pull/123239#issuecomment-2835418470 by delaying the checking of `#[rustc_no_implicit_autorefs]` on method call.
2025-05-02 17:35:50 +00:00
Lukas Wirth
be7433328e
Merge pull request #19731 from Veykril/push-mmvowomkpwxy
refactor: Simplify macro call id construction
2025-05-02 15:38:17 +00:00
Shoyu Vanilla
9f60884db7 fix: Correct assoc ty bound var starting index 2025-05-03 00:31:33 +09:00
Lukas Wirth
5d43e752ad refactor: Simplify macro call id construction 2025-05-02 17:26:48 +02:00
Lukas Wirth
9625ef795d
Merge pull request #19581 from Veykril/push-uvyutolsqnun
Render more lifetimes
2025-05-02 12:47:03 +00:00
Lukas Wirth
235d88bf42 Render more lifetimes 2025-05-02 14:36:18 +02:00
bors
495a416076 Auto merge of #139883 - matthiaskrgr:crashesapr15, r=Mark-Simulacrum
crashes: more tests

try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-gnu
try-job: dist-i586-gnu-i586-i686-musl
try-job: test-various
2025-05-02 10:46:51 +00:00