Commit graph

51840 commits

Author SHA1 Message Date
James Barford-Evans
1986be2bcd Moved struct Placeholder<T> 2025-12-09 13:40:18 +00:00
Stuart Cook
3c2a5dbace
Rollup merge of #149722 - dawidl022:contracts/fix/parsing-compound-statements, r=jieyouxu
contracts: fix lowering final declaration without trailing semicolon

Lowering for contract delcarations introduced in rust-lang/rust#144444 incorrectly handled the final declaration statement when it didn't end in a semicolon. This change fixes the issue.

See the included regression test for the minimal reproducible example.

Contracts tracking issue: https://github.com/rust-lang/rust/issues/128044
2025-12-08 11:46:25 +11:00
Stuart Cook
82af0eec44
Rollup merge of #149714 - reddevilmidzy:atd, r=fmease
Check associated type where-clauses for lifetimes

resolves: rust-lang/rust#148627
resolves: rust-lang/rust#149233
2025-12-08 11:46:25 +11:00
bors
ba2142a19c Auto merge of #149517 - WaffleLapkin:alphabet-blessing, r=jdonszelmann
Implement blessing for tidy alphabetical check

r? `@jdonszelmann`
2025-12-07 20:08:33 +00:00
bors
fa1f706fbd Auto merge of #149060 - jdonszelmann:duplicate-span-lowering, r=WaffleLapkin
early return on duplicate span lowerings

`@bors2` try
2025-12-07 16:56:12 +00:00
bors
aa30176300 Auto merge of #149729 - matthiaskrgr:rollup-25plwn0, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#147136 (Add warn-by-default lint for visibility on `const _` declarations)
 - rust-lang/rust#149498 (Tidying up `tests/ui/issues` tests [1/N])
 - rust-lang/rust#149721 (rustc book: fix `*-pc-windows-msvc` link label in sidebar)
 - rust-lang/rust#149724 (Fix off-by-one staging output when testing the library)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-07 10:32:34 +00:00
reddevilmidzy
d53f7676d1 Check associated type where-clauses for lifetimes 2025-12-07 18:40:03 +09:00
Dawid Lachowicz
d54fee82f4
contracts: fix lowering final declaration without trailing semicolon
Lowering for contract delcarations incorrectly handled the final
declaration statement when it didn't end in a semicolon. This
change fixes the issue.
2025-12-07 09:08:46 +00:00
Matthias Krüger
842f95de70
Rollup merge of #147136 - Jules-Bertholet:const-_-unused-vis, r=jdonszelmann
Add warn-by-default lint for visibility on `const _` declarations

Add a warn-by-default `unused_visibilities` lint for visibility qualifiers on `const _` declarations—e.g. `pub const _: () = ();`. Such qualifiers have no effect.

A [Sourcegraph search](https://sourcegraph.com/search?q=context:global+lang:Rust+pub%5Cs*%28%5C%28.*%5C%29%29%3F%5Cs*const%5Cs%2B_%5Cs*:&patternType=regexp&case=yes&sm=0) suggests that this pattern is relatively rare, and mostly found in tests (with only 3 exceptions). So perhaps this could become an FCW/hard error in the future.

`@rustbot` label T-lang A-lints A-visibility -T-clippy
2025-12-07 08:26:49 +01:00
bors
1c5a0cfc13 Auto merge of #149657 - Kobzol:revert-149147, r=chenyukang
Revert "Rollup merge of #149147 - chenyukang:yukang-fix-unused_assignments-macro-gen-147648, r=JonathanBrouwer"

This reverts commit 82a17b30d8, reversing
changes made to 5019bdaefe.

Reverts https://github.com/rust-lang/rust/pull/149147 due to a [perf regression](https://github.com/rust-lang/rust/pull/149147#issuecomment-3613098314).
2025-12-07 07:23:22 +00:00
bors
d427ddfe90 Auto merge of #149717 - matthiaskrgr:rollup-spntobh, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#149659 (Look for typos when reporting an unknown nightly feature)
 - rust-lang/rust#149699 (Implement `Vec::from_fn`)
 - rust-lang/rust#149700 (rustdoc: fix bugs with search aliases and merging)
 - rust-lang/rust#149713 (Update windows-gnullvm platform support doc)
 - rust-lang/rust#149716 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-06 21:42:15 +00:00
Jules Bertholet
43fa060c38
Expand lint note 2025-12-06 13:49:00 -05:00
Jules Bertholet
9e7200967e
Add note to lint message 2025-12-06 13:49:00 -05:00
Jules Bertholet
6b5da2f177
Don't warn when underscore is passed to macro 2025-12-06 13:49:00 -05:00
Jules Bertholet
4cc2f952e4
Elaborate lint explanation 2025-12-06 13:48:59 -05:00
Jules Bertholet
234df83fe3
Add warn-by-default lint for visibility on const _ declarations
Add a warn-by-default `unused_visibility` lint for visibility qualifiers
on `const _` declarations - e.g. `pub const _: () = ();`.
These have no effect.
2025-12-06 13:48:58 -05:00
Matthias Krüger
183283f60d
Rollup merge of #149659 - scrabsha:push-vtrtnooqlvvv, r=jdonszelmann
Look for typos when reporting an unknown nightly feature
2025-12-06 16:27:08 +01:00
bors
ba86c0460b Auto merge of #149704 - matthiaskrgr:rollup-u4zhw99, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#146826 (Implement `Allocator` for `&mut A` where `A: Allocator + ?Sized`)
 - rust-lang/rust#148487 (add Option::into_flat_iter)
 - rust-lang/rust#148814 (stabilize `array_windows`)
 - rust-lang/rust#149401 (Fix `name()` functions for local defs in rustc_public)
 - rust-lang/rust#149683 (Fix armv8r-none-eabihf tier)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-06 12:25:12 +00:00
Matthias Krüger
4c8c967225
Rollup merge of #149401 - celinval:smir-109-name, r=scottmcm
Fix `name()` functions for local defs in rustc_public

This change fixes the behavior of the `name()` function for `CrateDef` and `Instance` which should return absolute path of items. For local items, the crate name was missing.

This resolves: https://github.com/rust-lang/project-stable-mir/issues/109
2025-12-06 09:57:59 +01:00
Matthias Krüger
8a6f82efac
Rollup merge of #148814 - bend-n:stabilize_array_windows, r=scottmcm
stabilize `array_windows`

Tracking issue: rust-lang/rust#75027
Closes: rust-lang/rust#75027
FCP completed: https://github.com/rust-lang/rust/issues/75027#issuecomment-3477510526
2025-12-06 09:57:59 +01:00
bors
fbab541a7a Auto merge of #149701 - jhpratt:rollup-cnlzfbv, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#149563 (f*::min/max: fix comparing with libm and IEEE operations)
 - rust-lang/rust#149592 (`is_const_default_method` is completely handled by the `constness` query)
 - rust-lang/rust#149662 (Move attribute lints to `rustc_lint`)
 - rust-lang/rust#149684 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-06 06:03:46 +00:00
Jacob Pratt
28435f8885
Rollup merge of #149662 - JonathanBrouwer:lint-rework, r=jdonszelmann
Move attribute lints to `rustc_lint`

This PR changes two things:
- This decouples the `AttributeLintKind` from the `Lint` it is emitted in. `cx.emit_lint` now takes both as an argument, rather than inferring the `Lint` from the `AttributeLintKind`. This is nice because:
  - It allows us to remove `AttributeLintKind::InvalidMacroExportArguments`
  - It allows us to move the choice between `USELESS_DEPRECATED` and `UNUSED_ATTRIBUTES` out of the lint emitting code
  - It allows the next change:
- This moves `AttributeLintKind` to `rustc_lint_defs`, and the decorating code to `rustc_lint`. This is nice because:
  - It allows attribute lint decorating code to access the TypeCtxt, which unblocks https://github.com/rust-lang/rust/pull/149215
  - It might allow most early buffered attribute lints to become dyn lint diagnostics in the future, as in https://github.com/rust-lang/rust/pull/147634
  - It deduplicates `IllFormedAttributeInput`

This PR does not change observable output of the compiler, as can be seen by no uitests being affected.

r? `@jdonszelmann`
2025-12-05 23:26:38 -05:00
Jacob Pratt
e5f552a02b
Rollup merge of #149592 - oli-obk:no_is_const_default_method_fn, r=fee1-dead
`is_const_default_method` is completely handled by the `constness` query

After  rust-lang/rust#149444 this function became obsolete

r? `@fee1-dead`
2025-12-05 23:26:37 -05:00
bors
b4f1098e10 Auto merge of #148823 - lcnr:generalize-no-subtyping, r=BoxyUwU
TypeRelating emit WellFormed, not generalize

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/250

r? BoxyUwU
2025-12-06 02:53:23 +00:00
bors
36b2369c91 Auto merge of #141980 - beetrees:va-list-proposal, r=workingjubilee
`c_variadic`: make `VaList` abi-compatible with C

tracking issue: https://github.com/rust-lang/rust/issues/44930
related PR: rust-lang/rust#144529

On some platforms, the C `va_list` type is actually a single-element array of a struct (on other platforms it is just a pointer). In C, arrays passed as function arguments expirience array-to-pointer decay, which means that C will pass a pointer to the array in the caller instead of the array itself, and modifications to the array in the callee will be visible to the caller (this does not match Rust by-value semantics). However, for `va_list`, the C standard explicitly states that it is undefined behaviour to use a `va_list` after it has been passed by value to a function (in Rust parlance, the `va_list` is moved, not copied). This matches Rust's pass-by-value semantics, meaning that when the C `va_list` type is a single-element array of a struct, the ABI will match C as long as the Rust type is always be passed indirectly.

In the old implementation, this ABI was achieved by having two separate types: `VaList` was the type that needed to be used when passing a `VaList` as a function parameter, whereas `VaListImpl` was the actual `va_list` type that was correct everywhere else. This however is quite confusing, as there are lots of footguns: it is easy to cause bugs by mixing them up (e.g. the C function `void foo(va_list va)` was equivalent to the Rust `fn foo(va: VaList)` whereas the C function `void bar(va_list* va)` was equivalent to the Rust `fn foo(va: *mut VaListImpl)`, not `fn foo(va: *mut VaList)` as might be expected); also converting from `VaListImpl` to `VaList` with `as_va_list()` had platform specific behaviour: on single-element array of a struct platforms it would return a `VaList` referencing the original `VaListImpl`, whereas on other platforms it would return a cioy,

In this PR, there is now just a single `VaList` type (renamed from `VaListImpl`) which represents the C `va_list` type and will just work in all positions. Instead of having a separate type just to make the ABI work, rust-lang/rust#144529 adds a `#[rustc_pass_indirectly_in_non_rustic_abis]` attribute, which when applied to a struct will force the struct to be passed indirectly by non-Rustic calling conventions. This PR then implements the `VaList` rework, making use of the new attribute on all platforms where the C `va_list` type is a single-element array of a struct.

Cleanup of the `VaList` API and implementation is also included in this PR: since it was decided it was OK to experiment with Rust requiring that not calling `va_end` is not undefined behaviour (https://github.com/rust-lang/rust/issues/141524#issuecomment-3028383594), I've removed the `with_copy` method as it was redundant to the `Clone` impl (the `Drop` impl of `VaList` is a no-op as `va_end` is a no-op on all known platforms).

Previous discussion: rust-lang/rust#141524 and [t-compiler > c_variadic API and ABI](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/c_variadic.20API.20and.20ABI)
Tracking issue: https://github.com/rust-lang/rust/issues/44930
r? `@joshtriplett`
2025-12-05 23:36:55 +00:00
Sasha Pourcelot
a57470ff72 Look for typos when reporting an unknown nightly feature 2025-12-05 20:06:10 +00:00
Matthias Krüger
a43b30c113
Rollup merge of #149671 - RalfJung:interpret-float-min-max, r=mati865
interpret: test SNaN handling of float min/max and update comments

Also see https://github.com/rust-lang/rust/pull/149563.

I also renamed these enum variants so they are not almost identical.
2025-12-05 16:17:13 +01:00
Matthias Krüger
8e46521d0e
Rollup merge of #149666 - Zalathar:backend-has-zstd, r=jieyouxu
Add perma-unstable `--print=backend-has-zstd` for use by compiletest

Tests for `-Zdebuginfo-compression=zstd` need to be skipped if LLVM was built without support for zstd compression.

Currently, compiletest relies on messy and fragile heuristics to detect whether the compiler's LLVM was built with zstd support. But the compiler itself already knows whether LLVM has zstd or not, so it's easier for compiletest to just ask the compiler.

---

Originally I was intending for this to be a `--print=debuginfo-compression` flag that would print out a list of values supported by `-Zdebuginfo-compression=`. I got that working locally, but it was more complex than I was happy with (in both rustc and compiletest), so I decided to cut scope and instead add a very narrow perma-unstable print request instead.

There is always a circularity hazard whenever we ask the compiler-under-test for information about how to test it. But in this case, the underlying compiler code is fairly simple, whereas the previous heuristics were inherently messy and unreliable anyway.
2025-12-05 16:17:12 +01:00
Matthias Krüger
93249823c2
Rollup merge of #149661 - alinas:llvm-22-runtimelibraryinfo-fix, r=cuviper
Fix for LLVM22 making lowering decisions dependent on RuntimeLibraryInfo.

LLVM added codegen decision making based on RuntimeLibraryInfo. Mirror the change in Rust's codegen.

LLVM reference commit:
04c81a9973.
2025-12-05 16:17:11 +01:00
Matthias Krüger
0c05bb5606
Rollup merge of #149630 - wafarm:fix-149604, r=JonathanBrouwer
Check identifiers defined in macros when suggesting identifiers hidden by hygiene

Fix rust-lang/rust#149604

r? `@JonathanBrouwer` (Since you reviewed the other one related to this)
2025-12-05 16:17:10 +01:00
Matthias Krüger
c42ce16c7b
Rollup merge of #149548 - aerooneqq:ice-issue-144594, r=petrochenkov
Generate delegation error body when delegation is not resolved

This PR relates to the delegation feature rust-lang/rust#118212, it fixes rust-lang/rust#144594 ICE.
r? `@petrochenkov`
2025-12-05 16:17:10 +01:00
Matthias Krüger
7850fc4b13
Rollup merge of #149101 - reddevilmidzy:mutable, r=eholk
Improve mutable-binding suggestion to include name

resolve: rust-lang/rust#148467
2025-12-05 16:17:07 +01:00
Jonathan Brouwer
8f59eb0177
Move attribute lints to rustc_lint 2025-12-05 14:22:52 +01:00
aerooneqq
3e717121a1 Generate error delegation body when delegation is not resolved 2025-12-05 15:22:26 +03:00
bors
97b131c900 Auto merge of #148602 - BoxyUwU:coercion_cleanup_uncontroversial, r=lcnr
misc coercion cleanups and handle safety correctly

r? lcnr

### "remove normalize call"

Fixes rust-lang/rust#132765

If the normalization fails we would sometimes get a `TypeError` containing inference variables created inside of the probe used by coercion. These would then get leaked out causing ICEs in diagnostics logic

### "leak check and lub for closure<->closure coerce-lubs of same defids"

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/233
```rust
fn peculiar() -> impl Fn(u8) -> u8 {
    return |x| x + 1
}
```
the `|x| x + 1` expr has a type of `Closure(?31t)` which we wind up inferring the RPIT to. The `CoerceMany` `ret_coercion` for the whole `peculiar` typeck has an expected type of `RPIT` (unnormalized). When we type check the `return |x| x + 1` expr we go from the never type to `Closure(?31t)` which then participates in the `ret_coercion` giving us a `coerce-lub(RPIT, Closure(?31t))`.

Normalizing `RPIT` gives us some `Closure(?50t)` where `?31t` and `?50t` have been unified with `?31t` as the root var. `resolve_vars_if_possible` doesn't resolve infer vars to their roots so these wind up with different structural identities so the fast path doesn't apply and we fall back to coercing to a `fn` ptr. cc rust-lang/rust#147193 which also fixes this

New solver probably just gets more inference variables here because canonicalization + generally different approach to normalization of opaques. Idk :3

### FCP worthy stuffy

there are some other FCP worthy things but they're in my FCP comment which also contains some analysis of the breaking nature of the previously listed changes in this PR: https://github.com/rust-lang/rust/pull/148602#issuecomment-3503497467
2025-12-05 11:46:41 +00:00
Ralf Jung
f040a1a915 interpret: test SNaN handling of float min/max and update comments 2025-12-05 08:53:42 +01:00
Zalathar
84ff44c749 Add perma-unstable --print=backend-has-zstd for use by compiletest
Tests for `-Zdebuginfo-compression=zstd` need to be skipped if LLVM was built
without support for zstd compression.

Currently, compiletest relies on messy and fragile heuristics to detect whether
the compiler's LLVM was built with zstd support. But the compiler itself
already knows whether LLVM has zstd or not, so it's easier for compiletest to
just ask the compiler.
2025-12-05 14:27:52 +11:00
bors
3e2dbcdd3a Auto merge of #149646 - matthiaskrgr:rollup-jbfeow8, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#147224 (Emscripten: Turn wasm-eh on by default)
 - rust-lang/rust#149405 (Recover on misspelled item keyword)
 - rust-lang/rust#149443 (Tidying up UI tests [6/N])
 - rust-lang/rust#149524 (Move attribute safety checking to attribute parsing)
 - rust-lang/rust#149593 (powf, powi: point out SNaN non-determinism)
 - rust-lang/rust#149605 (Use branch name instead of HEAD when unshallowing)
 - rust-lang/rust#149612 (Apply the `bors` environment also to the `outcome` job)
 - rust-lang/rust#149623 (Don't require a normal tool build of clippy/rustfmt when running their test steps)
 - rust-lang/rust#149627 (Point to the item that is incorrectly annotated with `#[diagnostic::on_const]`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-04 22:04:03 +00:00
Alina Sbirlea
ad73972e99 Fix for LLVM22 making lowering decisions dependent on RuntimeLibraryInfo.
LLVM reference commit:
04c81a9973.
2025-12-04 20:23:00 +00:00
Jakub Beránek
74387157c7
Revert "Rollup merge of #149147 - chenyukang:yukang-fix-unused_assignments-macro-gen-147648, r=JonathanBrouwer"
This reverts commit 82a17b30d8, reversing
changes made to 5019bdaefe.
2025-12-04 21:17:40 +01:00
bors
b33119ffdd Auto merge of #149642 - GuillaumeGomez:subtree-update_cg_gcc_2025-12-04, r=GuillaumeGomez
cg_gcc subtree update

cc `@antoyo`

r? ghost
2025-12-04 17:48:32 +00:00
Matthias Krüger
69f8a5ca67
Rollup merge of #149627 - lapla-cogito:diag_onconst, r=jdonszelmann
Point to the item that is incorrectly annotated with `#[diagnostic::on_const]`

close rust-lang/rust#149606

r? estebank
2025-12-04 16:07:57 +01:00
Matthias Krüger
0c95abb979
Rollup merge of #149524 - JonathanBrouwer:move_attr_safety, r=jdonszelmann
Move attribute safety checking to attribute parsing

This PR moves attribute safety checking to be done during attribute parsing. The `cfg` and `cfg_attr` attribute no longer need special-cased safety checking, yay!

This PR is a part 1 of 2, in the second part I'd like to define attribute safety in the attribute parsers rather than getting the information from BUILTIN_ATTRIBUTE_MAP, but to keep PRs reviewable lets do that separately.

Fixes https://github.com/rust-lang/rust/issues/148453 by reordering the diagnostics. The "cannot find attribute" diagnostic now appears first, but both diagnostics still appear.

r? `@jdonszelmann`
2025-12-04 16:07:53 +01:00
Matthias Krüger
55fa9f74db
Rollup merge of #149405 - scrabsha:push-tzonpluy, r=jdonszelmann
Recover on misspelled item keyword

the title says everything. first commit adds a test that shows how current `main` behaves on misspelled item keyword. second commit adds the recovery, which allows to emit many more errors.
2025-12-04 16:07:52 +01:00
Matthias Krüger
c80ac0f21a
Rollup merge of #147224 - hoodmane:wasm-eh-default-on, r=bjorn3
Emscripten: Turn wasm-eh on by default

As specified by [MCP](https://github.com/rust-lang/compiler-team/issues/920)
Resolves https://github.com/rust-lang/rust/issues/148309
Resolves https://github.com/rust-lang/rust/issues/112195
2025-12-04 16:07:51 +01:00
lcnr
e1be0d2e2a MIR typeck: invariant ctxt fast path
This removes variance information from some diagnostics. However,
that variance information is not actually relevant here. Casting
`*const dyn Cat<'a>` to `*const S<dyn Cat<'static>>` is an error
regardless of whether `S` requires its argument to be invariant.
Wide-pointer casts always require the trait object arguments to be
invariant.
2025-12-04 15:43:05 +01:00
lcnr
1b71459736 emit WF goals in relate, not in generalize 2025-12-04 15:43:05 +01:00
bors
29e035e172 Auto merge of #149632 - matthiaskrgr:rollup-c5iqgtn, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#149521 (Improve `io::Error::downcast`)
 - rust-lang/rust#149544 (Only apply `no_mangle_const_items`'s suggestion to plain const items)
 - rust-lang/rust#149545 (fix the check for which expressions read never type)
 - rust-lang/rust#149570 (rename cortex-ar references to unified aarch32)
 - rust-lang/rust#149574 (Batched compiletest Config fixups)
 - rust-lang/rust#149579 (Motor OS: fix compile error)
 - rust-lang/rust#149595 (Tidying up `tests/ui/issues` tests [2/N])
 - rust-lang/rust#149597 (Revert "implement and test `Iterator::{exactly_one, collect_array}`")
 - rust-lang/rust#149608 (Allow PowerPC spe_acc as clobber-only register)
 - rust-lang/rust#149610 (Implement benchmarks for uN::{gather,scatter}_bits)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-04 14:38:19 +00:00
Guillaume Gomez
94f1bfe1fc Merge commit 'dab6863ce8' into subtree-update_cg_gcc_2025-12-04 2025-12-04 14:53:08 +01:00
beetrees
f7b3c1d3c0
Rework c_variadic 2025-12-04 10:51:34 +01:00