Commit Graph

325860 Commits

Author SHA1 Message Date
Jonathan Brouwer e35334f6d4 Rollup merge of #156014 - petrochenkov:kvak, r=mu001999
resolve: Catch "cannot reexport" errors from macros 2.0 better

After the macro 2.0 related holes are closed we can report `span_delayed_bug`s in more situations.

Merging https://github.com/rust-lang/rust/pull/155945 would make changes in this PR simpler, but that PR will probably have to wait for quite some time.

This is a continuation of my import & privacy invariant hardening changes from https://github.com/rust-lang/rust/pull/155257, https://github.com/rust-lang/rust/pull/155213, https://github.com/rust-lang/rust/pull/154149, etc.

r? @mu001999
2026-05-05 14:25:22 +02:00
bors 4feb7221f4 Auto merge of #156166 - GuillaumeGomez:rollup-nfRhhYb, r=GuillaumeGomez
Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#155848 ([doc]: Revert `core::io::ErrorKind` doc changes)
 - rust-lang/rust#155855 (Remove unnecessary `get_unchecked`)
 - rust-lang/rust#155543 (docs(unstable-book): Document const generics features)
 - rust-lang/rust#155962 (`rustc`: `target_features`: allow for `cfg`-only stable `target_features`)
 - rust-lang/rust#156043 (c-variadic: gate `va_arg` on `c_variadic_experimental_arch`)
 - rust-lang/rust#156082 (Move tests associated types)
 - rust-lang/rust#156087 (Improve `&pin` reference-pattern suggestions)
 - rust-lang/rust#156092 (Clean up `TyCtxt::needs_crate_hash` usage and rename it to `needs_hir_hash`.)
 - rust-lang/rust#156103 (Fix E0040 suggestion for explicit `Drop::drop` UFCS calls)
 - rust-lang/rust#156104 (Relax `T: Sized` bound on `try_as_dyn` / `try_as_dyn_mut`)
 - rust-lang/rust#156122 (Add a `doc_cfg` regression test to ensure foreign types impls are working as expected)
 - rust-lang/rust#156128 (.mailmap: prefer matching just based on commit emails)
 - rust-lang/rust#156135 (Remove most uses of def_id_to_node_id)
 - rust-lang/rust#156152 (Update books)
 - rust-lang/rust#156154 (tests: mark import UI tests as check-pass)
 - rust-lang/rust#156162 (Update `browser-ui-test` version to `0.23.5`)
2026-05-05 07:17:39 +00:00
bors 83adf7e080 Auto merge of #155681 - bjorn3:update_dlmalloc, r=clubby789
Remove windows-sys from the library workspace

Windows-sys isn't actually used as dlmalloc doesn't use it on any of the targets where std uses dlmalloc, but still ends up in the lockfile and thus gets vendored. By using a patch to replace it with an empty crate the vendor size of the standard library is reduced from 93MB to 20MB.
2026-05-05 04:09:17 +00:00
Guillaume Gomez ba38fa0147 Rollup merge of #156162 - GuillaumeGomez:update-gui-tester, r=GuillaumeGomez
Update `browser-ui-test` version to `0.23.5`

This new version adds a small delay on page loads (with a timeout of 500ms) to give more time for some checks to work as expected.

r? ghost
2026-05-05 02:50:16 +02:00
Guillaume Gomez 7bf810e176 Rollup merge of #156154 - SynapLink:cleanup/check-pass-import-tests, r=folkertdev
tests: mark import UI tests as check-pass

These import and extern-prelude UI tests only exercise checking behavior, so they do not need codegen or linking.

Mark them as check-pass and remove the old FIXME(62277) markers.
2026-05-05 02:50:15 +02:00
Guillaume Gomez 6c3772206b Rollup merge of #156152 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/reference

4 commits in 8c88f9d0bdd75ffdc0691676d83212ae22a18cee..581920f9109f141b88b860b3e1e8359e3896a150
2026-04-30 02:40:57 UTC to 2026-04-28 16:48:51 UTC

- Document trailing `self` in paths (rust-lang/reference#2237)
- add trailing comma (to follow style guidelines) (rust-lang/reference#2244)
- Doc: Add the LoongArch stabilized target features (rust-lang/reference#2217)
- typo (rust-lang/reference#2241)
2026-05-05 02:50:14 +02:00
Guillaume Gomez e4ed73e971 Rollup merge of #156135 - oli-obk:def_id_to_node_id_reduction, r=petrochenkov
Remove most uses of def_id_to_node_id

Especially those happening during normal resolving, where we are actually looking at current parent scopes. It allows follow-up refactorings to not have a way to go from `NodeId` to `DefId` until macro expansion is done

r? @petrochenkov
2026-05-05 02:50:14 +02:00
Guillaume Gomez 145df991c1 Rollup merge of #156128 - DanielEScherzer:gg-mailmap, r=GuillaumeGomez
.mailmap: prefer matching just based on commit emails

So that commits under different names are still caught
2026-05-05 02:50:13 +02:00
Guillaume Gomez 1e91ddd0c0 Rollup merge of #156122 - GuillaumeGomez:doc-cfg-test, r=Urgau
Add a `doc_cfg` regression test to ensure foreign types impls are working as expected

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

This is the last case mentioned in the issue that wasn't tested. With this, the issue can be closed.

r? @Urgau
2026-05-05 02:50:13 +02:00
Guillaume Gomez ca222b85ff Rollup merge of #156104 - aobatact:try-as-dyn-unsized, r=oli-obk
Relax `T: Sized` bound on `try_as_dyn` / `try_as_dyn_mut`

`trait_info_of` already returns `None` for unsized types, so allowing `T: ?Sized` is sound and lets callers in generic contexts use these functions without a separate `Sized` bound. For unsized `T`, the function always returns `None`.

Tracking issue: rust-lang/rust#144361

## Motivation

Currently, it is not possible to use `try_as_dyn` as "specialization-like" dispatch in
blanket impls with `?Sized` type.

```rust
// Cannot add ?Sized now.
impl<T: 'static /* + ?Sized */, S: Serializer + 'static> Serialize<S> for T {
    fn serialize(&self, serializer: &mut S) -> Result<S::Ok, S::Error> {
        if let Some(spec) = try_as_dyn::<_, dyn SpecializedSer<S>>(self) {
            spec.specialized_serialize(serializer)
        } else {
            // fall back to compile-time reflection via TypeId
            ...
        }
    }
}
```
2026-05-05 02:50:12 +02:00
Guillaume Gomez 20a4529124 Rollup merge of #156103 - Unique-Usman:ua/fixe0040, r=mejrs
Fix E0040 suggestion for explicit `Drop::drop` UFCS calls

`Drop::drop(&mut f)` now correctly suggests `drop(f)` instead of the bare `drop` with no argument.

Fix: rust-lang/rust#156017
2026-05-05 02:50:11 +02:00
Guillaume Gomez e4097f672e Rollup merge of #156092 - susitsm:needs-hir-hash, r=petrochenkov
Clean up `TyCtxt::needs_crate_hash` usage and rename it to `needs_hir_hash`.

While reviewing `crate_hash` query usage for https://github.com/rust-lang/rust/pull/155871, the `needs_crate_hash` function turned out to be the cause of unnecessary calls to the query. The `needs_crate_hash` name is easy to mistake for the functionality of "needs the crate_hash query". This PR removes the usage of `needs_crate_hash` where it was not appropriate and renames the function to `needs_hir_hash` which better reflects its functionality.
2026-05-05 02:50:11 +02:00
Guillaume Gomez 90cd3d3a96 Rollup merge of #156087 - P8L1:improve-pin-pattern-suggestions, r=Kivooeo
Improve `&pin` reference-pattern suggestions

This fills in the `pin_ergonomics` FIXME in `borrow_pat_suggestion` by making the diagnostic prefix account for both `Pinnedness` and `Mutability`.

Previously, the type-position suggestion path used ordinary reference spelling, which can spell `&` and `&mut` but cannot correctly spell pinned reference-pattern suggestions such as `&pin const` and `&pin mut`.

This is a diagnostic-only change. It adds focused UI coverage for both pinned const and pinned mut reference-pattern suggestions.
2026-05-05 02:50:10 +02:00
Guillaume Gomez 7a08b693d4 Rollup merge of #156082 - danieljofficial:move-tests-associated-types, r=petrochenkov
Move tests associated types

Hi, I have moved some ui tests I feel belong in the associated types folder
2026-05-05 02:50:09 +02:00
Guillaume Gomez be1e98b06e Rollup merge of #156043 - folkertdev:c-variadic-avr-assembly-test, r=joshtriplett
c-variadic: gate `va_arg` on `c_variadic_experimental_arch`

tracking issue: https://github.com/rust-lang/rust/issues/44930

Just gating `...` is insufficient because we make the types available everywhere, and you could still define and export functions that used va_arg for targets where we don't want to stably support it.

r? joshtriplett
2026-05-05 02:50:09 +02:00
Guillaume Gomez 8bf58ee5d4 Rollup merge of #155962 - romancardenas:cfg-only-stable-target-feature, r=RalfJung
`rustc`: `target_features`: allow for `cfg`-only stable `target_features`

This PR introduces a new stabilization level for `target_features`: `CfgOnlyStable`. The motivation is allowing the Rust compiler to expose `target_features` of targets so users can use `cfg(target_feature = "feature")` for conditional blocks depending on target features. However, `CfgOnlyStable` cannot be used for `#[target_feature(enable = "feature")]`, as this is still considered unstable. Accordingly, the compiler will still raise an error if these expressions are used on stable.

This PR relates partially to rust-lang/rust#150257. As discussed, for RISC-V targets, having the `"d"`, `"e"`, and `"f"` target features exposed will allow baremetal developers to adapt the code depending on the target's properties.

r? @RalfJung
2026-05-05 02:50:08 +02:00
Guillaume Gomez 594a848f49 Rollup merge of #155543 - popzxc:document-generic-const-features, r=BoxyUwU
docs(unstable-book): Document const generics features

Relevant tracking issues: rust-lang/rust#113521 rust-lang/rust#132980 rust-lang/rust#76560 rust-lang/rust#151972

## What

Adds a high-level overview of 4 unstable features related to const generic exprs.

## Why

While trying to learn about the current state of const generic exprs, I found it a bit too hard due to lack of documentation -- had to read through a bunch of tracking issues & look for PRs/examples in the repo just to understand what the feature is about.

Moreover, given that there is a bunch of features with similarly-looking names, it was even more confusing. For that purpose, I also added cross-referencing across (directly or logically) related features.

As a result, I decided to add some more context to the unstable book, so that new readers have an easier time than I had.

## Caveats

I understand that the features are incomplete/experimental, so the docs are at risk of becoming stale, but the book entrypoint already has [a corresponding warning](https://doc.rust-lang.org/unstable-book/), so I guess it should be fine.

Also, given that I did research myself, the examples provided might be not the best to showcase the feature -- happy to provide better examples, if you have suggestions. The examples provided are what "made the feature make sense" to me as an outsider, so there is a chance that they will be good for other external readers too, though.

LLM use disclosue: an LLM was used for self-review only; research, coming up with examples, and writing is mine. Issues reported by LLM were fixed manually too.

r? @BoxyUwU
2026-05-05 02:50:07 +02:00
Guillaume Gomez 6b750498bc Rollup merge of #155855 - ChrisDenton:remove-unsafe-get, r=Mark-Simulacrum
Remove unnecessary `get_unchecked`

My benchmarking did not show any issue with using the safe method instead so I assume this isn't an issue any more. But let's do a perf run to be sure.
2026-05-05 02:50:07 +02:00
Guillaume Gomez 6c103078ab Rollup merge of #155848 - bushrat011899:revert_08bd077, r=Mark-Simulacrum
[doc]: Revert `core::io::ErrorKind` doc changes

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: https://github.com/rust-lang/rust/issues/154046
Related: https://github.com/rust-lang/rust/pull/154654

## Description

rust-lang/rust#154654 changed the documentation for `ErrorKind` to remove links to `std` items. These changes were made falsely assuming documentation links from `core` to `std` were not possible. Since it is possible, we can restore the documentation to its original form prior to the `core::io` move.

## Notes

* No AI tooling of any kind was used in the creation of this PR.
2026-05-05 02:50:06 +02:00
Guillaume Gomez 7c44e45f14 Update browser-ui-test version to 0.23.5 2026-05-05 01:11:49 +02:00
Pieter-Louis Schoeman 14d414b7c8 Improve &pin reference-pattern suggestions
* Improve diagnostics for pinned reference patterns
* Gate pin pattern suggestion on pin ergonomics
* Document pin ergonomics suggestion gate
* Remove unnecessary incomplete_features allow

Co-authored-by: Redddy <midzy0228@gmail.com>
* Remove redundant incomplete_features allow

UI tests already allow incomplete_features by default, so the explicit allow is unnecessary.
* Update ref-pat-suggestions stderr

Bless line-number changes after removing the redundant incomplete_features allow.
* Simplify pinned ref pattern suggestion gating
* Fix formatting
* More formatting fixes
2026-05-04 20:24:08 +00:00
Usman Akinyemi e5b42e5084 Fix E0040 suggestion for explicit Drop::drop UFCS calls
`Drop::drop(&mut f)` now correctly suggests `drop(f)` instead of
the bare `drop` with no argument.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-05-05 01:09:33 +05:30
SynapLink f9ddd9fdbb tests: mark import UI tests as check-pass 2026-05-04 19:38:47 +02:00
rustbot 5ace24b058 Update books 2026-05-04 19:01:25 +02:00
Vadim Petrochenkov fadb74734d rust-analyzer: Fix pub_use_of_private_extern_crate lint 2026-05-04 19:58:34 +03:00
Oli Scherer fd701b79a7 Remove most uses of def_id_to_node_id
Especially those happening during normal resolving, where we are actually looking at current parent scopes
2026-05-04 17:40:26 +02:00
Oli Scherer 71177d1b66 Add NodeId to ModuleKind 2026-05-04 17:40:26 +02:00
Román Cárdenas Rodríguez ee9a01aecf rustc: target_features: adapt compile errors and warnings for cfg-only stable features 2026-05-04 17:28:35 +02:00
bors cb40c25f6a Auto merge of #156139 - inq:minimize-reshell-perf, r=lcnr
Short-circuit `calculate_fallback_to_f32` when no float vars

Sharing a small fix.

When no unresolved variable is a `float_vid`, no f32 fallback can apply,
so we can skip `from_float_for_f32_root_vids` (which walks the proof tree
of every pending obligation under the new solver — O(N × M) on crates
with many large obligations).

On ReShell: stage1 wall-clock 2m35s → 1m46s (-49s, ~31%).

Context + profile breakdown will be linked at
rust-lang/trait-system-refactor-initiative#254 after this PR opens.

r? @lcnr
2026-05-04 14:02:18 +00:00
Vadim Petrochenkov 21c58d8ad9 resolve: Harden some invariant checks for visibilities 2026-05-04 15:51:36 +03:00
Vadim Petrochenkov 65e5bd6610 resolve: Catch "cannot reexport" errors from macros 2.0 better 2026-05-04 15:51:36 +03:00
Vadim Petrochenkov cf636ec649 resolve: Factor out reporting of "cannot reexport" errors into a separate function 2026-05-04 15:51:33 +03:00
inq 55ff2e1b14 Short-circuit calculate_fallback_to_f32 when no float vars 2026-05-04 16:45:59 +07:00
bors 1d72d7e813 Auto merge of #156134 - jhpratt:rollup-79KaBC4, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#156120 (Regression test for trait-system-refactor#7)
 - rust-lang/rust#156125 (refactor using ExprParenthesesNeeded where possible)
 - rust-lang/rust#156132 (More lifting tweaks)
2026-05-04 09:31:36 +00:00
Jacob Pratt 037e2b0bb0 Rollup merge of #156132 - nnethercote:more-lifting-tweaks, r=oli-obk
More lifting tweaks

Details in individual commits.

r? @oli-obk
2026-05-04 04:25:25 -04:00
Jacob Pratt 06c89cfdd2 Rollup merge of #156125 - GTimothy:refactor-exprparenthesesneeded, r=ShoyuVanilla
refactor using ExprParenthesesNeeded where possible

Found multiple instances where the equivalent of `ExprParenthesesNeeded` was done 'manually'.
Replaced them with an `ExprParenthesesNeeded::surrounding` call.
2026-05-04 04:25:24 -04:00
Jacob Pratt 19fbc622a6 Rollup merge of #156120 - inq:test-alias-relate-7, r=lcnr
Regression test for trait-system-refactor#7

Adds a regression test for [`AliasRelate` hides info in transitive cases](https://github.com/rust-lang/trait-system-refactor-initiative/issues/7).

The example previously errored under the new solver but compiles cleanly now thanks to eager normalization (post-rust-lang/rust#119106). Verified on both the `old` and `next` revisions.

The issue body has an older TODO suggesting a goal-proving variant test; per lcnr's recent note in `#t-types/trait-system-refactor` ("this isn't an issue as we eagerly normalize"), the underlying mechanism is now resolved across both inference and goal-proving paths, so this single regression test is sufficient. Closing the upstream issue manually after merge.

r? @lcnr
2026-05-04 04:25:24 -04:00
Román Cárdenas Rodríguez df8d029014 rustc: target_features: allow for cfg-only stable target_features 2026-05-04 10:12:27 +02:00
inkyu d4c413e348 Apply suggestion from @lcnr
Co-authored-by: lcnr <rust@lcnr.de>
2026-05-04 15:05:04 +07:00
Folkert de Vries 8e0ebb9044 c-variadic: gate va_arg on c_variadic_experimental_arch
Just gating `...` is insufficient because we make the types available
everywhere, and you could still define and export functions that used
va_arg for targets where we don't want to stably support it.
2026-05-04 10:03:05 +02:00
bors 783062d3c6 Auto merge of #154095 - joboet:vec_clear_truncate, r=nnethercote
std: implement `clear` via `truncate`

This gets rid of some `unsafe`. `truncate(0)` is even documented to be equivalent to `clear`, this makes that equivalence even more obvious.
2026-05-04 06:16:32 +00:00
Nicholas Nethercote 2cf48841f1 Remove silly FmtPrinter<'tcx, 'tcx> instance.
This doesn't match any of the other uses.
2026-05-04 15:50:46 +10:00
Nicholas Nethercote 809fcab63e Shift lift calls outward.
Several printing functions (e.g. `short_string`) take a liftable
parameter. This commit changes the call sites to do the lifting instead.
This simplifies the type signatures and puts the `lift` calls inside
`tls::with` calls which is where they usually appear, and the minor cost
of having more `lift` call sites.
2026-05-04 14:05:16 +10:00
Nicholas Nethercote 67ba480fdb Remove unused 'tcx lifetime from trait Print. 2026-05-04 14:04:55 +10:00
Daniel Scherzer 1e649f13ca .mailmap: prefer matching just based on commit emails
So that commits under different names are still caught
2026-05-03 20:31:11 -07:00
bors a51f3a89b2 Auto merge of #156044 - danieljofficial:move-tests-array-slice-vec, r=JonathanBrouwer
Move tests array slice vec

r? @Kivooeo 
Hi, some tests that belong in the  array-slice-vec folder
2026-05-04 03:00:26 +00:00
GTimothy ed2356a953 refactor using ExprParenthesesNeeded where possible
found multiple instances where the equivalent of ExprParenthesesNeeded
was done 'manually'.
replaced them with a `ExprParenthesesNeeded::surrounding` call
2026-05-04 01:19:01 +02:00
bors 045b17737d Auto merge of #156118 - RalfJung:miri, r=RalfJung
miri subtree update

Subtree update of `miri` to https://github.com/rust-lang/miri/commit/0853747bf78b8b6e314dcdf14ade9c83a6c54f3e.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-05-03 22:28:16 +00:00
Guillaume Gomez 5dd3e5e2bf Add a doc_cfg regression test to ensure foreign types impls are working as expected 2026-05-04 00:05:38 +02:00
inq 44a7eb01fc Regression test for trait-system-refactor#7 2026-05-04 04:00:57 +07:00