Commit Graph

281699 Commits

Author SHA1 Message Date
Matthias Krüger
10dd016a80
Rollup merge of #137203 - nnethercote:improve-MIR-modification, r=compiler-errors
Improve MIR modification

A few commits that simplify code that manipulates MIR bodies.

r? `@tmiasko`
2025-02-18 18:40:54 +01:00
Matthias Krüger
05dbe6ddff
Rollup merge of #137191 - ehuss:update-mdbook, r=jieyouxu
Update mdbook and move error_index_generator

This moves error_index_generator to the rustbook workspace so that it can share the dependency with mdbook. I had forgotten that error_index_generator is using mdbook.

This includes a corresponding update to mdbook which avoids a regression in error_index_generator.

Closes https://github.com/rust-lang/rust/issues/137052
2025-02-18 18:40:53 +01:00
Matthias Krüger
54db888355
Rollup merge of #137161 - dianne:pat-migration-bookkeeping-for-macros, r=Nadrieril
Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions

See the diff between the two commits for how this affected the error message and suggestion. In order to decide how to format those, the pattern migration diagnostic keeps track of which parts of the user's pattern cause problems in Edition 2024. However, it neglected to do some of this bookkeeping when pointing to macro expansion sites. This fixes that.
2025-02-18 18:40:52 +01:00
Matthias Krüger
ac3b179c3b
Rollup merge of #137126 - m4rch3n1ng:fix-inherent-str-docs, r=Amanieu
fix docs for inherent str constructors

related to #131114

when implementing inherent str constructors in #136517, i forgot to change the docs, so the code examples still imported the `std::str` module and used the constructor from there, instead of using "itself" (the inherent constructor).
2025-02-18 18:40:52 +01:00
Matthias Krüger
c8d904125e
Rollup merge of #137000 - compiler-errors:deeply-normalize-item-bounds, r=lcnr
Deeply normalize item bounds in new solver

Built on #136863.

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

cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/116

First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env.

Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out.

r? lcnr
2025-02-18 18:40:51 +01:00
Matthias Krüger
5a942d67a6
Rollup merge of #136876 - joshtriplett:locking-might-not-be-advisory, r=Amanieu
Locking documentation updates

- Reword file lock documentation to clarify advisory vs mandatory. Remove the
  word "advisory", and make it more explicit that the lock may be advisory or
  mandatory depending on platform.

- Document that locking a file fails on Windows if the file is opened only for append
2025-02-18 18:40:50 +01:00
Matthias Krüger
58a622b019
Rollup merge of #136599 - yotamofek:pr/rustdoc-more-joined, r=GuillaumeGomez
librustdoc: more usages of `Joined::joined`

Some missed opportunities from #136244
r? ```@GuillaumeGomez``` since you reviewed the last one (feel free to re-assign, of course 😊)
First two commits are just drive-by cleanups
2025-02-18 18:40:50 +01:00
Matthias Krüger
7edd17cfbb
Rollup merge of #135711 - estebank:issue-135649, r=davidtwco
Do not ICE on default_field_value const with lifetimes

`#![feature(default_field_values)]` uses a `const` body that should be treated as inline `const`s, but is actually being detected otherwise. This is similar to the situation in #78174, so we take the same solution: we check if the const actually comes from a field, and if it does, we use that logic to get the appropriate lifetimes and not ICE during borrowck.

Fix #135649.
2025-02-18 18:40:49 +01:00
Josh Triplett
ec2034d53d Reorder "This lock may be advisory or mandatory." earlier in the lock docs 2025-02-18 17:31:10 +01:00
Josh Triplett
35674eff6f Clarify that locking on Windows also works for files opened with .read(true) 2025-02-18 17:26:33 +01:00
bors
3b022d8cee Auto merge of #133852 - x17jiri:cold_path, r=saethlin
improve cold_path()

#120370 added a new instrinsic `cold_path()` and used it to fix `likely` and `unlikely`

However, in order to limit scope, the information about cold code paths is only used in 2-target switch instructions. This is sufficient for `likely` and `unlikely`, but limits usefulness of `cold_path` for idiomatic rust. For example, code like this:

```
if let Some(x) = y { ... }
```

may generate 3-target switch:

```
switch y.discriminator:
0 => true branch
1 = > false branch
_ => unreachable
```

and therefore marking a branch as cold will have no effect.

This PR improves `cold_path()` to work with arbitrary switch instructions.

Note that for 2-target switches, we can use `llvm.expect`, but for multiple targets we need to manually emit branch weights. I checked Clang and it also emits weights in this situation. The Clang's weight calculation is more complex that this PR, which I believe is mainly because `switch` in `C/C++` can have multiple cases going to the same target.
2025-02-18 07:49:09 +00:00
bors
aaa8614934 Auto merge of #137162 - nnethercote:remove-Map-2, r=Zalathar
Move methods from `Map` to `TyCtxt`, part 2.

Continuing the work started in #136466.

Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.

r? Zalathar
2025-02-18 04:26:30 +00:00
Nicholas Nethercote
04eeda47ab Inline and replace Statement::replace_nop.
It has a single call site, and doesn't seem worth having as an API
function.
2025-02-18 13:43:43 +11:00
Nicholas Nethercote
69f5e342bf Inline and remove BasicBlockData::retain_statements.
It has a single call site, and the code is clearer this way.
2025-02-18 13:31:08 +11:00
Nicholas Nethercote
627e08c909 Remove BasicBlockData::expand_statements.
The previous commit removed its single use. `MirPatch` is a more
flexible alternative.
2025-02-18 13:13:32 +11:00
Nicholas Nethercote
e3316ae453 Improve MirPatch documentation and naming.
It's currently lacking comments. This commit adds some, which is useful
because there are some methods with non-obvious behaviour.

The commit also renames two things:
- `patch_map` becomes `term_patch_map`, because it's only about
  terminators.
- `is_patched` becomes `is_term_patched`, for the same reason.

(I would guess that originally `MirPatch` only handled terminators, and
then over time it expanded to allow other modifications, but these names
weren't updated.)
2025-02-18 13:12:50 +11:00
Nicholas Nethercote
a1daa34ad0 Use MirPatch in EnumSizeOpt.
Instead of `expand_statements`. This makes the code shorter and
consistent with other MIR transform passes.

The tests require updating because there is a slight change in
MIR output:
- the old code replaced the original statement with twelve new
  statements.
- the new code inserts converts the original statement to a `nop` and
  then insert twelve new statements in front of it.

I.e. we now end up with an extra `nop`, which doesn't matter at all.
2025-02-18 12:52:56 +11:00
bors
de91711756 Auto merge of #137176 - matthiaskrgr:rollup-eht05gr, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #136959 (Simplify switch sources)
 - #137020 (Pass vendored sources from bootstrap to generate-copyright)
 - #137073 (boostrap: skip no_std targets in Std doc step)
 - #137165 (Use `tell` for `<File as Seek>::stream_position`)
 - #137166 (Update default loongarch code model in docs)
 - #137168 (correct comment)
 - #137169 (CI: rfl: move job forward to Linux v6.14-rc3)
 - #137170 (Allow configuring jemalloc per target)
 - #137173 (Subtree update of `rust-analyzer`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-18 00:05:30 +00:00
Nicholas Nethercote
fd7b4bf4e1 Move methods from Map to TyCtxt, part 2.
Continuing the work started in #136466.

Every method gains a `hir_` prefix, though for the ones that already
have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-18 10:17:44 +11:00
Yotam Ofek
c0b1c6eed5 librustdoc: more usages of Joined::joined 2025-02-17 22:53:52 +00:00
Eric Huss
123217b3b8 Fix what looks like an inverted message
I believe this is trying to say there is something that is in the file,
but shouldn't be.
2025-02-17 10:58:57 -08:00
Eric Huss
2773456f5f Move error_index_generator to the rustbook workspace
I had forgotten that error_index_generator is using mdbook. This moves
it to be part of the rustbook workspace so that it can share the
dependency with rustbook.
2025-02-17 10:58:15 -08:00
Eric Huss
32b1bffa11 Update mdbook to 0.4.45
Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0445
2025-02-17 10:47:48 -08:00
Yotam Ofek
4a76615054 coalesce match patterns with identical bodies 2025-02-17 18:38:13 +00:00
Yotam Ofek
a7a43cd373 use Iterator::zip instead of enumerating+indexing 2025-02-17 18:38:13 +00:00
Michael Goulet
b002b5cc82 Deeply normalize associated type bounds before proving them 2025-02-17 17:21:24 +00:00
Michael Goulet
2cdb7fac95 Prefer param-env candidates even when alias's trait bound isn't proven via param-env 2025-02-17 16:59:17 +00:00
Matthias Krüger
fc829035c1
Rollup merge of #137173 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2025-02-17 17:06:14 +01:00
Matthias Krüger
10cc816cef
Rollup merge of #137170 - ferrocene:pa-target-jemalloc, r=Kobzol
Allow configuring jemalloc per target

In Ferrocene we're trying to switch from `./configure` to a predefined `config.toml` file. One of the limitations of doing that is the `rust.jemalloc` configuration option, which we need to conditionally disable based on the target. This PR adds a `target.$tuple.jemalloc` option to override `rust.jemalloc` to make that possible.
2025-02-17 17:06:13 +01:00
Matthias Krüger
8d72b7cb42
Rollup merge of #137169 - ojeda:rfl, r=lqd
CI: rfl: move job forward to Linux v6.14-rc3

Linux v6.14-rc3 contains commit 6273a058383e ("x86: rust: set rustc-abi=x86-softfloat on rustc>=1.86.0"), which resolves the error from https://github.com/rust-lang/rust/pull/136146.

r? `@lqd` `@Kobzol`
try-job: x86_64-rust-for-linux
`@rustbot` label A-rust-for-linux
`@bors` try
2025-02-17 17:06:13 +01:00
Matthias Krüger
7808784f01
Rollup merge of #137168 - klensy:rc--, r=lcnr
correct comment

Rc was removed in #113573, so
r? `@lcnr`
2025-02-17 17:06:12 +01:00
Matthias Krüger
652c8b6866
Rollup merge of #137166 - nikic:loongarch-code-model, r=workingjubilee
Update default loongarch code model in docs

Since https://github.com/rust-lang/rust/pull/130266 loongarch defaults to medium code model.
2025-02-17 17:06:11 +01:00
Matthias Krüger
10018d8e10
Rollup merge of #137165 - thaliaarchi:file-tell, r=ChrisDenton
Use `tell` for `<File as Seek>::stream_position`

Some platforms have a more efficient way to get the current offset of the file than by seeking. For example, Wasi has `fd_tell` and SOLID has `SOLID_FS_Ftell`. Implement `<File as Seek>::stream_position()` in terms of those.

I do not use any APIs that were not already used in `std`. Although, the `libc` crate has [`ftell`](https://docs.rs/libc/latest/libc/fn.ftell.html), [`ftello`](https://docs.rs/libc/latest/libc/fn.ftello.html), and [`ftello64`](https://docs.rs/libc/latest/libc/fn.ftello64.html), I do not know platform coverage. It appears that Windows has no `tell`-like API.

I have checked that it builds on each relevant platform.
2025-02-17 17:06:10 +01:00
Matthias Krüger
97962d7643
Rollup merge of #137073 - niklaskorz:bootstrap-doc-fix-empty-no-std, r=clubby789
boostrap: skip no_std targets in Std doc step

This fixes a bug that currently prevents us from adding no_std library targets to rustc in nixpkgs (https://github.com/NixOS/nixpkgs/pull/382166).

When running `./x.py doc`, the `Std` doc step generally fails for no_std targets, logs: https://gist.github.com/niklaskorz/fb83f9503ce19b75e8b1af02cdebd592

Skipping no_std targets in this step will allow using no_std targets such as `bpfel-unknown-none` together with other targets in the same config without blocking the doc generator for them, e.g.

```
./configure --release-channel=stable --tools=rustc,rustdoc,rust-analyzer-proc-macro-srv --build=aarch64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-apple-darwin,bpfel-unknown-none

./x.py doc
```

Logs with this fix applied: https://gist.github.com/niklaskorz/cdd50aaea33ede579f737434286d800b
2025-02-17 17:06:10 +01:00
Matthias Krüger
48543dd66d
Rollup merge of #137020 - ferrocene:pa-vendor-sources, r=Kobzol
Pass vendored sources from bootstrap to generate-copyright

In addition to doing the vendoring in bootstrap, this PR also loads the list of manifests to parse from bootstrap (instead of hardcoding a smaller list in generate-copyright). This is best reviewed commit-by-commit.

Fixes https://github.com/rust-lang/rust/issues/136955
2025-02-17 17:06:09 +01:00
Matthias Krüger
005de3877d
Rollup merge of #136959 - nnethercote:simplify-SwitchSources, r=tmiasko
Simplify switch sources

`SwitchSources` and the code around it can be simplified.

r? `@tmiasko`
2025-02-17 17:06:08 +01:00
bors
ce36a966c7 Auto merge of #135763 - nikic:llvm-20, r=cuviper
Update to LLVM 20

LLVM 20 GA is scheduled for March 11th. Rust 1.87 will be stable on May 15th.

* [x] https://github.com/rust-lang/rust/pull/135764
* [x] https://github.com/rust-lang/rust/pull/136134
* [x] https://github.com/rust-lang/compiler-builtins/pull/752
* [x] https://github.com/llvm/llvm-project/pull/125287
* [x] https://github.com/rust-lang/rust/pull/136537
* [x] https://github.com/rust-lang/rust/pull/136895
* [x] Wait for beta branch (Feb 14).

Tested: host-x86_64, host-aarch64, apple, mingw, msvc
2025-02-17 14:19:33 +00:00
Pietro Albini
92f31b95c9
use the shared vendor impl for plan source tarballs 2025-02-17 14:52:02 +01:00
Thalia Archibald
7112474134 Use tell for <File as Seek>::stream_position 2025-02-17 05:25:14 -08:00
Laurențiu Nicola
e08736d70d
Merge pull request #19170 from lnicola/update-lockfile
minor: Update lockfile
2025-02-17 13:06:12 +00:00
Laurențiu Nicola
bce3d0ff1c Update lockfile 2025-02-17 14:50:39 +02:00
Laurențiu Nicola
0c9c489355
Merge pull request #19169 from lnicola/sync-from-rust
minor: Sync from downstream
2025-02-17 12:30:13 +00:00
Laurențiu Nicola
952bfae057 Bump rustc crates 2025-02-17 14:11:12 +02:00
WANG Rui
1873bd3720 Default to the medium code model for the loongarch64-linux toolchains
The medium code model is already the default on the Rust side.
Make sure that linked in C objects (e.g. from glibc) also use
medium code model.
2025-02-17 12:42:00 +01:00
Lukas Wirth
2a0d16f3c4
Merge pull request #19167 from ChayimFriedman2/fix-ref-pat
fix: Fix detection of ref patterns for path patterns
2025-02-17 11:23:18 +00:00
Laurențiu Nicola
b571e8a8ac Merge from rust-lang/rust 2025-02-17 13:20:12 +02:00
Laurențiu Nicola
19fa3deab3 Preparing for merge from rust-lang/rust 2025-02-17 13:20:07 +02:00
bors
2162e9d4b1 Auto merge of #137164 - matthiaskrgr:rollup-dj5826k, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #137095 (Replace some u64 hashes with Hash64)
 - #137100 (HIR analysis: Remove unnecessary abstraction over list of clauses)
 - #137105 (Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.)
 - #137120 (Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows)
 - #137125 (Re-add missing empty lines in the releases notes)
 - #137145 (use add-core-stubs / minicore for a few more tests)
 - #137149 (Remove SSE ABI from i586-pc-windows-msvc)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-17 11:18:33 +00:00
Pietro Albini
a71de77ae9
allow configuring jemalloc per target 2025-02-17 11:43:49 +01:00
Pietro Albini
33e7f9bc66
generate-copyright: pass the vendored sources from bootstrap 2025-02-17 11:00:21 +01:00