Commit Graph

281545 Commits

Author SHA1 Message Date
Scott McMurray
3a3aedee10 Update some comparison tests now that they pass in LLVM20 2025-02-17 16:36:14 -08: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
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
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
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
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
Matthias Krüger
767ec0a8ad
Rollup merge of #136817 - dianne:clean-and-comment-pat-migration, r=Nadrieril
Pattern Migration 2024: clean up and comment

This follows up on #136577 by moving the pattern migration logic to its own module, removing a bit of unnecessary complexity, and adding comments. Since there's quite a bit of pattern migration logic now (and potentially more in #136496), I think it makes sense to keep it separate from THIR construction, at least as much as is convenient.

r? ``@Nadrieril``
2025-02-17 06:37:36 +01:00
Matthias Krüger
0c051c8196
Rollup merge of #136671 - nnethercote:middle-limits, r=Nadrieril
Overhaul `rustc_middle::limits`

In particular, to make `pattern_complexity` work more like other limits, which then enables some other simplifications.

r? ``@Nadrieril``
2025-02-17 06:37:35 +01:00
Matthias Krüger
f3a4f1a02a
Rollup merge of #136466 - nnethercote:start-removing-Map, r=cjgillot
Start removing `rustc_middle::hir::map::Map`

`rustc_middle::hir::map::Map` is now just a low-value wrapper around `TyCtxt`. This PR starts removing it.

r? `@cjgillot`
2025-02-17 06:37:35 +01:00
Nicholas Nethercote
f666361caa Remove TyCtxt::hir_krate.
It's a trivial wrapper around the `hir_crate` query with a small number
of uses.
2025-02-17 13:24:40 +11:00
Nicholas Nethercote
661f99ba03 Overhaul the intravisit::Map trait.
First of all, note that `Map` has three different relevant meanings.
- The `intravisit::Map` trait.
- The `map::Map` struct.
- The `NestedFilter::Map` associated type.

The `intravisit::Map` trait is impl'd twice.
- For `!`, where the methods are all unreachable.
- For `map::Map`, which gets HIR stuff from the `TyCtxt`.

As part of getting rid of `map::Map`, this commit changes `impl
intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's
fairly straightforward except various things are renamed, because the
existing names would no longer have made sense.

- `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named
  because it gets some HIR stuff from a `TyCtxt`.
- `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`,
  because it's always `!` or `TyCtxt`.
- `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`.

I deliberately made the new trait and associated type names different to
avoid the old `type Map: Map` situation, which I found confusing. We now
have `type MaybeTyCtxt: HirTyCtxt`.
2025-02-17 13:21:35 +11:00
Nicholas Nethercote
f86f7ad5f2 Move some Map methods onto TyCtxt.
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17 13:21:02 +11:00
bors
d5eb31c934 Auto merge of #136953 - ken-matsui:import-target-metadata, r=workingjubilee
rustc_target: import TargetMetadata
2025-02-17 02:01:59 +00:00
Ken Matsui
b660382f12
rustc_target: import TargetMetadata 2025-02-16 17:53:36 -05:00
Nicholas Nethercote
cd1d84cdf7 Remove unused Map::hir_node_by_def_id method. 2025-02-17 09:53:27 +11:00
Nicholas Nethercote
6021ba0668 Rename rustc_middle/src/hir/map/mod.rs as map.rs.
There is no need for the extra subdirectory, and this makes the `map`
module consistent with its sibling modules `nested_filter` and `place`.
2025-02-17 09:53:27 +11:00
Nicholas Nethercote
b51ab7d9be Clarify impl Map for !.
All the methods are unreachable, so make that clearer.
2025-02-17 09:53:27 +11:00
Nicholas Nethercote
7ff67901ac Avoid unnecessary use of the Map trait.
The `Map` trait is there for cases where `tcx` isn't available. This
isn't one of those cases, so it's simpler to just call through `tcx`
directly.
2025-02-17 09:53:27 +11:00
Nicholas Nethercote
7a8c0fc117 Rename pattern_complexity attr as pattern_complexity_limit.
For consistency with `recursion_limit`, `move_size_limit`, and
`type_length_limit`.
2025-02-17 09:30:40 +11:00
Nicholas Nethercote
223c95fd59 Move rustc_middle::limits to rustc_interface.
It's always good to make `rustc_middle` smaller. `rustc_interface` is
the best destination, because it's the only crate that calls
`get_recursive_limit`.
2025-02-17 09:30:39 +11:00
Nicholas Nethercote
13280eed6a Improve comments about limits. 2025-02-17 09:30:37 +11:00
Nicholas Nethercote
30b8c84de6 Merge get_limit and get_limit_size.
Thanks to the previous commit, they no longer need to be separate.
2025-02-17 09:30:35 +11:00
Nicholas Nethercote
b023671ce2 Add pattern_complexity_limit to Limits.
It's similar to the other limits, e.g. obtained via `get_limit`. So it
makes sense to handle it consistently with the other limits. We now use
`Limit`/`usize` in most places instead of `Option<usize>`, so we use
`Limit::new(usize::MAX)`/`usize::MAX` to emulate how `None` used to work.

The commit also adds `Limit::unlimited`.
2025-02-17 09:30:33 +11:00
bors
d1fb81e8dd Auto merge of #137143 - matthiaskrgr:rollup-9hapmyd, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #136986 (Apply unsafe_op_in_unsafe_fn to the standard library)
 - #137012 (add docs and ut for bootstrap util cc-detect)
 - #137072 (Load all builtin targets at once instead of one by one in check-cfg)
 - #137102 (Rework `name_regions` to not rely on reverse scc graph for non-member-constrain usages)
 - #137112 (Don't project into `NonNull` when dropping a `Box`)
 - #137114 (Add an example for `std::error::Error`)
 - #137117 (Fix test that relies on error language)
 - #137119 (fix broken `x {doc, build} core`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-16 21:23:25 +00:00
Ben Kimock
4cf21866e8 Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer 2025-02-16 16:18:30 -05:00
Noratrieb
1c66d5bed9 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
```
2025-02-16 21:13:01 +01:00
bors
5bc6231454 Auto merge of #137127 - pietroalbini:pa-musl-cve-2025-26519, r=jieyouxu
Fix musl's CVE-2025-26519

The musl project [announced CVE-2025-26519](https://www.openwall.com/lists/musl/2025/02/13/1), which could result in out-of-bounds writes when calling the `iconv` function. There is no musl release available with the fixes at this point in time (and we're using an older version of musl anyway), so this PR applies the provided patches on top of the musl source tarball we download.
2025-02-16 18:20:57 +00:00
Ralf Jung
4a4207a650 use add-core-stubs / minicore for a few more tests 2025-02-16 18:37:50 +01:00
Noratrieb
8a02724b9d 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.
2025-02-16 18:21:40 +01:00
Matthias Krüger
e802a8cc01
Rollup merge of #137119 - onur-ozkan:fix-broken-core, r=jieyouxu
fix broken `x {doc, build} core`

Fixes #137115
2025-02-16 17:14:07 +01:00
Matthias Krüger
7374439111
Rollup merge of #137117 - ChrisDenton:error-lang, r=fmease,Noratrieb
Fix test that relies on error language

We shouldn't care about the OS error message text in this test.
2025-02-16 17:14:06 +01:00
Matthias Krüger
f82764f2d9
Rollup merge of #137114 - ChrisDenton:error, r=Noratrieb
Add an example for `std::error::Error`

There is currently no example provided for `std::error::Error` so let's fix that.
2025-02-16 17:14:06 +01:00
Matthias Krüger
b125096821
Rollup merge of #137112 - scottmcm:box-drop-no-nonnull-project, r=oli-obk
Don't project into `NonNull` when dropping a `Box`

Another step towards banning these projections.

Tracking Issue #133652
2025-02-16 17:14:05 +01:00
Matthias Krüger
ea9c8d9c17
Rollup merge of #137102 - compiler-errors:name_regions2, r=oli-obk
Rework `name_regions` to not rely on reverse scc graph for non-member-constrain usages

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

Splits the `name_regions` into two versions: One meant for member region constraint error reporting (which I've renamed to `name_regions_for_member_constraint`), and one meant *just* to replace region vids with an external region.

Use the latter in the usage sites I added in #136559, since the regions returned by `name_regions_for_member_constraint` are also not *totally* accurate (which is fine for how they're used for member region constraint error reporting -- they're intentionally returning overapproximated universal regions so that we have something to name in `+ use<'a>` suggestions, because opaques can only capture universal regions and since member region constraints don't insert any edges into the region graph, the error region is probably gonna be shorter than a universal region) and because that function requires the reverse scc graph to have been computed which isn't done for our usages in #136559.
2025-02-16 17:14:05 +01:00
Matthias Krüger
fc094a1813
Rollup merge of #137072 - Urgau:check-cfg-load-builtins-at-once, r=Noratrieb
Load all builtin targets at once instead of one by one in check-cfg

This PR adds a method on `rustc_target::Target` to load all the builtin targets at once, and then uses that method when constructing the `target_*` values in check-cfg instead of load loading each target one by one by their name, which requires a lookup and was more of a hack anyway.

This may give us some performance improvements as we won't need to do the lookup for the _currently_ 287 targets we have.
2025-02-16 17:14:04 +01:00
Matthias Krüger
34e789a8fb
Rollup merge of #137012 - Shourya742:2025-02-14-doc-and-unit-test-cc-detect, r=onur-ozkan
add docs and ut for bootstrap util cc-detect

This PR adds doc and unit test for bootstrap utils/cc-detect module
2025-02-16 17:14:03 +01:00
Matthias Krüger
53b4c7c631
Rollup merge of #136986 - ehuss:library-unsafe-fun, r=Noratrieb
Apply unsafe_op_in_unsafe_fn to the standard library

This applies unsafe_op_in_unsafe_fn to the standard library in preparation for updating to Rust 2024.

Closes https://github.com/rust-lang/rust/issues/127747 (I think?) cc ``@workingjubilee``
I have been testing a variety of targets, and I feel like they are all pretty much covered. I'll continue doing some testing async, but I don't expect to catch any more.
2025-02-16 17:14:03 +01:00
Pietro Albini
a6ee2f4af2
fix musl's CVE-2025-26519 2025-02-16 16:36:55 +01:00
bors
a3d4bd382a Auto merge of #136914 - marcoieni:arm-ubuntu-24, r=jdno
ci: use ubuntu 24 for free arm runner

try-job: aarch64-gnu
try-job: aarch64-gnu-debug
2025-02-16 15:07:36 +00:00
Pavel Grigorenko
77571a5c8b clippy: string_from_utf8_as_bytes: also detect inherent from_utf8 2025-02-16 16:34:51 +03:00