Commit Graph

3106 Commits

Author SHA1 Message Date
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
Matthias Krüger d67a12dfff Rollup merge of #148256 - lcnr:orphan-check, r=spastorino,WaffleLapkin
remove support for `typeof`

see https://github.com/rust-lang/compiler-team/issues/940 closes https://github.com/rust-lang/rust/issues/148700

This also enables checks for invariants previously broken by `typeof` again.

r? types
2025-11-27 15:59:11 +01:00
lcnr feb13036ef remove support for type-of 2025-11-25 10:19:44 +01:00
Ben Kimock 4752322343 Add a little cfg_attr(bootstrap) to make the doctest work on stage1 2025-11-24 21:50:02 -05:00
Ben Kimock bef49a02ef Don't lint on derefs of null pointers to ZSTs 2025-11-24 21:45:28 -05:00
Ben Kimock c0097978aa Make deref_nullptr deny by default instead of warn 2025-11-24 21:45:28 -05:00
Urgau dc2a61eccd Add const_item_interior_mutations lint 2025-11-22 14:48:40 +01:00
Matthias Krüger 2cc5bf7b6a Rollup merge of #147421 - Kivooeo:ice-fix51621, r=chenyukang
Add check if span is from macro expansion

The same thing I did in https://github.com/rust-lang/rust/pull/147416, actually the same bug but in another place, I'm not really sure how this method is good for fixing such ICEs, but, it does work and not conflicting with any existing tests, so I guess, it's fine

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

r? compiler
2025-11-19 09:48:06 +01:00
Camille Gillot 72444372ae Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00