Commit Graph

17383 Commits

Author SHA1 Message Date
Jonathan Brouwer 0f6fe2ea22 Rollup merge of #155486 - folkertdev:c-variadic-roundtrip, r=RalfJung
c-variadic: add roundtrip test

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

Test that our `va_arg` implementation matches (as in, can decode) how LLVM passes c-variadic arguments.

And some comment followup to https://github.com/rust-lang/rust/pull/152980 (cc @RalfJung, feel free to review this PR too btw).

r? tgross35
2026-04-19 16:04:34 +02:00
Jonathan Brouwer fa8db59673 Rollup merge of #155294 - mejrs:coalescing, r=chenyukang
Add test for coalescing of diagnostic attribute duplicates

There is an existing [test](github.com/rust-lang/rust/blob/main/tests/ui/diagnostic_namespace/on_unimplemented/report_warning_on_duplicated_options.rs) that warnings for duplicates are emitted, but not for the messages themselves.
2026-04-19 16:04:30 +02:00
Folkert de Vries a852582b35 test that c-variadic arguments roundtrip 2026-04-19 12:51:03 +02:00
bors 6f109d8a2d Auto merge of #155223 - teor2345:fndef-refactor, r=mati865
Refactor FnDecl and FnSig non-type fields into a new wrapper type





#### Why this Refactor?

This PR is part of an initial cleanup for the [arg splat experiment](https://github.com/rust-lang/rust/issues/153629), but it's a useful refactor by itself.

It refactors the non-type fields of `FnDecl`, `FnSig`, and `FnHeader` into a new packed wrapper types, based on this comment in the `splat` experiment PR:
https://github.com/rust-lang/rust/pull/153697#discussion_r3004637413

It also refactors some common `FnSig` creation settings into their own methods. I did this instead of creating a struct with defaults.

#### Relationship to `splat` Experiment

I don't think we can use functional struct updates (`..default()`) to create `FnDecl` and `FnSig`, because we need the bit-packing for the `splat` experiment.

Bit-packing will avoid breaking "type is small" assertions for commonly used types when `splat` is added.
This PR packs these types:
- ExternAbi: enum + `unwind` variants (38) -> 6 bits
- ImplicitSelfKind: enum variants (5) -> 3 bits
- lifetime_elision_allowed, safety, c_variadic: bool -> 1 bit

#### Minor Changes

Fixes some typos, and applies rustfmt to clippy files that got skipped somehow.
2026-04-18 23:46:37 +00:00
Jonathan Brouwer 5c896555de Rollup merge of #155351 - ujjwalvishwakarma2006:reorg-tests-01, r=Kivooeo
Reorganize tests from `tests/ui/issues/`

The following tests are reorganized in this pull request

| old-name | new-sub-dir | new-name |
|-|-|-|
| `auxiliary/issue-2316-a.rs` | `resolve/auxiliary` | `resolve-conflict-local-vs-glob-import-a.rs` |
| `auxiliary/issue-2316-b.rs` | `resolve/auxiliary` | `resolve-conflict-local-vs-glob-import-b.rs` |
| `issue-2316-c.rs` | `resolve/` | `resolve-conflict-local-vs-glob-import.rs` |
| `issue-28839.rs` | `reborrow/` | `reborrow-mutable-reference.rs` |
| `issue-32008.rs` | `overloaded/` | `subtyping-both-lhs-and-rhs-in-add-impl.rs` |
| `issue-45425.rs` | `higher-ranked/` | `binop-lhs-hrtb-subtyping.rs` |

r? Kivooeo
2026-04-18 19:23:16 +02:00
Jonathan Brouwer 0e54c26ac8 Rollup merge of #154843 - nataliakokoromyti:fix-154826-deref-help, r=mati865
Fix conflicting deref move suggestion for LazyLock patterns

fixes rust-lang/rust#154826.

Rust was suggesting *V -> V for let (v,) = *V, which then triggered a follow-up error suggesting the opposite. This patch makes that case suggest borrowing (&*V) instead. Also handles destructuring assignment separately so we don’t emit a misleading &*... fix-it there.
2026-04-18 11:41:31 +02:00
Jonathan Brouwer eca0926c12 Rollup merge of #155308 - JonathanBrouwer:duplicate_errs, r=jdonszelmann
Make `OnDuplicate::Error` the default for attributes

This makes two changes, in separate commits for reviewability:
- Changes all unstable attributes that are currently `OnDuplicate::Warn` to error.
- Makes `OnDuplicate::Error` the default and removes the explicit `ON_DUPLICATE` for ones that currently already error

r? @jdonszelmann
2026-04-18 11:41:29 +02:00
Jonathan Brouwer ae4cf84814 Mark all unstable attributes as OnDuplicate::Error 2026-04-18 10:20:32 +02:00
Jacob Pratt e3676b5ab9 Rollup merge of #155428 - lapla-cogito:issue_139089, r=mejrs
Fix ICE in borrowck mutability suggestion with multi-byte ref sigil

Fixes rust-lang/rust#139089

Similarly to rust-lang/rust#155068, this is another instance where span arithmetic did not account for multi-byte characters. (Note that the ampersand in the test is full-width)

This change also results in correcting some inappropriate suggestions.
2026-04-18 00:05:19 -04:00
Jacob Pratt eb52efbbd2 Rollup merge of #155295 - lapla-cogito:issue_154350, r=JohnTitor
Fix misleading "borrowed data escapes outside of function" diagnostic

Fixes rust-lang/rust#154350

Fall back to `report_general_error()` when `fr_name_and_span` is `None` in function items, since the "escaping data" framing is only appropriate for closures capturing outside variables.
2026-04-18 00:05:18 -04:00
Jacob Pratt db3d08421c Rollup merge of #154935 - Darksonn:dyn-trait-dyn-compat, r=scottmcm
Add Sized supertrait for CoerceUnsized and DispatchFromDyn

This is part of rust-lang/rust#149094. I did not include `Receiver` because I think it is correct to allow non-sized receivers.
2026-04-18 00:05:15 -04:00
lapla a779e054a9 Fix ICE in borrowck mutability suggestion with multi-byte ref sigil 2026-04-18 08:52:11 +09:00
bors e9e32aca5a Auto merge of #155432 - JonathanBrouwer:rollup-dJVrrO0, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#154781 (Fix attribute order implementation)
 - rust-lang/rust#155242 (resolve: Introduce `(Local,Extern)Module` newtypes for local and external modules respectively)
 - rust-lang/rust#149614 (Use `MaybeDangling` in `std`)
 - rust-lang/rust#153178 (Add `TryFromIntError::kind` method and `IntErrorKind::NotAPowerOfTwo` variant)
 - rust-lang/rust#155049 (Documenting the case of `Weak::upgrade` returning `None` when the value behind the reference is missing)

Failed merges:

 - rust-lang/rust#155308 (Make `OnDuplicate::Error` the default for attributes)
2026-04-17 19:17:17 +00:00
Jonathan Brouwer c142d8013c Rollup merge of #154781 - JonathanBrouwer:fix-attr-order, r=jdonszelmann
Fix attribute order implementation

The implementation in https://github.com/rust-lang/rust/pull/153041 contained a mistake :c
I swapped the place where the error message was on, but did not change any code for which attribute was also selected, which explains the empty crater results.
**Interestingly, the original code is broken too, before https://github.com/rust-lang/rust/pull/153041 it always took the last attribute, regardless of what the `AttributeOrder` actually was...**

Let's first see crater results before making a decision

TODO for this PR: Make better tests for this
2026-04-17 13:28:55 +02:00
bors 4dbafc340b Auto merge of #153955 - aerooneqq:def-path-hash-collision, r=petrochenkov
delegation: fix def path hash collision, add per parent disambiguators



This PR addresses the following delegation issues:
- It fixes rust-lang/rust#153410 when generating new `DefId`s for generic parameters by ~saving `DisambiguatorState`s from resolve stage and using them at AST -> HIR lowering~ introducing per owner disambiguators and transferring them to AST -> HIR lowering stage
- ~Next it fixes the ICE which is connected to using `DUMMY_SP` in delegation code, which was found during previous fix~
- ~Finally, after those fixes the rust-lang/rust#143498 is also fixed, only bugs with propagating synthetic generic params are left.~

Fixes rust-lang/rust#153410. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-04-17 11:13:11 +00:00
Jonathan Brouwer 6f968782fd Add regression tests 2026-04-17 12:37:58 +02:00
aerooneqq 699eb29443 Fix delegation def path hash collision, add per-parent disambiguators 2026-04-17 09:46:54 +03:00
Stuart Cook 350e0d7fad Rollup merge of #155095 - lms0806:issue_155030, r=nnethercote
changed the information provided by (mut x) to mut x (Fix 155030)

When trying to change a value without using mut in a for loop, the recommendation for this change is incorrect, so I am correcting it.

resolve: rust-lang/rust#155030
2026-04-17 16:17:54 +10:00
Stuart Cook 1ff95e018f Rollup merge of #141633 - xizheyin:issue-141350, r=nnethercote
Suggest to bind `self.x` to `x` when field `x` may be in format string

Fixes rust-lang/rust#141350

I added the new test in the first commit, and committed the changes in the second one.

r? @fmease
cc @mejrs
2026-04-17 16:17:49 +10:00
bors 7af3402cda Auto merge of #155380 - jhpratt:rollup-j1e7DVL, r=jhpratt
Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#154451 (Require that a `<_ as Try>::Residual` implement the `Residual` trait)
 - rust-lang/rust#154595 (Emit fatal on invalid const args with nested defs)
 - rust-lang/rust#154599 (report the `varargs_without_pattern` lint in deps)
 - rust-lang/rust#154699 (`core::unicode`: Replace `Cased` table with `Lt`)
 - rust-lang/rust#155353 (resolve: Remove `inaccessible_ctor_reexport` resolver field)
 - rust-lang/rust#155357 (Add `--remap-path-scope` as unstable in rustdoc)
 - rust-lang/rust#150649 (clippy fix: non_canonical_clone_impl)
 - rust-lang/rust#154604 (abort in core)
 - rust-lang/rust#154616 (Add `--quiet` flag to x.py and bootstrap to suppress output)
 - rust-lang/rust#155215 (Clean up `AttributeLintKind` and refactor diagnostic attribute linting)
 - rust-lang/rust#155228 (Check diagnostic output in incremental `cpass` and `rpass` revisions)
 - rust-lang/rust#155266 (Adjust release notes for post-merge feedback)
 - rust-lang/rust#155326 (Disallow ZST allocations with `TypedArena`.)
 - rust-lang/rust#155334 (docs: Use `0b1` instead of `NonZero::MIN` in `NonZero::bit_width` doctests)
 - rust-lang/rust#155340 (Handle nonnull pattern types in size skeleton)
 - rust-lang/rust#155347 (Add push_mut and new Layout methods to release notes)
 - rust-lang/rust#155356 (remove calls to AliasTyKind::def_id)
 - rust-lang/rust#155364 (Reduce diagnostic type visibilities.)
2026-04-16 18:19:58 +00:00
bors 18b439f84e Auto merge of #154605 - estebank:attr-suggest, r=jieyouxu
Make `span_suggestions` always verbose



`span_suggestions` is to provide mutually exclusive suggestions. When it was introduced, we made its behavior be that if a single suggestion is given to it, we present the suggestion inline, otherwise in patch format. Changing this to make all of its uses be verbose, as that is closer in intent of output.
2026-04-16 11:23:18 +00:00
Jacob Pratt a5f590a1d6 Rollup merge of #155340 - oli-obk:size-skeleton-pat-tys, r=mati865
Handle nonnull pattern types in size skeleton

The original comment was correct, the size is always the same, but we have more information now. In theory there was an additional bug that would have allowed transmuting things of different sizes, but I don't see how that would have been actually doable as the `tail` types would always have differed.

fixes rust-lang/rust#155330
2026-04-16 01:54:13 -04:00
Jacob Pratt 0d98e0d54f Rollup merge of #155215 - mejrs:condense_diag_lints, r=JonathanBrouwer
Clean up `AttributeLintKind` and refactor diagnostic attribute linting

There was a fair amount of duplication here, and thanks to the proliferation of new diagnostic attributes these days, it was threatening to grow bigger.
2026-04-16 01:54:10 -04:00
Jacob Pratt 0238243b5f Rollup merge of #154599 - folkertdev:varargs-without-pattern-in-deps, r=mati865
report the `varargs_without_pattern` lint in deps

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

After discussion in https://github.com/rust-lang/reference/pull/2177#discussion_r2864885208.

Based on https://github.com/rust-lang/rust/pull/143619#issuecomment-3133157725 there was only one actual impacted crate https://crates.io/crates/binrw. The issue was fixed in https://github.com/jam1garner/binrw/issues/342, and has since been released https://github.com/jam1garner/binrw/issues/342#issuecomment-3994700268.

Hence we may as well report this loudly.

r? @ghost
2026-04-16 01:54:05 -04:00
Jacob Pratt 402748551a Rollup merge of #154595 - mu001999-contrib:fix/154539, r=BoxyUwU
Emit fatal on invalid const args with nested defs

Fixed https://github.com/rust-lang/rust/issues/123629
Fixes https://github.com/rust-lang/rust/issues/154539

Invalid const args are rejected, so their surrounding HIR is not preserved. But nested defs inside them can still get created, leaving children lowered without a valid HIR parent and causing an ICE when later error handling walks HIR parents.

r? @BoxyUwU
2026-04-16 01:54:05 -04:00
Scott McMurray 3efcdbc43c Require that a <_ as Try>::Residual implement Residual
The `Residual` trait was even more experimental than `Try`, but now that RFC3721 is merged, I think it would make sense to require this.
2026-04-15 18:09:52 -07:00
teor dafb6bb801 Refactor FnDecl and FnSig flags into packed structs 2026-04-16 07:08:08 +10:00
ujjwalVishwakarma2006 bcf86daada Add issue links 2026-04-15 23:50:36 +05:30
ujjwalVishwakarma2006 8c78c33aba Move test files from issues/ to appropriate subdirectories 2026-04-15 23:46:29 +05:30
bors e8e4541ff1 Auto merge of #139087 - beetrees:impl-from-f16-for-f32, r=jackh726
Fallback `{float}` to `f32` when `f32: From<{float}>` and add `impl From<f16> for f32`



Currently, the following code compiles:
```rust
fn foo<T: Into<f32>>(_: T) {}

fn main() {
    foo(1.0);
}
```

This is because the only `From<{float}>` impl for `f32` is currently `From<f32>`. However, once `impl From<f16> for f32` is added this is no longer the case. This would cause the float literal to fallback to `f64`, subsequently causing a type error as `f32` does not implement `From<f64>`. While this kind of change to type inference isn't technically a breaking change according to Rust's breaking change policy, the previous attempt to add `impl From<f16> for f32` was removed rust-lang/rust#123830 due to the large number of crates affected (by my count, there were root regressions in 42 crates and 52 GitHub repos, not including duplicates). This PR solves this problem by using `f32` as the fallback type for `{float}` when there is a trait predicate of `f32: From<{float}>`. This allows adding `impl From<f16> for f32` without affecting the code that currently compiles (such as the example above; this PR shouldn't affect what is possible on stable).

This PR also allows adding a future-incompatibility warning for the fallback to `f32` (currently implemented in the third commit) if the lang team wants one (allowing the `f32` fallback to be removed in the future); alternatively this could be expanded in the future into something more general like @tgross35 suggested in https://github.com/rust-lang/rust/issues/123831#issuecomment-2064728053. I think it would be also possible to disallow the `f32` fallback in a future edition.

As expected, a crater check showed [no non-spurious regressions](https://github.com/rust-lang/rust/pull/139087#issuecomment-2764732580).

For reference, I've based the implementation loosely on the existing `calculate_diverging_fallback`. This first commit adds the `f32` fallback, the second adds `impl From<f16> for f32`, and the third adds a FCW lint for the `f32` fallback. I think this falls under the types team, so
r? types

Fixes: rust-lang/rust#123831
Tracking issue: rust-lang/rust#116909

@rustbot label +T-lang +T-types +T-libs-api +F-f16_and_f128

To decide on whether a future-incompatibility warning is desired or otherwise (see above):
@rustbot label +I-lang-nominated

cc https://github.com/rust-lang/rust/issues/154024 https://github.com/rust-lang/rust/issues/154005
2026-04-15 18:09:11 +00:00
mu001999 1fca34d15d Emit fatal on defaults for generic params in binders if with nested defs 2026-04-15 21:41:19 +08:00
Jonathan Brouwer 439410f68a Rollup merge of #155311 - cyrgani:expand-clean, r=Kivooeo,petrochenkov
various small `rustc_expand` cleanups

Each commit should be reviewable on its own.
2026-04-15 14:39:09 +02:00
Jonathan Brouwer 1de718c323 Rollup merge of #155286 - mejrs:confusables, r=JonathanBrouwer
attribute cleanup: rustc_confusables

r? @jdonszelmann
2026-04-15 14:39:07 +02:00
Oli Scherer 8d642647bd Handle non-null pattern types in size skeleton 2026-04-15 14:37:41 +02:00
Oli Scherer 82545d7d79 Add regression test 2026-04-15 14:24:11 +02:00
mejrs 1d6177020c Add test for coalescing of diagnostic attribute duplicates 2026-04-15 11:49:55 +02:00
nataliakokoromyti 7d680171f0 borrowck: suggest borrowing for destructuring moves from overloaded deref 2026-04-15 00:59:25 -07:00
bors 57cb10ae1e Auto merge of #155324 - jhpratt:rollup-BNB8Pcb, r=jhpratt
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#154882 (Gate tuple const params behind `min_adt_const_params` feature)
 - rust-lang/rust#155259 (explicit-tail-calls: disable two tests on LoongArch)
 - rust-lang/rust#155293 (fix arch names in cfg pretty printer)
 - rust-lang/rust#155314 (`BorrowedBuf`: Update outdated safety comments in `set_init` users.)
 - rust-lang/rust#153469 (docs: clarify path search behavior in std::process::Command::new)
 - rust-lang/rust#154765 (Clarify ascii whitespace exclusion of vertical tab in the doc)
 - rust-lang/rust#155172 (Some small nits for supertrait_item_shadowing, and additional testing)
 - rust-lang/rust#155279 (Test/lexer unicode pattern white space)
 - rust-lang/rust#155280 (Tests for precise-capture through RPIT and TAIT)
 - rust-lang/rust#155301 (Delete unused `rustc_trait_selection` errors.)
 - rust-lang/rust#155303 (remove ibraheemdev from review rotation)
 - rust-lang/rust#155304 (remove PointeeParser)
 - rust-lang/rust#155319 (Remove dead diagnostic structs.)
2026-04-15 05:15:32 +00:00
lms0806 96fb37ae60 add : new UI test 2026-04-15 13:23:23 +09:00
Jacob Pratt 900e3a7720 Rollup merge of #155280 - Zalathar:opaque-capture-bug, r=JonathanBrouwer
Tests for precise-capture through RPIT and TAIT

- Tests for https://github.com/rust-lang/rust/issues/155151.

These tests succeed under `-Znext-solver`, but incorrectly fail under the old trait solver.

---

The bug can be triggered via return-position `impl Trait` on stable, but requires some rather contrived code. When using type-alias `impl Trait`, it's easier to imagine the issue being triggered by real code.
2026-04-14 23:02:35 -04:00
Jacob Pratt 07f5dcaac7 Rollup merge of #155279 - Sandijigs:test/lexer-unicode-pattern-white-space, r=jdonszelmann
Test/lexer unicode pattern white space

This PR adds a test for the Rust lexer to verify it correctly accepts vertical tab (`\x0B`) as valid whitespace between tokens. Vertical tab is part of Unicode Pattern_White_Space, which the Rust language specification uses to define whitespace.

Related: Outreachy tracking [Pattern_White_Space](https://www.unicode.org/reports/tr31/#R3a)
2026-04-14 23:02:34 -04:00
Jacob Pratt 5cff48a164 Rollup merge of #155172 - jackh726:supertrait-shadowing-cleanup, r=lcnr
Some small nits for supertrait_item_shadowing, and additional testing

cc rust-lang/rust#89151

r? types
2026-04-14 23:02:33 -04:00
Jacob Pratt de84f87874 Rollup merge of #155259 - durin42:llvm-23-loongarch-tailcall, r=chenyukang
explicit-tail-calls: disable two tests on LoongArch

A [recent LLVM change](https://github.com/llvm/llvm-project/pull/191508) broke these on LLVM 23.

I suspect these will eventually be fixed, so maybe it'd be okay/better to just leave this pending so it applies to our CI without merging it? I'm open to opinions.
2026-04-14 23:02:30 -04:00
Jacob Pratt c6363238fa Rollup merge of #154882 - zedddie:gate-tuple-const-params, r=BoxyUwU
Gate tuple const params behind `min_adt_const_params` feature

r? BoxyUwU
2026-04-14 23:02:30 -04:00
bors bd1e7c7948 Auto merge of #153815 - GokhanKabar:fix-ice-enum-discr-generic-self, r=BoxyUwU
Fix ICE when Self is used in enum discriminant of a generic enum



Fixes rust-lang/rust#153756
Let discriminant AnonConst inherit parent generics via Node::Variant in generics_of, and emit a proper error instead of span_bug! for the TooGeneric case in wfcheck.
2026-04-15 01:58:56 +00:00
Esteban Küber b849e10d38 Make span_suggestions always verbose
`span_suggestions` is to provide mutually exclusive suggestions. When it was introduced, we made its behavior be that if a single suggestion is given to it, we present the suggestion inline, otherwise in patch format. Changing this to make all of its uses be verbose, as that is closer in intent of output.
2026-04-15 01:38:14 +00:00
mejrs 72db94ff17 Pass allowed options as parameter to diagnostic lints 2026-04-15 00:24:17 +02:00
mejrs 75273e21c9 Warn instead of error for some ructs_on_unimplemented errors 2026-04-14 23:37:13 +02:00
Folkert de Vries a7590138a7 thread through a HirId to emit lints in the right place
Previously the lint would be reported at the right span, but could not be `allow`ed or `expect`ed in that location, because the lint was actually emitted using `CRATE_HIR_ID`
2026-04-14 23:21:54 +02:00
Folkert de Vries dfb680751e mark From<f16> for f32 as an unstable instance 2026-04-14 18:51:24 +02:00