Commit graph

3164 commits

Author SHA1 Message Date
mu001999
d572e6d415 Add span field for ConstArg 2026-01-07 08:44:32 +08:00
Jonathan Brouwer
6268b9118e
Rollup merge of #149991 - Flakebi:gpu-kernel-cc, r=workingjubilee
Add checks for gpu-kernel calling conv

The `gpu-kernel` calling convention has several restrictions that were not enforced by the compiler until now.
Add the following restrictions:

1. Cannot be async
2. Cannot be called
3. Cannot return values, return type must be `()` or `!`
4. Arguments should be simple, i.e. passed by value. More complicated types can work when you know what you are doing, but it is rather unintuitive, one needs to know ABI/compiler internals.
5. Export name should be unmangled, either through `no_mangle` or `export_name`. Kernels are searched by name on the CPU side, having a mangled name makes it hard to find and probably almost always unintentional.

Tracking issue: rust-lang/rust#135467
amdgpu target tracking issue: rust-lang/rust#135024

``@workingjubilee,`` these should be all the restrictions we talked about a year ago.

cc ``@RDambrosio016`` ``@kjetilkjeka`` for nvptx
2026-01-02 23:13:21 +01:00
Flakebi
33add367e2
Add checks for gpu-kernel calling conv
The `gpu-kernel` calling convention has several restrictions that were
not enforced by the compiler until now.
Add the following restrictions:

1. Cannot be async
2. Cannot be called
3. Cannot return values, return type must be `()` or `!`
4. Arguments should be primitives, i.e. passed by value. More complicated
   types can work when you know what you are doing, but it is rather
   unintuitive, one needs to know ABI/compiler internals.
5. Export name should be unmangled, either through `no_mangle` or
   `export_name`. Kernels are searched by name on the CPU side, having
   a mangled name makes it hard to find and probably almost always
   unintentional.
2026-01-01 18:34:24 +01:00
Jonathan Brouwer
a65fa4a357
Rollup merge of #150166 - Urgau:const-item-lint-150157, r=Kivooeo
Don't lint on interior mutable `const` item coming from derefs

This PR fixes the `const_item_interior_mutations` lint so we don't lint on interior mutable `const` item coming from derefs.

Fixes https://github.com/rust-lang/rust/issues/150157
2025-12-22 20:11:54 +01:00
Boxy Uwu
2ffb1d55ef Handle bootstrap cfgs 2025-12-19 15:04:30 -08:00
Urgau
2581c2571c Don't lint on interior mutable const item coming from derefs 2025-12-19 23:35:13 +01:00
Edvin Bryntesson
44cfed7465
Port #[rustc_lint_diagnostics] to attribute parser 2025-12-18 23:36:26 +01:00
Edvin Bryntesson
5277241d27
Port #[rustc_lint_untracked_query_information] to attribute parser 2025-12-18 23:33:25 +01:00
Edvin Bryntesson
fe34b17c2a
Port #[rustc_lint_opt_deny_field_access] to attribute parser 2025-12-18 12:19:07 +01:00
Edvin Bryntesson
96e453d713
Port #[rustc_lint_query_instability] to parsed attribute 2025-12-17 18:28:37 +01:00
Edvin Bryntesson
81d20363b3
Port #[rustc_lint_opt_ty] to parsed attribute 2025-12-17 18:23:49 +01:00
Edvin Bryntesson
bbda675aac
Port #[rustc_no_implicit_autorefs] to attribute parser 2025-12-17 18:22:19 +01:00
Edvin Bryntesson
5692064521
Port #[rustc_never_returns_null_ptr] to attribute parser 2025-12-17 12:35:32 +01:00
Jubilee Young
0004d8d421 Remove deny of manual-let-else 2025-12-16 08:42:04 -08:00
Matthias Krüger
d7a18fc052
Rollup merge of #148490 - hkBst:dangling-ptr-lint-2, r=Urgau
dangling pointer from temp cleanup

Continuation of https://github.com/rust-lang/rust/pull/148348
r? `@Urgau`
2025-12-14 20:04:54 +01:00
Marijn Schouten
cab911449a dangling pointer from temp cleanup 2025-12-14 11:39:43 +00:00
Esteban Küber
a49c175380 #![deny(clippy::manual_let_else)] in some rustc modules 2025-12-12 17:53:19 +00:00
Esteban Küber
146711fc24 Use let...else instead of match foo { ... _ => return }; and if let ... else return 2025-12-12 17:52:39 +00:00
Matthias Krüger
d952bac929
Rollup merge of #149792 - clubby789:cfg-FALSE, r=jdonszelmann
Suggest `cfg(false)` instead of `cfg(FALSE)`

Split from rust-lang/rust#149791

cc ```````@Urgau```````
2025-12-12 12:19:10 +01:00
bors
5b150d238f Auto merge of #149645 - GuillaumeGomez:doc-attr-based, r=jdonszelmann,jonathanbrouwer
Port `doc` attributes to new attribute API

Part of https://github.com/rust-lang/rust/issues/131229.

This PR ports the `doc` attributes to the new attribute API. However, there are things that will need to be fixed in a follow-up:

* Some part of `cfg_old.rs` are likely unused now, so they should be removed.
* Not all error/lints are emitted at the same time anymore, making them kinda less useful considering that you need to run and fix rustc/rustdoc multiple times to get through all of them.
* For coherency with the other attribute errors, I didn't modify the default output too much, meaning that we have some new messages now. I'll likely come back to that to check if the previous ones were better in a case-by-case approach.
* `doc(test(attr(...)))` is handled in a horrifying manner currently. Until we can handle it correctly with the `Attribute` system, it'll remain that thing we're all very ashamed of. 😈
* A type in rustdoc got its size increased, I'll check the impact on performance. But in any case, I plan to improve it in a follow-up so should be "ok".
* Because of error reporting, some fields of `Doc` are suboptimal, like `inline` which instead of being an `Option` is a `ThinVec` because we report the error later on. Part of the things I'm not super happy about but can be postponed to future me.
* In `src/librustdoc/clean/cfg.rs`, the `pub(crate) fn parse(cfg: &MetaItemInner) -> Result<Cfg, InvalidCfgError> {` function should be removed once `cfg_trace` has been ported to new `cfg` API.
* Size of type `DocFragment` went from 32 to 48. Would be nice to get it back to 32.
* ``malformed `doc` attribute input`` wasn't meant for so many candidates, should be improved.
* See how many of the checks in `check_attr` we can move to attribute parsing
* Port target checking to be in the attribute parser completely
* Fix target checking for `doc(alias)` on fields & patterns

And finally, once this PR is merged, I plan to finally stabilize `doc_cfg` feature. :)

cc `@jdonszelmann`
r? `@JonathanBrouwer`
2025-12-11 21:08:19 +00:00
Jamie Hill-Daniel
0349359792 Suggest cfg(false) instead of cfg(FALSE) 2025-12-11 18:23:04 +00:00
Matthias Krüger
eab103688f
Rollup merge of #149846 - jdonszelmann:links-for-all-fcws, r=wafflelapkin
Statically require links to an issue or the edition guide for all FCWs

r? `@wafflelapkin`
2025-12-10 17:16:50 +01:00
Jana Dönszelmann
0eed5ab550
introduce fcw macro 2025-12-10 15:15:54 +01:00
Guillaume Gomez
2340f8054c Update to new lint API 2025-12-10 12:28:07 +01:00
Guillaume Gomez
4936973d49 Fix ui tests 2025-12-10 12:28:05 +01:00
Guillaume Gomez
acb32df7b1 Continue migration to new Attribute API for doc attribute 2025-12-10 12:27:33 +01:00
Jana Dönszelmann
3f08e4dcd9 start using parsed doc attributes everywhere 2025-12-10 12:27:33 +01:00
mu001999
50e9839d48 Don't suggest wrapping attr in unsafe if it may come from proc macro 2025-12-09 22:54:37 +08:00
Matthias Krüger
add772d3c4
Rollup merge of #149730 - SATVIKsynopsis:main, r=Kivooeo
lint: emit proper diagnostic for unsafe binders in improper_ctypes instead of ICE

Fixes rust-lang/rust#149719

This PR replaces the `todo!("FIXME(unsafe_binder)")` branch in the `improper_ctypes` lint with a proper diagnostic.

Previously, using an unsafe binder inside an extern `"C"` block caused an internal compiler error.
This fix now ensures that the compiler now emits a clear and stable error message explaining that types containing unsafe binders are not yet supported in FFI.

A new UI test `(unsafe-binder-basic.rs)` is included to ensure this behavior remains stable and prevent regressions.
2025-12-09 06:17:24 +01:00
Matthias Krüger
ece99775da
Rollup merge of #149215 - JonathanBrouwer:cfg_lints2, r=jdonszelmann
Emit `check-cfg` lints during attribute parsing rather than evaluation

The goal of this PR is to make the `eval_config_entry` not have any side effects, by moving the check-cfg lints to the attribute parsing. This also helps ensure we do emit the lint in situations where the attribute happens to be parsed, but never evaluated.

cc ``@jdonszelmann`` ``@Urgau`` for a vibe check if you feel like it
2025-12-09 06:17:22 +01:00
SATVIKsynopsis
0f4ec28155 lint: treat unsafe binders in improper_ctypes instead of ICE
Replaced _binder with _
2025-12-08 18:51:59 +05:30
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
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
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
Jonathan Brouwer
71b093fd2c
Emit check-cfg lints during attribute parsing rather than evaluation#149215 2025-12-06 10:22:13 +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
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
Jonathan Brouwer
8f59eb0177
Move attribute lints to rustc_lint 2025-12-05 14:22:52 +01: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
lcnr
1b71459736 emit WF goals in relate, not in generalize 2025-12-04 15:43:05 +01:00
Matthias Krüger
5c9a4eed87
Rollup merge of #149544 - reddevilmidzy:where, r=fmease
Only apply `no_mangle_const_items`'s suggestion to plain const items

resolve: rust-lang/rust#149511
2025-12-04 09:22:11 +01:00
reddevilmidzy
2951d72219 Simplify and robustly compute suggestion span using
`vis_span.to(ident.span.shrink_to_lo())`
2025-12-04 11:01:40 +09:00
reddevilmidzy
6ce0f0ff91 Only apply no_mangle_const_items's suggestion to plain const items 2025-12-04 11:01:10 +09:00
Jonathan Brouwer
884fb5aef2
Move attribute safety checking to rustc_attr_parsing 2025-12-03 17:00:06 +01:00
bendn
919e46f4d4
stabilize [T]::array_windows 2025-12-02 00:37:17 +07:00
León Orell Valerian Liehr
109e5e5999
Move early buffered lint ambigous-glob-imports to a dyn lint diagnostic 2025-12-01 16:31:53 +01:00
León Orell Valerian Liehr
3ad6359f54
Move more early buffered lints to dyn lint diagnostics (6/N) 2025-11-30 17:59:42 +01:00
León Orell Valerian Liehr
74d12e8598
Move more early buffered lints to dyn lint diagnostics (5/N) 2025-11-30 17:54:38 +01:00