Commit Graph

25558 Commits

Author SHA1 Message Date
bors 4ddd4538a8 Auto merge of #154327 - WaffleLapkin:drop_in_place_ref, r=RalfJung,scottmcm,saethlin
change the type of the argument of `drop_in_place` lang item to `&mut _`



We used to special case `core::ptr::drop_in_place` when computing LLVM argument attributes with this hack:

https://github.com/rust-lang/rust/blob/db5e2dc248fe5bb26f70d7baec46a3bca9fa3e1d/compiler/rustc_ty_utils/src/abi.rs#L383-L392

This is because even though `drop_in_place` takes a `*mut T` it is semantically a `&mut T` (remember how `&mut Self` is passed to `Drop::drop`). This is apparently relevant for perf.

This PR replaces this hack with a simpler solution -- it makes `drop_in_place` a thin wrapper around newly added `core::ptr::drop_glue`, which is the actual lang item and takes a `&mut T`:

https://github.com/rust-lang/rust/blob/d2563d5003bbecff1efc40c1f5673ceec603825b/library/core/src/ptr/mod.rs#L810-L833

------

The rest of the PR is blessing tests and cleaning up things which are not necessary after this change.

One thing that is a bit awkward is that now that `drop_glue` is the actual lang item, a lot of the comments referring to `drop_in_place` are outdated. Should I try fixing that?

I've also changed `async_drop_in_place` to take a `&mut T`, and it simplified the code handling it a bit. (since it's unstable we don't need to introduce a wrapper)

-------

cc @RalfJung 
Closes https://github.com/rust-lang/rust/issues/154274
2026-05-07 00:52:53 +00:00
Jonathan Brouwer 2744cb7ac6 Rollup merge of #156211 - kupiakos:space-in-hashbrown-src-location, r=wesleywiser
tests/ui: allow spaces in hashbrown src normalization

If one's home directory contains a space, the default location for the hashbrown source location also contains a space, and so the UI test normalization in issue-21763 fails to normalize as expected.

While this new regex does not handle all valid paths, such as those beginning with `\\?\` or `\\name\`, this handles most absolute UNIX and Windows paths. Relative paths don't seem to be applicable.
2026-05-06 22:39:20 +02:00
Jonathan Brouwer b1d22623ab Rollup merge of #156151 - mejrs:non_macro_attr, r=petrochenkov
Don't return dummy MacroData in `get_macro`

I was experimenting with tool attributes and ast manipulation, and wasted some time figuring out that this was happening. AFAIK all users of `get_macro` are expecting an actual macro (and none were reading the dummy MacroData) so there should be no change in behavior.
2026-05-06 22:39:20 +02:00
bors 365c0e1d7a Auto merge of #155443 - jdonszelmann:canonical, r=lcnr
Improve caching by introducing `TypingMode::ErasedNotCoherence`



r? @lcnr


This introduces `TypingMode::ErasedNotCoherence`. Most typing modes contain a list of opaque types, which are quite often unused during canonicalization. With this change, any time we try canonicalization, we replace whichever typing mode we're currently in with `ErasedNotcoherence`, attempt to canonicalize, and if that fails *retry* in the original typing mode. If erased mode succeeds, this is beneficial because that way the opaque types don't end up in the cache key, allowing more cache reuse.

This seems to have a small (0.5%) slowdown on most programs, but a dramatic (>60%) speedup in specific cases like the rustc-perf `wg-grammar` benchmark. Some more improvements are expected with "eager normalization", which is work that's under way right now.
2026-05-06 13:55:09 +00:00
mejrs facd03622b Don't return dummy MacroData in get_macro 2026-05-06 14:39:39 +02:00
Waffle Lapkin 278517f345 bless codegen-units tests 2026-05-06 13:57:36 +02:00
Waffle Lapkin af5e1da690 bless mir-opt tests 2026-05-06 13:57:36 +02:00
Jana Dönszelmann 7ff71be015 Try to canonicalize with erased opaques, retry when opaques are used. 2026-05-06 10:18:21 +02:00
Jacob Pratt e826e3f3bf Rollup merge of #156205 - lcnr:move-generalization-test, r=lqd
move generalization test

The forth test of https://github.com/rust-lang/trait-system-refactor-initiative/issues/191#issuecomment-3351555279 isn't actually related to closure signature inference.

closes https://github.com/rust-lang/trait-system-refactor-initiative/issues/191, which has already been fixed by https://github.com/rust-lang/rust/pull/155767

r? types
2026-05-05 22:50:27 -04:00
Jacob Pratt f8a77e26f6 Rollup merge of #156195 - danieljofficial:move-tests-codegen, r=JohnTitor
Move tests codegen

Hi, I have moved some tests into the codegen folder
2026-05-05 22:50:27 -04:00
Jacob Pratt 46b1955d9c Rollup merge of #156170 - inq:add-known-bug-test-144442, r=JohnTitor
add known-bug test for coroutine 'static-yields-non-'static unsoundness (#144442)

Add a `known-bug` regression test for [#144442 ("Unsoundness due to 'static coroutines that yield non-'static values").](https://github.com/rust-lang/rust/issues/144442)

Existing known-bug tests:
```
- tests/ui/closures/static-closures-with-nonstatic-return.rs
- tests/ui/implied-bounds/dyn-erasure-tait.rs
- tests/ui/implied-bounds/dyn-erasure-no-tait.rs
```

Verified in Darwin: running the compiled binary segfaults on current main, so the bug is still present.
2026-05-05 22:50:26 -04:00
Jacob Pratt 7eb0a28679 Rollup merge of #155808 - lapla-cogito:issue_155803, r=oli-obk
Always use `ConstFn` context for `const` closures

fixes rust-lang/rust#155803

Since https://github.com/rust-lang/rust/commit/e8a46117795f82f35e2f4087516a8743e28ba174, `hir_body_const_context()` returned the parent's const context for a `const` closure. But a `const` closure can escape its enclosing body via a `fn`-pointer-typed const item or an opaque return type and be invoked at runtime, so it must be const-checked under the most restrictive `ConstFn` context like a regular `const fn`.

r? oli-obk (since you authored the commit mentioned above, feel free to reroll)
2026-05-05 22:50:23 -04:00
Jacob Pratt b2cc990df0 Rollup merge of #155341 - khyperia:non-type-const, r=BoxyUwU
generic_const_args: allow paths to non type consts

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

Non type consts should be usable in the type system in `feature(generic_const_args)`. These are directly plugged into the constant evaluator, unlike type consts, which are attempted to be reasoned about by the type system.

Inherent associated constants are not supported at this time, due to complications around how generic arguments are represented for them (it's currently a mess). The mess is being cleaned up (e.g. https://github.com/rust-lang/rust/pull/154758), so instead of trying to hack support in before the refactoring is done, let's just wait to be able to implement it more cleanly.

r? @BoxyUwU
2026-05-05 22:50:18 -04:00
Jacob Pratt 2717d989c9 Rollup merge of #151122 - Jaidenmagnan:main, r=chenyukang
fix: more descriptive error message for enum to integer

Fixes rust-lang/rust#151116
A  more descriptive error message when casting an enum to an Integer. Please review issue linked above.
2026-05-05 22:50:18 -04:00
Jaiden Magnan 0f5d89fea1 fix: CopyPriority addition 2026-05-05 17:34:50 -04:00
Alyssa Haroldsen a8d85e6368 tests/ui: allow spaces in hashbrown src normalization
If one's home directory contains a space, the default location for the
hashbrown source location also contains a space, and so the UI test
normalization in issue-21763 fails to normalize as expected.

While this new regex does not handle all valid paths, such as those
beginning with `\\?\` or `\\name\`, this handles most absolute UNIX and
Windows paths. Relative paths don't seem to be applicable.
2026-05-05 14:23:02 -07:00
lcnr 8634d63321 move test 2026-05-05 22:31:00 +02:00
Jaiden Magnan 61743bf3b0 fix: adding more verbose error message 2026-05-05 16:19:41 -04:00
khyperia cb2c5fc540 generic_const_args: allow paths to non type consts 2026-05-05 17:35:17 +02:00
danieljofficial 769c3a9a12 add issue links and bless 2026-05-05 16:01:33 +01:00
danieljofficial 3c45cc96e6 move codegen tests into its folder 2026-05-05 15:36:17 +01:00
lapla 0e72a29c93 Always use ConstFn context for const closures 2026-05-05 22:43:54 +09:00
Jonathan Brouwer 17e266a1ae Rollup merge of #156184 - cyrgani:macros-are-weird, r=petrochenkov
Revert "remove `MethodReceiverExpr` special-casing"

This reverts commit 5ad560f7ec and adds a regression test.

Fixes rust-lang/rust#156084.

r? @petrochenkov
2026-05-05 14:25:24 +02:00
Jonathan Brouwer 73e5912d1e Rollup merge of #156058 - qaijuang:issue-151393, r=JohnTitor
Print HRTB binders before fn qualifiers

Fixes rust-lang/rust#151393

This PR updates the custom fn-signature diff used in type mismatch diagnostics to print higher-ranked binders before fn qualifiers.

We might want to update reference also: https://github.com/rust-lang/reference/blob/581920f9109f141b88b860b3e1e8359e3896a150/src/items/external-blocks.md?plain=1#L60
2026-05-05 14:25:23 +02:00
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
cyrgani ee350203e8 Revert "remove MethodReceiverExpr special-casing"
This reverts commit 5ad560f7ec and adds a regression test.
2026-05-05 10:56:28 +00:00
inq 227a289461 add known-bug test for coroutine 'static-yields-non-'static unsoundness
Coroutine variant of the closure / impl Fn 'static unsoundness family.
References in PR description.
2026-05-05 17:44:35 +07:00
Waffle Lapkin 2051cb8e00 change type of async_drop_in_place to accept &mut _ 2026-05-05 12:36:39 +02:00
Waffle Lapkin 810eae99af rename drop_in_place lang item to drop_glue 2026-05-05 12:36:39 +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 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 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
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
Waffle Lapkin 40f3908f54 bless miri/codegen-llvm/ui tests 2026-05-04 15:35:40 +02:00
Vadim Petrochenkov 65e5bd6610 resolve: Catch "cannot reexport" errors from macros 2.0 better 2026-05-04 15:51:36 +03: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
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 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
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
bors ad3a598ca4 Auto merge of #156113 - JonathanBrouwer:rollup-yXpNY1L, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#153536 (Add `const_param_ty_unchecked` gate)
 - rust-lang/rust#155528 (const-stabilize `char::is_control()`)
 - rust-lang/rust#156086 (VaList::next_arg: track_caller for better Miri errors)
2026-05-03 17:54:12 +00:00
Jonathan Brouwer 43fbdfd2f4 Rollup merge of #153536 - zedddie:const-param-ty-unchecked-gate, r=BoxyUwU
Add `const_param_ty_unchecked` gate

Add `const_param_ty_unchecked` internal feature gate to skip `ConstParamTy_` trait enforcement on type. Provides an escape hatch for writing tests and examples that use const generics without needing to ensure all fields implement `ConstParamTy_`.

r? BoxyUwU
2026-05-03 19:23:52 +02:00
Jonathan Brouwer 081e7c4481 Rollup merge of #155433 - oli-obk:bye-bye-long-attribute, r=RalfJung,ShoyuVanilla
Rip out rustc_layout_scalar_valid_range_* attribute support

And either removes tests for it or replaces the uses with pattern types.

primarily fixes rust-lang/rust#135996

fixes rust-lang/rust#147761
fixes rust-lang/rust#133652
2026-05-03 16:33:22 +02:00