Commit Graph

285573 Commits

Author SHA1 Message Date
Noah Lev
4a0cca3a38 wip on lowering as const blocks 2025-04-10 23:07:40 -04:00
Noah Lev
0cea2c1fa5 Centralize const item lowering logic 2025-04-10 21:34:30 -04:00
Noah Lev
42745dcb5a Lower to const path if possible in const item value 2025-04-10 18:49:24 -04:00
Noah Lev
6054bd5468 Add optional ConstArg field to assoc consts in HIR 2025-04-09 12:14:21 -04:00
Noah Lev
acd3ad9e26 Add optional ConstArg field to ItemKind::Const
Currently always None, but will be Some if the const item value is a
const path.
2025-04-07 17:26:21 -04:00
bors
e0883a2a6c Auto merge of #137738 - Daniel-Aaron-Bloom:const_slice_make_iter, r=dtolnay
Make slice iterator constructors unstably const

See [tracking issue](https://github.com/rust-lang/rust/issues/137737) for justification.

try-job: aarch64-apple
try-job: x86_64-gnu
2025-04-03 08:57:46 +00:00
bors
b6d74b5e15 Auto merge of #139250 - dianqk:llvm-20.1.2, r=cuviper
Update to LLVM 20.1.2

`@rustbot` label A-LLVM T-compiler
2025-04-03 03:27:29 +00:00
bors
3658060890 Auto merge of #139234 - compiler-errors:query-tweak, r=oli-obk
Misc query tweaks

Remove some redundant work around `cache_on_disk` and `ensure_ok`, since `Result<(), ErrorGuaranteed>` queries don't need to cache or recompute their "value" if they are only used for their result.
2025-04-03 00:13:54 +00:00
bors
d5b4c2e4f1 Auto merge of #139269 - matthiaskrgr:rollup-pk78gig, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #138992 (literal pattern lowering: use the pattern's type instead of the literal's in `const_to_pat`)
 - #139211 (interpret: add a version of run_for_validation for &self)
 - #139235 (`AstValidator` tweaks)
 - #139237 (Add a dep kind for use of the anon node with zero dependencies)
 - #139260 (Add dianqk to codegen reviewers)
 - #139264 (Fix two incorrect turbofish suggestions)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-02 18:39:21 +00:00
Matthias Krüger
278bc67fdc
Rollup merge of #139264 - freyacodes:fix/bad-turbofish-hints, r=petrochenkov
Fix two incorrect turbofish suggestions

This fixes #121901

This is my contribution to Rust, and my first contribution to a language parser that I didn't write myself.
I am a bit outside my depth here, so any constructive criticism is appreciated.
2025-04-02 19:44:15 +02:00
Matthias Krüger
43f17288e1
Rollup merge of #139260 - dianqk:dianqk-codegen-reviewers, r=Urgau
Add dianqk to codegen reviewers

Not an expert yet, but I may be able to review some LLVM-related PRs.

r? codegen
2025-04-02 19:44:14 +02:00
Matthias Krüger
3c5ee8d5f9
Rollup merge of #139237 - Zoxc:anon-0-deps-kind, r=compiler-errors
Add a dep kind for use of the anon node with zero dependencies

This adds a dep kind for use of the anon node with zero dependencies instead of making use of the null node. I don't think this matters, but it is nicer than random null nodes in the dep graph.
2025-04-02 19:44:14 +02:00
Matthias Krüger
ad8db11b94
Rollup merge of #139235 - nnethercote:AstValidator-tweaks, r=compiler-errors
`AstValidator` tweaks

When I read through `AstValidator` there were several things that tripped me up, and made the code harder to understand than I would have liked. This PR addresses them. Best reviewed one commit at a time.

r? ``@davidtwco``
2025-04-02 19:44:13 +02:00
Matthias Krüger
f5276bb0cf
Rollup merge of #139211 - RalfJung:interpret-run-for-validation, r=oli-obk
interpret: add a version of run_for_validation for &self

Turns out we'll need this for some ongoing work in Miri.

r? ``@oli-obk``
2025-04-02 19:44:13 +02:00
Matthias Krüger
3fb1230adc
Rollup merge of #138992 - dianne:simplify-byte-string-to-pat, r=oli-obk
literal pattern lowering: use the pattern's type instead of the literal's in `const_to_pat`

This has two purposes:
- First, it enables removing the `treat_byte_string_as_slice` fields from `TypeckResults` and `ConstToPat`. A byte string pattern's type will be `&[u8]` when matching on a slice reference, so `const_to_pat` will lower it to a slice ref pattern. I believe this is tested by `tests/ui/match/pattern-deref-miscompile.rs`.
- Second, it will simplify the implementation of byte string literals in deref patterns. If byte string patterns can be given the type `[u8; N]` or `[u8]` during HIR typeck, then nothing needs to be changed in `const_to_pat` in order to lower the patterns `deref!(b"..."): Vec<u8>` and `deref!(b"..."): Box<[u8; 3]>`.

Implementation-wise, this uses `lit_to_const` to make a const with the pattern's type and the literal's valtree; that feels to me like the best way to make sure that the valtree representations of the pattern type and literal are the same. Though it may necessitate later changes to `lit_to_const` to accommodate giving byte string literal patterns non-reference types—would that be reasonable?

This unfortunately doesn't work for the `string_deref_patterns` feature (since that gives string literal patterns the `String` type), so I added a workaround for that. However, once `deref_patterns` supports string literals, it may be able to replace `string_deref_patterns`; the special case for `String` can removed at that point.

r? ``@oli-obk``
2025-04-02 19:44:12 +02:00
Daniel Bloom
20417a9522 Make slice iterator constructors unstably const 2025-04-02 10:39:14 -07:00
Freya Arbjerg
d8d27ca822 Fix two incorrect turbofish suggestions
Fixes #121901
2025-04-02 18:10:34 +02:00
dianqk
d5f7e9c200
Add dianqk to codegen reviewers 2025-04-02 22:23:19 +08:00
bors
4f0de4c81d Auto merge of #139257 - TaKO8Ki:rollup-vjzdas7, r=TaKO8Ki
Rollup of 5 pull requests

Successful merges:

 - #139178 (Remove cjgillot from automated review assignment)
 - #139184 (Add unstable `--print=crate-root-lint-levels`)
 - #139215 (Add `opt-level = "s"` for more std symbolication crates)
 - #139232 (Move methods from `Map` to `TyCtxt`, part 5.)
 - #139239 (Remove `aux_build` run-make rustc helpers)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-02 14:17:11 +00:00
Takayuki Maeda
abcfc3e390
Rollup merge of #139239 - jieyouxu:run-make-aux-build, r=Kobzol
Remove `aux_build` run-make rustc helpers

They provide very little value and makes it more confusing than is
helpful.

Helps with #138066.

r? `@Kobzol`
2025-04-02 22:52:47 +09:00
Takayuki Maeda
bda2ea4d01
Rollup merge of #139232 - nnethercote:remove-Map-5, r=Zalathar
Move methods from `Map` to `TyCtxt`, part 5.

This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR.

A follow-up to #137504.

r? `@Zalathar`
2025-04-02 22:52:46 +09:00
Takayuki Maeda
5df0c684f4
Rollup merge of #139215 - clubby789:std-size-tweaks, r=joboet
Add `opt-level = "s"` for more std symbolication crates

This reduces the size of a hello world binary built by stage 1 in release by a few kilobytes
2025-04-02 22:52:46 +09:00
Takayuki Maeda
eb23a597c8
Rollup merge of #139184 - Urgau:crate-root-lint-levels, r=jieyouxu
Add unstable `--print=crate-root-lint-levels`

This PR implements `--print=crate-root-lint-levels` from MCP 833 https://github.com/rust-lang/compiler-team/issues/833.

Tracking issue: https://github.com/rust-lang/rust/issues/139180

Best reviewed commit by commit.
2025-04-02 22:52:45 +09:00
Takayuki Maeda
13c2d5e71e
Rollup merge of #139178 - apiraino:remove-cjgillot-automated-assighment, r=cjgillot
Remove cjgillot from automated review assignment

As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Review.20for.20.23137465/with/508540539).

To be clear, this is not a value judgement, it's just a way to improve our fairness when assigning reviews, trying to find a balance between leaving time to Rust contributors review on their terms and availability and avoid having PRs waiting for too long.

> [!IMPORTANT]
> This is not a final decision! Rust contributors are free to re-add themselves back to the active review rotation (if they feel like it) once they have more availability.

cc: `@cjgillot`
2025-04-02 22:52:45 +09:00
dianqk
6e6d4a8cc5
Update to LLVM 20.1.2 2025-04-02 20:19:43 +08:00
bors
ae9173d7dd Auto merge of #139018 - oli-obk:incremental-trait-impls, r=compiler-errors
Various local trait item iteration cleanups

Adding a trait impl for `Foo` unconditionally affected all queries that are interested in a completely independent trait `Bar`. Perf has no effect on this. We probably don't have a good perf test for this tho.

r? `@compiler-errors`

I am unsure about 9d05efb66f as it doesn't improve anything wrt incremental, because we still do all the checks for valid `Drop` impls, which subsequently will still invoke many queries and basically keep the depgraph the same.

I want to do

9549077a47/compiler/rustc_middle/src/ty/trait_def.rs (L141)

but would leave that to a follow-up PR, this one changes enough things as it is
2025-04-02 10:10:50 +00:00
Jieyou Xu
f31bd747a9
Update run-make tests to no longer use aux_build 2025-04-02 15:40:22 +08:00
Jieyou Xu
b591eb022d
Drop aux_build rustc helpers
They provide very little value and makes it more confusing than is
helpful.
2025-04-02 15:39:55 +08:00
Oli Scherer
49c74d29fd Only walk local items instead of filtering for them later 2025-04-02 07:30:11 +00:00
Oli Scherer
798987982c Remove a function that has no necessary callers 2025-04-02 07:30:11 +00:00
Oli Scherer
062ef5365d Remove a hir_* helper that was just forwarding to a query 2025-04-02 07:30:11 +00:00
Oli Scherer
7192a0643d Directly fetch the impl self type 2025-04-02 07:30:11 +00:00
Oli Scherer
6697f02761 Fetch the destructor constness lazily 2025-04-02 07:30:11 +00:00
Oli Scherer
ca32447c0c Only look at trait impls in the current crate when looking for Drop impls 2025-04-02 07:30:11 +00:00
bors
79de6c0bbe Auto merge of #138848 - clubby789:cargo-update, r=Mark-Simulacrum
Update dependencies

#136077 needs manual tweaking
```
    compiler and tools dependencies
        Updating anyhow v1.0.95 -> v1.0.97
        Updating basic-toml v0.1.9 -> v0.1.10
        Updating bitflags v2.8.0 -> v2.9.0
        Updating blake3 v1.5.5 -> v1.8.0
        Updating bumpalo v3.16.0 -> v3.17.0
        Removing byteorder v1.5.0
        Updating bytes v1.9.0 -> v1.10.1
        Updating cargo_metadata v0.19.1 -> v0.19.2
        Updating chrono v0.4.39 -> v0.4.40
        Updating chrono-tz v0.10.1 -> v0.10.3
        Updating chrono-tz-build v0.4.0 -> v0.4.1
        Updating clap v4.5.26 -> v4.5.35
        Updating clap_builder v4.5.26 -> v4.5.35
        Updating clap_derive v4.5.24 -> v4.5.35
        Updating console v0.15.10 -> v0.15.11
        Updating cpufeatures v0.2.16 -> v0.2.17
        Updating curl-sys v0.4.78+curl-8.11.0 -> v0.4.80+curl-8.12.1
        Updating darling v0.20.10 -> v0.20.11
        Updating darling_core v0.20.10 -> v0.20.11
        Updating darling_macro v0.20.10 -> v0.20.11
        Updating deranged v0.3.11 -> v0.4.1
        Updating dissimilar v1.0.9 -> v1.0.10
        Updating either v1.13.0 -> v1.15.0
        Updating elsa v1.11.0 -> v1.11.2
        Updating env_logger v0.11.6 -> v0.11.7
        Updating equivalent v1.0.1 -> v1.0.2
        Updating flate2 v1.0.35 -> v1.1.0
        Updating foldhash v0.1.4 -> v0.1.5
        Updating getrandom v0.3.1 -> v0.3.2
        Updating globset v0.4.15 -> v0.4.16
     Downgrading html5ever v0.29.2 -> v0.29.1 (available: v0.30.0)
        Updating humantime v2.1.0 -> v2.2.0
        Updating icu_list_data v1.5.0 -> v1.5.1
        Updating icu_locid_transform_data v1.5.0 -> v1.5.1
        Updating icu_normalizer_data v1.5.0 -> v1.5.1
        Updating icu_properties_data v1.5.0 -> v1.5.1
        Updating indexmap v2.7.0 -> v2.8.0
        Updating indicatif v0.17.9 -> v0.17.11
        Updating inout v0.1.3 -> v0.1.4
        Updating itoa v1.0.14 -> v1.0.15
          Adding jiff v0.2.5
          Adding jiff-static v0.2.5
        Updating jobserver v0.1.32 -> v0.1.33
        Updating lexopt v0.3.0 -> v0.3.1
          Adding leb128fmt v0.1.0
        Updating libc v0.2.169 -> v0.2.171
        Updating libz-sys v1.1.21 -> v1.1.22
        Updating linux-raw-sys v0.4.15 -> v0.9.3
        Updating litemap v0.7.4 -> v0.7.5
        Updating log v0.4.25 -> v0.4.27
     Downgrading markup5ever v0.15.0 -> v0.14.1
        Updating miniz_oxide v0.8.3 -> v0.8.5
        Updating once_cell v1.20.2 -> v1.21.3
        Updating openssl-probe v0.1.5 -> v0.1.6
        Updating openssl-sys v0.9.104 -> v0.9.106
        Updating pest v2.7.15 -> v2.8.0
        Updating pest_derive v2.7.15 -> v2.8.0
        Updating pest_generator v2.7.15 -> v2.8.0
        Updating pest_meta v2.7.15 -> v2.8.0
        Updating pkg-config v0.3.31 -> v0.3.32
        Updating portable-atomic v1.10.0 -> v1.11.0
          Adding portable-atomic-util v0.2.4
        Updating ppv-lite86 v0.2.20 -> v0.2.21
        Updating proc-macro2 v1.0.93 -> v1.0.94
        Updating quote v1.0.38 -> v1.0.40
          Adding r-efi v5.2.0
        Updating rand_core v0.9.0 -> v0.9.3
        Updating redox_syscall v0.5.8 -> v0.5.10
        Updating rustc-stable-hash v0.1.1 -> v0.1.2
        Updating rustc_tools_util v0.4.0 -> v0.4.2
        Updating rustix v0.38.43 -> v1.0.5
        Updating rustversion v1.0.19 -> v1.0.20
        Updating ryu v1.0.18 -> v1.0.20
        Updating semver v1.0.24 -> v1.0.26
        Updating serde v1.0.217 -> v1.0.219
        Updating serde_derive v1.0.217 -> v1.0.219
        Updating serde_json v1.0.135 -> v1.0.140
        Updating similar v2.6.0 -> v2.7.0
        Updating smallvec v1.13.2 -> v1.14.0
        Updating socket2 v0.5.8 -> v0.5.9
        Updating stacker v0.1.18 -> v0.1.20
        Updating string_cache v0.8.8 -> v0.8.9
        Updating syn v2.0.96 -> v2.0.100
        Updating tar v0.4.43 -> v0.4.44
        Updating tempfile v3.15.0 -> v3.19.1
        Updating thin-vec v0.2.13 -> v0.2.14
        Updating thiserror v2.0.11 -> v2.0.12
        Updating thiserror-impl v2.0.11 -> v2.0.12
        Updating time v0.3.37 -> v0.3.41
        Updating time-core v0.1.2 -> v0.1.4
        Updating time-macros v0.2.19 -> v0.2.22
        Updating tinyvec v1.8.1 -> v1.9.0
        Updating tokio v1.43.0 -> v1.44.1
        Updating typenum v1.17.0 -> v1.18.0
        Updating unicode-ident v1.0.14 -> v1.0.18
        Updating uuid v1.12.0 -> v1.16.0
        Updating wasi v0.13.3+wasi-0.2.2 -> v0.14.2+wasi-0.2.4
        Removing wasm-encoder v0.219.1
        Removing wasm-encoder v0.223.0
          Adding wasm-encoder v0.219.2 (available: v0.227.1)
          Adding wasm-encoder v0.223.1
          Adding wasm-encoder v0.228.0
        Updating wasm-metadata v0.223.0 -> v0.223.1
        Removing wasmparser v0.219.1
        Removing wasmparser v0.222.0
        Removing wasmparser v0.223.0
          Adding wasmparser v0.219.2 (available: v0.227.1)
          Adding wasmparser v0.222.1
          Adding wasmparser v0.223.1
          Adding wasmparser v0.228.0
        Updating wast v223.0.0 -> v228.0.0
        Updating wat v1.223.0 -> v1.228.0
        Updating windows-core v0.52.0 -> v0.61.0
          Adding windows-implement v0.60.0
        Updating windows-interface v0.59.0 -> v0.59.1
          Adding windows-link v0.1.1
        Updating windows-result v0.3.0 -> v0.3.2
        Updating windows-strings v0.3.0 -> v0.3.1
          Adding windows-strings v0.4.0
        Updating wit-bindgen-rt v0.33.0 -> v0.39.0
        Updating wit-component v0.223.0 -> v0.223.1
        Updating wit-parser v0.223.0 -> v0.223.1
        Updating xattr v1.4.0 -> v1.5.0
        Updating zerocopy v0.8.14 -> v0.8.24
        Updating zerocopy-derive v0.8.14 -> v0.8.24
        Updating zerofrom v0.1.5 -> v0.1.6
        Updating zerofrom-derive v0.1.5 -> v0.1.6
```
2025-04-02 06:58:57 +00:00
John Kåre Alsaker
927ad1659a Add a dep kind for use of the anon node with zero dependencies 2025-04-02 07:35:05 +02:00
Nicholas Nethercote
2e7de1a924 Reduce scope of AstValidator::with_* calls.
`AstValidator` has several `with_*` methods, each one setting a field
that adjust how checking takes place for items within certain other
items. E.g. `with_in_trait_impl` is used to adjust the checking done on
items inside an `impl` item. Weirdly, the scopes used for most of the
`with_*` calls are very broad, and include things that aren't "inside"
the item, such as visibility, unsafety, and constness.

This commit minimizes the scope of these `with_*` calls so they only
apply to the things inside the item.
2025-04-02 15:43:11 +11:00
dianne
7a4d4de8a8 add tests for array/slice const patterns 2025-04-01 21:35:12 -07:00
Michael Goulet
3524e6ab0f ensure_ok().query doesn't need cache_on_disk 2025-04-02 04:01:15 +00:00
Michael Goulet
444a7eb5aa Use return_result_from_ensure_ok a bit more 2025-04-02 04:01:15 +00:00
Michael Goulet
a3e6b69471 cache_on_disk_if false is a noop 2025-04-02 03:59:48 +00:00
bors
c9cd707845 Auto merge of #139229 - Zalathar:rollup-5cs3f4d, r=Zalathar
Rollup of 14 pull requests

Successful merges:

 - #135295 (Check empty SIMD vector in inline asm)
 - #138003 (Add the new `amx` target features and the `movrs` target feature)
 - #138823 (rustc_target: RISC-V: add base `I`-related important extensions)
 - #138913 (Remove even more instances of `@ts-expect-error` from search.js)
 - #138941 (Do not mix normalized and unnormalized caller bounds when constructing param-env for `receiver_is_dispatchable`)
 - #139060 (replace commit placeholder in vendor status with actual commit)
 - #139102 (coverage: Avoid splitting spans during span extraction/refinement)
 - #139191 (small opaque type/borrowck cleanup)
 - #139200 (Skip suggest impl or dyn when poly trait is not a real trait)
 - #139208 (fix dead link netbsd.md)
 - #139210 (chore: remove redundant backtick)
 - #139212 (Update mdbook to 0.4.48)
 - #139214 (Tell rustfmt to use the 2024 edition in ./x.py fmt)
 - #139225 (move autodiff from EnzymeAD/Enzyme to our rust-lang/Enzyme soft-fork)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-02 03:48:21 +00:00
Nicholas Nethercote
fb01485690 Rename span-related names in AstValidator.
A bunch of span-related names in `AstValidator` don't end in `span`,
which goes against the usual naming conventions and makes the code
surprisingly hard to read. E.g. a name like `body` doesn't sound like
it's a span.

This commit adds `_span` suffixes.
2025-04-02 14:21:52 +11:00
Stuart Cook
ea51a1c055
Rollup merge of #139225 - EnzymeAD:rust-lang-enzyme, r=jieyouxu
move autodiff from EnzymeAD/Enzyme to our rust-lang/Enzyme soft-fork

In https://github.com/rust-lang/team/pull/1665 we decided to have a soft-fork of Enzyme, to be able to merge e.g. CI, docs, or cmake improvements if upstream is not interested in them. We don't intend to merge logic/code changes. It also seems generally preferable if we clone submodules from a rust-lang repo, instead of an external org. We don't build or checkout Enzyme yet by default, so this should be a safe rollup.
2025-04-02 13:10:43 +11:00
Stuart Cook
82f04468e9
Rollup merge of #139214 - bjorn3:edition_2024_rustfmt, r=compiler-errors
Tell rustfmt to use the 2024 edition in ./x.py fmt

Most crates in this repo have been moved to the 2024 edition already. This also allows removing a rustfmt exclusion for a cg_clif test.
2025-04-02 13:10:42 +11:00
Stuart Cook
5f05d43922
Rollup merge of #139212 - ehuss:update-mdbook, r=Mark-Simulacrum
Update mdbook to 0.4.48

This brings in several updates. Two significant ones are to halve the search index size, and the other introduces major changes to footnote rendering.

Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0448
2025-04-02 13:10:42 +11:00
Stuart Cook
cedb554473
Rollup merge of #139210 - highcloudwind:master, r=aDotInTheVoid
chore: remove redundant backtick

remove redundant backtick
2025-04-02 13:10:41 +11:00
Stuart Cook
e89ba0bf95
Rollup merge of #139208 - futreall:master, r=jieyouxu
fix dead link netbsd.md

src/doc/rustc/src/platform-support/netbsd.md
https://github.com/NetBSD/pkgsrc-wip/blob/master/rust/Makefile - https://github.com/NetBSD/pkgsrc-wip/blob/master/Makefile
2025-04-02 13:10:41 +11:00
Stuart Cook
2d43a8b20d
Rollup merge of #139200 - xizheyin:issue-139174, r=compiler-errors
Skip suggest impl or dyn when poly trait is not a real trait

Fixes #139174
When `poly_trait_ref` is not a real trait, we should stop suggesting `impl` and `dyn` to avoid false positives. 3 cases were added to the ui test.
0b45675cfc/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs (L88-L93)

In the first commit, I submitted the test and passed it. In the second commit, I modified the code and we can see the changes in the test.

r? compiler
2025-04-02 13:10:40 +11:00
Stuart Cook
2311b342bc
Rollup merge of #139191 - lcnr:interner-opaques, r=compiler-errors
small opaque type/borrowck cleanup

pulled out of #138785
2025-04-02 13:10:40 +11:00