about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2025-06-17Add a missing colon at the end of the expected panic message in ↵Daniel Paoliello-1/+1
location-detail-unwrap-multiline.rs
2025-06-17Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obkbors-1021/+4167
Sized Hierarchy: Part I This patch implements the non-const parts of rust-lang/rfcs#3729. It introduces two new traits to the standard library, `MetaSized` and `PointeeSized`. See the RFC for the rationale behind these traits and to discuss whether this change makes sense in the abstract. These traits are unstable (as is their constness), so users cannot refer to them without opting-in to `feature(sized_hierarchy)`. These traits are not behind `cfg`s as this would make implementation unfeasible, there would simply be too many `cfg`s required to add the necessary bounds everywhere. So, like `Sized`, these traits are automatically implemented by the compiler. RFC 3729 describes changes which are necessary to preserve backwards compatibility given the introduction of these traits, which are implemented and as follows: - `?Sized` is rewritten as `MetaSized` - `MetaSized` is added as a default supertrait for all traits w/out an explicit sizedness supertrait already. There are no edition migrations implemented in this, as these are primarily required for the constness parts of the RFC and prior to stabilisation of this (and so will come in follow-up PRs alongside the const parts). All diagnostic output should remain the same (showing `?Sized` even if the compiler sees `MetaSized`) unless the `sized_hierarchy` feature is enabled. Due to the use of unstable extern types in the standard library and rustc, some bounds in both projects have had to be relaxed already - this is unfortunate but unavoidable so that these extern types can continue to be used where they were before. Performing these relaxations in the standard library and rustc are desirable longer-term anyway, but some bounds are not as relaxed as they ideally would be due to the inability to relax `Deref::Target` (this will be investigated separately). It is hoped that this is implemented such that it could be merged and these traits could exist "under the hood" without that being observable to the user (other than in any performance impact this has on the compiler, etc). Some details might leak through due to the standard library relaxations, but this has not been observed in test output. **Notes:** - Any commits starting with "upstream:" can be ignored, as these correspond to other upstream PRs that this is based on which have yet to be merged. - This best reviewed commit-by-commit. I've attempted to make the implementation easy to follow and keep similar changes and test output updates together. - Each commit has a short description describing its purpose. - This patch is large but it's primarily in the test suite. - I've worked on the performance of this patch and a few optimisations are implemented so that the performance impact is neutral-to-minor. - `PointeeSized` is a different name from the RFC just to make it more obvious that it is different from `std::ptr::Pointee` but all the names are yet to be bikeshed anyway. - `@nikomatsakis` has confirmed [that this can proceed as an experiment from the t-lang side](https://rust-lang.zulipchat.com/#narrow/channel/435869-project-goals/topic/SVE.20and.20SME.20on.20AArch64.20.28goals.23270.29/near/506196491) - FCP in https://github.com/rust-lang/rust/pull/137944#issuecomment-2912207485 Fixes rust-lang/rust#79409. r? `@ghost` (I'll discuss this with relevant teams to find a reviewer)
2025-06-16miri: bless testsDavid Wood-4/+4
These error messages include lines of the standard library which have changed and so need updated.
2025-06-16miri: fix buildDavid Wood-1/+1
It isn't clear why the `Deref` impl isn't found for this in a stage two build, but presumably relates to `rustc_middle::ty::RawList` containing an extern type and `Deref` not yet being relaxed to `PointeeSized` (this is technically a breaking change but unlikely to be one and will be tested in a follow-up).
2025-06-16cranelift/gcc: `{Meta,Pointee,}Sized` in minicoreDavid Wood-60/+72
As in many previous commits, adding the new traits to minicore, but this time for cranelift and gcc.
2025-06-16clippy: `{Meta,Pointee,}Sized` in non-minicoreDavid Wood-2/+8
One clippy test is `no_core` and needs to have `MetaSized` and `PointeeSized` added to it.
2025-06-16clippy: add `MetaSized` conditionsDavid Wood-1/+8
Existing lints that had special-casing for `Sized` predicates ought to have these same special cases applied to `MetaSized` predicates.
2025-06-16bootstrap: address lint failuresDavid Wood-2/+2
Unexpected Clippy lint triggering is fixed in upcoming commits but is necessary for `cfg(bootstrap)`.
2025-06-16rustdoc: `PointeeSized` bounds with extern typesDavid Wood-1/+1
As before, updating types using extern types to use `PointeeSized` bounds.
2025-06-16rustdoc: `{Meta,Pointee,}Sized` in non-minicoreDavid Wood-21/+109
Some rustdoc tests are `no_core` and need to have `MetaSized` and `PointeeSized` added to them.
2025-06-16rustdoc: skip `MetaSized` boundsDavid Wood-7/+52
These should never be shown to users at the moment.
2025-06-16trait_sel: skip `nominal_obligations` for `Sized`David Wood-36/+12
`nominal_obligations` calls `predicates_of` on a `Sized` obligation, effectively elaborating the trait and making the well-formedness checking machinery do a bunch of extra work checking a `MetaSized` obligation is well-formed, but given that both `Sized` and `MetaSized` are built-ins, if `Sized` is otherwise well-formed, so `MetaSized` will be.
2025-06-16trait_sel: skip elaboration of sizedness supertraitDavid Wood-40/+268
As a performance optimization, skip elaborating the supertraits of `Sized`, and if a `MetaSized` obligation is being checked, then look for a `Sized` predicate in the parameter environment. This makes the `ParamEnv` smaller which should improve compiler performance as it avoids all the iteration over the larger `ParamEnv`.
2025-06-16trait_sel: extend fast path with sized hierarchyDavid Wood-23/+47
Extend the fast path for `Sized` traits to include constness and `MetaSized`.
2025-06-16tests: bless remaining testsDavid Wood-25/+135
These tests just need blessing, they don't have any interesting behaviour changes. Some of these tests have new errors because `LegacyReceiver` cannot be proven to be implemented now that it is also testing for `MetaSized` - but this is just a consequence of the other errors in the test.
2025-06-16tests: add overflow testDavid Wood-0/+66
This test case is a reduction from the `hwc` crate on GitHub, following a crater run. It passes with the next solver but fails on the current solver due to a known limitation of the current solver. It starts fails on the current solver with the `sized_hierarchy` changes because `?Sized` is now a proper bound.
2025-06-16tests: unconstrain params in `non_lifetime_binders`David Wood-43/+64
It seems like generics from `non_lifetime_binders` don't have any default bounds like normal generics, so all of the `?Sized` relaxations need to be further relaxed with `PointeeSized` for this test to be the equivalent of before.
2025-06-16tests: update tests with unconstrained parametersDavid Wood-7/+32
With the addition of new bounds to the unconstrained parameters, there are more errors which just need blessed.
2025-06-16tests: `PointeeSized` bounds with extern typesDavid Wood-69/+131
These tests necessarily need to change now that `?Sized` is not sufficient to accept extern types and `PointeeSized` is now necessary. In addition, the `size_of_val`/`align_of_val` test can now be changed to expect an error.
2025-06-16middle: print `{Meta,Pointee}Sized` in opaquesDavid Wood-5/+150
When `sized_hierarchy` is enabled, rustc should print `MetaSized` or `PointeeSized` instead of `?Sized` in opaques.
2025-06-16trait_sel: print `{Meta,Pointee}Sized` impl headersDavid Wood-16/+252
When printing impl headers in a diagnostic, the compiler has to account for `?Sized` implying `MetaSized` and new `MetaSized` and `PointeeSized` bounds.
2025-06-16trait_sel: sort `{Meta,Pointee}Sized` diagnostics lastDavid Wood-10/+17
Like `Sized` diagnostics, sorting `MetaSized` and `PointeeSized` diagnostics last prevents earlier more useful diagnostics from being skipped because there has already been error tainting.
2025-06-16trait_sel: `MetaSized` bounds in dispatchable checkDavid Wood-8/+15
Given the necessary additions of bounds to these traits and their impls in the standard library, it is necessary to add `MetaSized` bounds to the obligation which is proven as part of checking for dyn dispatchability.
2025-06-16trait_sel: stash `{Meta,Pointee}Sized` errorsDavid Wood-1/+4
`Sized` errors are currently stashed to improve diagnostics and this must happen with `{Meta,Pointee}Sized` too to maintain diagnostic output.
2025-06-16aux: add `{Meta,Pointee}Sized` bounds to minicoreDavid Wood-40/+40
With `MetaSized` bounds replacing `?Sized` and being added as a supertrait, the same relaxations applied to the standard library must be applied to minicore.
2025-06-16hir_analysis: add `{Meta,Pointee}Sized` boundsDavid Wood-207/+798
Opting-out of `Sized` with `?Sized` is now equivalent to adding a `MetaSized` bound, and adding a `MetaSized` or `PointeeSized` bound is equivalent to removing the default `Sized` bound - this commit implements this change in `rustc_hir_analysis::hir_ty_lowering`. `MetaSized` is also added as a supertrait of all traits, as this is necessary to preserve backwards compatibility. Unfortunately, non-global where clauses being preferred over item bounds (where `PointeeSized` bounds would be proven) - which can result in errors when a `PointeeSized` supertrait/bound/predicate is added to some items. Rather than `PointeeSized` being a bound on everything, it can be the absence of a bound on everything, as `?Sized` was.
2025-06-16lint: don't consider sizedness in upcastable lintDavid Wood-2/+2
Adding a sizedness supertrait shouldn't require multiple vtables so shouldn't be linted against.
2025-06-16library/compiler: add `PointeeSized` boundsDavid Wood-219/+310
As core uses an extern type (`ptr::VTable`), the default `?Sized` to `MetaSized` migration isn't sufficient, and some code that previously accepted `VTable` needs relaxed to continue to accept extern types. Similarly, the compiler uses many extern types in `rustc_codegen_llvm` and in the `rustc_middle::ty::List` implementation (`OpaqueListContents`) some bounds must be relaxed to continue to accept these types. Unfortunately, due to the current inability to relax `Deref::Target`, some of the bounds in the standard library are forced to be stricter than they ideally would be.
2025-06-16tests: `{Meta,Pointee}Sized` in non-minicore testsDavid Wood-172/+616
As before, add `MetaSized` and `PointeeSized` traits to all of the non-minicore `no_core` tests so that they don't fail for lack of language items.
2025-06-16Auto merge of #142447 - dianqk:llvm-20.1.7, r=nikicbors-0/+0
Update to LLVM 20.1.7 Closes rust-lang/rust#141306, closes rust-lang/rust#140686, closes rust-lang/rust#141737, closes rust-lang/rust#140933.
2025-06-16Auto merge of #142589 - Kobzol:rollup-j90fk2j, r=Kobzolbors-238/+912
Rollup of 8 pull requests Successful merges: - rust-lang/rust#139340 (Fix RISC-V C function ABI when passing/returning structs containing floats) - rust-lang/rust#142341 (Don't suggest converting `///` to `//` when expecting `,`) - rust-lang/rust#142414 (ignore `run-make` tests that need `std` on targets without `std`) - rust-lang/rust#142498 (Port `#[rustc_as_ptr]` to the new attribute system) - rust-lang/rust#142554 (Fix `PathSource` lifetimes.) - rust-lang/rust#142562 (Update the `backtrace` submodule) - rust-lang/rust#142565 (Test naked asm for wasm32-unknown-unknown) - rust-lang/rust#142573 (`fn candidate_is_applicable` to method) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-16Rollup merge of #142573 - lcnr:search_graph-3, r=lqdJakub Beránek-17/+6
`fn candidate_is_applicable` to method r? `@BoxyUwU`
2025-06-16Rollup merge of #142565 - bjorn3:wasm32_unknown_naked_asm_test, r=RalfJungJakub Beránek-3/+6
Test naked asm for wasm32-unknown-unknown cc https://github.com/rust-lang/rust/pull/133952#discussion_r2148924872
2025-06-16Rollup merge of #142562 - tgross35:update-backtrace, r=workingjubileeJakub Beránek-0/+0
Update the `backtrace` submodule Pick up the following pull requests: * ci: remove binary size check (not relevant in rust-lang/rust) <https://github.com/rust-lang/backtrace-rs/pull/710> * Upgrade `ruzstd`, `object`, and `addr2line` to the latest versions <https://github.com/rust-lang/backtrace-rs/pull/718>
2025-06-16Rollup merge of #142554 - nnethercote:fix-PathSource-lifetimes, r=petrochenkovJakub Beránek-33/+33
Fix `PathSource` lifetimes. It currently has two, which don't accurately capture what's happening -- the `TupleStruct` spans are allocated in `ResolverArenas`, which is different to where the `Expr` is allocated -- and require some "outlives" constraints to be used. This commit adds another lifetime, renames the existing ones, and removes the "outlives" constraints. r? `@petrochenkov`
2025-06-16Rollup merge of #142498 - GrigorenkoPV:as-ptr-refactor, r=jdonszelmannJakub Beránek-13/+41
Port `#[rustc_as_ptr]` to the new attribute system It might make sense to introduce some new parser analogous to `Single`, but even more simple: for parsing attributes that take no arguments and may appear only once (such as `#[rustc_as_ptr]` or `#[rustc_const_stable_indirect]`). Not sure if this should be a single `impl` parsing all such attributes, or one impl per attribute. Or how it will play along with the upcoming rework of attribute validation. Or how these argumentless attributes should be called (I've loosely referred to them as `markers` in the name of the new module in this PR, but not sure how good it is). This is a part of rust-lang/rust#131229, so r? `@jdonszelmann` --- For reference, the `#[rustc_as_ptr]` attribute was created back in rust-lang/rust#132732 as a followup to rust-lang/rust#128985.
2025-06-16Rollup merge of #142414 - folkertdev:ignore-nostd-tests, r=jieyouxuJakub Beránek-21/+184
ignore `run-make` tests that need `std` on targets without `std` In particular, anything that includes `none` in the target triple, and `nvptx64-nvidia-cuda`. Right now we don't cross-compile the `run-make` tests, but we want to in the future. This uses `//@ needs-target-std` introduced in https://github.com/rust-lang/rust/pull/142297. Useful for https://github.com/rust-lang/rust/pull/139244 and https://github.com/rust-lang/rust/pull/141856. The modified files are based on running https://github.com/rust-lang/rust/pull/141856 locally. It might be that https://github.com/rust-lang/rust/pull/139244 uncovers some additional files, but that PR needs to be rebased (though actually I'd advice to rebase the non-test changes onto this PR, probably faster that way). r? ``@jieyouxu`` <details> <summary>vim notes for future me</summary> Make a file with lines like this ``` /home/folkertdev/rust/rust/tests/run-make/export/disambiguator/rmake.rs:1:1 /home/folkertdev/rust/rust/tests/run-make/invalid-so/rmake.rs:1:1 /home/folkertdev/rust/rust/tests/run-make/no-builtins-attribute/rmake.rs:1:1 /home/folkertdev/rust/rust/tests/run-make/export/extern-opt/rmake.rs:1:1 /home/folkertdev/rust/rust/tests/run-make/link-dedup/rmake.rs:1:1 ``` then ``` :set errorformat=%f:%l:%c :cfile /tmp/files-to-fix.txt ``` ``` :copen :cnext :cprev ``` are your friends </details>
2025-06-16Rollup merge of #142341 - xizheyin:142311, r=fee1-deadJakub Beránek-17/+105
Don't suggest converting `///` to `//` when expecting `,` Fixes rust-lang/rust#142311
2025-06-16Rollup merge of #139340 - beetrees:riscv-float-struct-abi, r=workingjubileeJakub Beránek-134/+537
Fix RISC-V C function ABI when passing/returning structs containing floats RISC-V passes structs containing only one or two floats (or a float and integer pair) in registers, as long as the individual floats/integers fit in a single corresponding register (see [the ABI specification](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/download/v1.0/riscv-abi.pdf) for details). Before this PR, Rust would not check what offset the second float/integer was at, instead assuming that it was at the standard offset for its default alignment. However, as the offset can be affected by `#[repr(align(N))]` and `#[repr(packed)]`, this caused miscompilations (see #115609). To fix this, this PR introduces a `rest_offset` field to `CastTarget` that can be used to explicitly specify at what offset the `rest` part of the cast is located at. While fixing this, I discovered another bug: the size of the cast target was being used as the size of the MIR return place (when the function was using a `PassMode::Cast` return type). However, the cast target is allowed to be smaller than the size of the actual type, causing a miscompilation. This PR fixes this issue by using the largest of the size of the type and the size of the cast target as the size of the MIR return place, ensuring all reads/writes will be inbounds. Fixes the RISC-V part of #115609. cc target maintainers of `riscv64gc-unknown-linux-gnu`: `@kito-cheng` `@michaelmaitland` `@robin-randhawa-sifive` `@topperc` r? `@workingjubilee`
2025-06-16Port `#[rustc_as_ptr]` to the new attribute systemPavel Grigorenko-13/+41
2025-06-16Dont suggest converting `///` to regular comment when it appears after ↵xizheyin-17/+105
missing `,` in list Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-16aux: add `{Meta,Pointee}Sized` to minicoreDavid Wood-2/+15
Add `MetaSized` and `PointeeSized` to minicore so that fewer tests fail from missing language items.
2025-06-16trait_sel: `{Meta,Pointee}Sized` on `?Sized` typesDavid Wood-220/+907
Expand the automatic implementation of `MetaSized` and `PointeeSized` so that it is also implemented on non-`Sized` types, just not `ty::Foreign` (extern type).
2025-06-16trait_sel: `{Meta,Pointee}Sized` on `Sized` typesDavid Wood-1/+253
Introduce the `MetaSized` and `PointeeSized` traits as supertraits of `Sized` and initially implement it on everything that currently implements `Sized` to isolate any changes that simply adding the traits introduces.
2025-06-16Auto merge of #142574 - Kobzol:rollup-ldj386u, r=Kobzolbors-203/+693
Rollup of 12 pull requests Successful merges: - rust-lang/rust#141639 (Expose discriminant values in stable_mir) - rust-lang/rust#142082 (Refactor `rustc_attr_data_structures` documentation) - rust-lang/rust#142125 (Stabilize "file_lock" feature) - rust-lang/rust#142236 (Add documentation for `PathBuf`'s `FromIterator` and `Extend` impls) - rust-lang/rust#142373 (Fix Debug for Location) - rust-lang/rust#142416 (Assorted bootstrap cleanups (step 2)) - rust-lang/rust#142431 (Add initial version of snapshot tests to bootstrap) - rust-lang/rust#142450 (Add documentation on top of `rustc_middle/src/query/mod.rs`) - rust-lang/rust#142528 (clarify `rustc_do_not_const_check` comment) - rust-lang/rust#142530 (use `if let` guards where possible) - rust-lang/rust#142561 (Remove an `njn:` comment accidentaly left behind.) - rust-lang/rust#142566 (Fix `-nopt` CI jobs) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-16Rollup merge of #142566 - Kobzol:ci-nopt-fix, r=jieyouxuJakub Beránek-10/+2
Fix `-nopt` CI jobs They were using `--config` instead of `--set`, which overrides too much stuff after recent changes to config merging. Should hopefully unblock https://github.com/rust-lang/rust/pull/142447. r? `@jieyouxu`
2025-06-16Rollup merge of #142561 - nnethercote:fix-njn-comment, r=chenyukangJakub Beránek-1/+2
Remove an `njn:` comment accidentaly left behind. r? `@chenyukang`
2025-06-16Rollup merge of #142530 - fee1-dead-contrib:push-klusvwusyqvq, r=compiler-errorsJakub Beránek-20/+12
use `if let` guards where possible these crates already enable the feature
2025-06-16Rollup merge of #142528 - fee1-dead-contrib:push-rlxklunqkwmv, r=RalfJungJakub Beránek-2/+2
clarify `rustc_do_not_const_check` comment ~~Given that we have used this attribute for other reasons before it seems appropriate to make this a "usually".~~ Add function name as a pointer cc ```@rust-lang/wg-const-eval```
2025-06-16Rollup merge of #142450 - xizheyin:rustc-query-doc, r=SparrowLiiJakub Beránek-4/+60
Add documentation on top of `rustc_middle/src/query/mod.rs` The `rustc-dev-guide` gives a high-level intro, but many details—especially about how the code works and modifiers in `query xxx(){...}`—are only in code comments or the macro implementation. This doc makes it easier for contributors and code readers to understand the workflow and available modifiers without jumping between files and docs. This PR adds a comprehensive module-level doc comment to `rustc_middle::query::mod.rs` that: 1. Provides an overview of the query system and macro-based query definitions for reading code more easily 2. Centralizes documentation for all query modifiers (previously scattered or only in `rustc_macro` code), closely following the authoritative list in QueryModifiers.