Commit Graph

281672 Commits

Author SHA1 Message Date
Nikita Popov
31cc4c074d Emit getelementptr inbounds nuw for pointer::add() 2025-02-19 11:32:32 +01:00
Nikita Popov
5e9d8a7d55 Switch to the LLVMBuildGEPWithNoWrapFlags API
This API allows us to set the nuw flag as well.
2025-02-19 11:32:32 +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
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
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
Chayim Refael Friedman
b7a9a32126 Fix detection of ref patterns for path patterns
I was wrong on #19127, I thought hir-def resolver is enough for them, but it turns out not because of paths like `<Enum>::Variant` and `Type::AssocThatIsEnum::Variant`.
2025-02-17 11:51:29 +02:00
Lukas Wirth
c7a2986c20
Merge pull request #19158 from PoignardAzur/expaned_pub_glob_imports
Implement expand_glob_reexport assist
2025-02-17 09:46:29 +00:00
Miguel Ojeda
f46c7652d5 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.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2025-02-17 10:46:01 +01:00
Lukas Wirth
d7fb8f15c7
Merge pull request #19122 from Austaras/master
pass struct fields to chalk
2025-02-17 09:37:55 +00:00
klensy
6fa3ad1e5e correct comment 2025-02-17 12:32:26 +03:00
Nikita Popov
9cbc310314 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 09:57:13 +01:00
Lukas Wirth
123f17c57b
Merge pull request #19127 from ChayimFriedman2/different-generic-args
feat: Refactor path lowering and serve a new path diagnostic
2025-02-17 08:30:10 +00:00
bors
273465e1f2 Auto merge of #137163 - matthiaskrgr:rollup-ovgfkns, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #136466 (Start removing `rustc_middle::hir::map::Map`)
 - #136671 (Overhaul `rustc_middle::limits`)
 - #136817 (Pattern Migration 2024: clean up and comment)
 - #136844 (Use `const_error!` when possible)
 - #137080 (bootstrap: add more tracing to compiler/std/llvm flows)
 - #137101 (`invalid_from_utf8[_unchecked]`: also lint inherent methods)
 - #137140 (Fix const items not being allowed to be called `r#move` or `r#static`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-17 08:10:13 +00:00
Laurențiu Nicola
6b46937305
Merge pull request #19166 from ChayimFriedman2/runnables-order
fix: Fix sorting of runnables
2025-02-17 05:58:35 +00:00
Jiri Bobek
7bb5f4dd78 improve cold_path() 2025-02-17 06:39:58 +01:00
Matthias Krüger
183fc30867
Rollup merge of #137149 - Noratrieb:wtf-is-this-target, r=RalfJung
Remove SSE ABI from i586-pc-windows-msvc

As an i586 target, it should not have SSE. This caused the following warning to be emitted:

```
warning: target feature `sse2` must be enabled to ensure that the ABI of the current target can be implemented correctly
  |
  = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>

warning: 1 warning emitted
```

see #116344.

r? RalfJung
2025-02-17 06:38:17 +01:00
Matthias Krüger
3293afbef7
Rollup merge of #137145 - RalfJung:minicore, r=jieyouxu
use add-core-stubs / minicore for a few more tests

See https://github.com/rust-lang/rust/issues/131485 for context. These are some tests I worked on in the past so I figured I'd see if `minicore` works for them. :)
2025-02-17 06:38:17 +01:00
Matthias Krüger
18e0746406
Rollup merge of #137125 - Urgau:reapply-empty-lines-relnotes, r=Mark-Simulacrum
Re-add missing empty lines in the releases notes

cf. https://github.com/rust-lang/rust/pull/135797#discussion_r1957168194 and https://rust-lang.zulipchat.com/#narrow/channel/241545-t-release/topic/1.2E85/near/499937064
2025-02-17 06:38:16 +01:00
Matthias Krüger
7cae8e1f50
Rollup merge of #137120 - ChrisDenton:its-all-relative, r=GuillaumeGomez
Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows

The problem with the error message on Windows is:

- The path separators are different
- The OS error message string is different

Normalizing those two things makes the test pass on Windows.
2025-02-17 06:38:15 +01:00
Matthias Krüger
fae72a07dd
Rollup merge of #137105 - zachs18:cow-derefpure-restrict, r=Nadrieril
Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.

Fixes #136046

`feature(deref_patterns)` tracking issue: https://github.com/rust-lang/rust/issues/87121

`Cow<'_, T>` should only implement `DerefPure` if its `Deref` impl is pure, which requires `<T::Owned as Borrow<T>>::borrow`  to be pure. This PR restricts `impl DerefPure for Cow<'_, T>` to `T: Sized + Clone`, `T = [U: Clone]`, and `T = str` (for all of whom `<T::Owned as Borrow<T>>::borrow` is implemented in the stdlib and is pure).

cc ``@Nadrieril``

------

An alternate approach would be to introduce a new `unsafe trait BorrowPure<T>` analogous to `DerefPure`  that could be implemented for `T: Sized`, `&T`, `&mut T`, `String`, `Vec`, `Box`, `PathBuf`, `OsString`, etc. https://github.com/rust-lang/rust/compare/master...zachs18:borrow-pure-trait
2025-02-17 06:38:15 +01:00
Matthias Krüger
2a25a16c57
Rollup merge of #137100 - fmease:hirtylow-rm-clauses-wrapper, r=compiler-errors
HIR analysis: Remove unnecessary abstraction over list of clauses

`rustc_hir_analysis::bounds::Bounds` with its methods is nowadays a paper-thin wrapper around `Vec<(Clause, Span)>`s and `Vec::push` essentially.

Its existence slightly annoyed me (and I keep opening its corresp. file instead of the identically named `bounds.rs` in `hir_ty_lowering/` that I actually want most of the time :P).

Opening to check if you agree with inlining it.
r? compiler-errors or reassign
2025-02-17 06:38:14 +01:00
Matthias Krüger
fab38375bc
Rollup merge of #137095 - saethlin:use-hash64-for-hashes, r=workingjubilee
Replace some u64 hashes with Hash64

I introduced the Hash64 and Hash128 types in https://github.com/rust-lang/rust/pull/110083, essentially as a mechanism to prevent hashes from landing in our leb128 encoding paths. If you just have a u64 or u128 field in a struct then derive Encodable/Decodable, that number gets leb128 encoding. So if you need to store a hash or some other value which behaves very close to a hash, don't store it as a u64.

This reverts part of https://github.com/rust-lang/rust/pull/117603, which turned an encoded Hash64 into a u64.

Based on https://github.com/rust-lang/rust/pull/110083, I don't expect this to be perf-sensitive on its own, though I expect that it may help stabilize some of the small rmeta size fluctuations we currently see in perf reports.
2025-02-17 06:38:14 +01:00
Matthias Krüger
f0710999a9
Rollup merge of #137140 - Noratrieb:const-move, r=jieyouxu,compiler-errors
Fix const items not being allowed to be called `r#move` or `r#static`

Because of an ambiguity with const closures, the parser needs to ensure that for a const item, the `const` keyword isn't followed by a `move` or `static` keyword, as that would indicate a const closure:

```rust
fn main() {
  const move // ...
}
```

This check did not take raw identifiers into account, therefore being unable to distinguish between `const move` and `const r#move`. The latter is obviously not a const closure, so it should be allowed as a const item.

This fixes the check in the parser to only treat `const ...` as a const closure if it's followed by the *proper keyword*, and not a raw identifier.

Additionally, this adds a large test that tests for all raw identifiers in all kinds of positions, including `const`, to prevent issues like this one from occurring again.

fixes #137128
2025-02-17 06:37:39 +01:00
Matthias Krüger
86f3d525e0
Rollup merge of #137101 - GrigorenkoPV:str-inherent-lint, r=Urgau
`invalid_from_utf8[_unchecked]`: also lint inherent methods

Addressing https://github.com/rust-lang/rust/issues/131114#issuecomment-2646663535

Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
2025-02-17 06:37:38 +01:00
Matthias Krüger
5dd48bce7c
Rollup merge of #137080 - jieyouxu:more-tracing, r=onur-ozkan
bootstrap: add more tracing to compiler/std/llvm flows

- Add more tracing to compiler/std/llvm flows.
- Two drive-by nits:
    1. Take `TargetSelection` by-value for `builder.is_builder_target()`. Noticed while adding tracing; follow-up to #136767.
    2. Coalesce enzyme build logic into one branch.
- Document `COMPILER{,_FOR}` tracing targets for #96176.
- No functional changes.

### Testing

You can play with the tracing locally with:

```
$ BOOTSTRAP_TRACING=bootstrap=debug ./x build library
$ BOOTSTRAP_TRACING=bootstrap=trace ./x build library
$ BOOTSTRAP_TRACING=bootstrap=trace,COMPILER=trace,COMPILER_FOR=trace ./x build library
```

### Previews

```
$ BOOTSTRAP_TRACING=bootstrap=debug ./x build library
```

![Screenshot 2025-02-15 230824](https://github.com/user-attachments/assets/c3b02b62-d52e-4c03-a00a-da0d95618989)

```
$ BOOTSTRAP_TRACING=bootstrap=trace,COMPILER=trace,COMPILER_FOR=trace ./x build library
```

![Screenshot 2025-02-15 233859](https://github.com/user-attachments/assets/842e4ece-4c26-4191-acbb-5f93e42de4dc)

r? ``@onur-ozkan`` (or reroll)
2025-02-17 06:37:37 +01:00
Matthias Krüger
c04801dbb9
Rollup merge of #136844 - thaliaarchi:const-io-error, r=ChrisDenton
Use `const_error!` when possible

Replace usages of `io::Error::new(io::ErrorKind::Variant, "constant string")` with `io::const_error!(io::ErrorKind::Variant, "constant string")` to avoid allocations when possible. Additionally, fix `&&str` error messages in SGX and missing/misplaced trailing commas in `const_error!`.
2025-02-17 06:37:37 +01:00