Commit graph

22384 commits

Author SHA1 Message Date
Jacob Pratt
47f1502c73
Rollup merge of #149860 - Delta17920:fix/149821-root-cause, r=petrochenkov
Fix: Prevent macro-expanded extern crates from shadowing extern arguments

prevents an ICE by fixing a logic bug in `build_reduced_graph.rs`.
the bug caused the compiler to correctly detect and report a shadowing error for a macro-expanded `extern crate` but then continue processing the invalid item, corrupting the resolver's internal state (`extern_prelude`) and leading to a crash in later resolution passes the fix adds an early return after the shadowing error is reported to ensure the invalid item is not added to the resolution graph.

Fixes rust-lang/rust#149821
2025-12-13 00:55:56 -05:00
Jacob Pratt
e7ba4a5e6d
Rollup merge of #149843 - aerooneqq:inherit-attributes-in-delegation, r=petrochenkov
Inherit attributes in delegation

This PR adds support for inheriting attributes of the original function of the delegation and is a part of rust-lang/rust#118212, for now we inherit only #[must_use] attribute, but we can add other attributes to inherit. The list of processed attributes can be found [here](https://github.com/aerooneqq/public-docs/blob/master/rust/delegation/processed_attributes.md).

r? ``@petrochenkov``
2025-12-13 00:55:56 -05:00
Jacob Pratt
d175f11e0e
Rollup merge of #149177 - chenyukang:yukang-fix-assoc-func-149038, r=estebank
Add proper suggestion for associated function with unknown field

Fixes rust-lang/rust#149038

The first commit is changing the old suggestion to verbose,
the second commit is a new added suggestion.

r? ``@estebank``
2025-12-13 00:55:55 -05:00
bors
dc47a69ed9 Auto merge of #149136 - BoxyUwU:mgca_explicit_anon_consts, r=oli-obk
MGCA: Syntactically distinguish anon const const args

r? oli-obk

tracking issue: rust-lang/rust#132980

This PR requires that when `feature(min_generic_const_args)` is enabled, anon const const args are *syntactically* distinguishable from other kinds of args. We use `const { ... }` in const argument position to denote an anon const:
```rust
#![feature(min_generic_const_args)]

// no longer allowed as `1 + 1` is represented via an anon const and
// there is no syntactic marker
type Foo = [(); 1 + 1];

// allowed, `const { ... }` indicates an anon const representation
type Foo = [(); const { 1 + 1 }];
```

This restriction is only placed when mgca is enabled. There should be no effect on stable. This restriction is not enforced for unbraced literals which we continue to implicitly wrap in an anon const: `tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs`

This restriction allows us to create `DefId`s for anon consts only when actually required. When it is syntactically ambiguous whether a const argument is an anon const or not we are forced to conservatively create a `DefId` for every const argument even if it doesn't wind up needing one.

This works fine on stable but under `mgca` we can wind up with anon consts nested inside non-anon-const const arguments resulting in a broken `DefId` tree. See rust-lang/rust#148838 where an anon const arg inside of a path arg winds up with a parent of a conservatively created `DefId` that doesn't actually correspond to an anon const, resulting in an ICE.

With rust-lang/rust#149114 every field initialiser in a const argument would become a place where there could *possibly* be an anon const. This would also get worse once we support tuple constructors- now every function argument is a place where there could possibly be an anon const.

We introduce this restriction to avoid creating massive amounts of unused `DefId`s that make the parent tree significantly more complicated, and to avoid having to paper over this issue in things like `generics_of`.

Fixes rust-lang/rust#148838

It also must be syntactically clear from context whether `'_` means an inference lifetime or an elided lifetime parameter. This restriction will allow us to properly resolve `'_` in const arguments in mgca. This PR doesn't actually fix handle this, but we could do so trivially after this lands.
2025-12-12 21:35:31 +00:00
bors
fa5eda19b9 Auto merge of #149917 - GuillaumeGomez:malformed-attribute-suggestions, r=JonathanBrouwer
If there are too many suggestions for malformed attribute, do not suggest them

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

This not only covers for doc attributes but for all attributes, so don't hesitate to tell me if you want it to be limited to only doc attributes (although I think it's actually a nice improvement overall).

Also, I picked 3 as the maximum number of suggestions before it becomes noise, but it's very much open to debate.

r? `@JonathanBrouwer`
2025-12-12 18:18:14 +00:00
aerooneqq
0a3fd24287 Support attribute inheritance in delegation 2025-12-12 20:34:54 +03:00
delta17920
0748492e2b Fix: Prevent macro-expanded extern crates from shadowing extern arguments 2025-12-12 16:22:25 +00:00
Boxy Uwu
acc3a0e2da Syntactically distinguish anon const const args 2025-12-12 15:45:37 +00:00
Guillaume Gomez
d025cdef7d If there are too many suggestions for malformed attribute, do not suggest them 2025-12-12 14:55:17 +01:00
bors
3391c01336 Auto merge of #149909 - matthiaskrgr:rollup-596c34w, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#149655 (bootstrap: add rustc-dev install target)
 - rust-lang/rust#149789 (Cleanup in the attribute parsers)
 - rust-lang/rust#149791 (Remove uses of `cfg({any()/all()})`)
 - rust-lang/rust#149792 (Suggest `cfg(false)` instead of `cfg(FALSE)`)
 - rust-lang/rust#149883 (add regression test for `proc_macro` error subdiagnostics)
 - rust-lang/rust#149884 (Clippy subtree update)
 - rust-lang/rust#149896 (Add myself(makai410) to the review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-12 13:00:47 +00:00
Matthias Krüger
1553fcc240
Rollup merge of #149883 - cyrgani:sub-err-diag, r=Kivooeo
add regression test for `proc_macro` error subdiagnostics

The previous ICE was already fixed by rust-lang/rust#148188, but no test was added at that time.
Closes rust-lang/rust#145305.
2025-12-12 12:19:10 +01: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
Matthias Krüger
b826d06771
Rollup merge of #149791 - clubby789:cfg-bool-lints, r=jdonszelmann
Remove uses of `cfg({any()/all()})`

~~This implements the followup warning suggested in https://github.com/rust-lang/rfcs/pull/3695~~
~~Lint against an empty `cfg(any/all)`, suggest the boolean literal equivalents.~~
https://github.com/rust-lang/rust/pull/149791#issuecomment-3638624348

Tracking issue: https://github.com/rust-lang/rust/issues/131204
2025-12-12 12:19:09 +01:00
bors
2a3a62d26e Auto merge of #148477 - lqd:crater-wfcheck, r=lcnr,BoxyUwU
don't normalize where-clauses when checking well-formedness

WfCheck checks where-clauses after normalization, and we'd like to see what would break if it didn't for https://github.com/rust-lang/trait-system-refactor-initiative/issues/255

r? ghost
2025-12-12 09:45:27 +00:00
bors
c4dc70ee0a Auto merge of #149891 - matthiaskrgr:rollup-jh6xrhz, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142380 (Put negative implementors first and apply same ordering logic to foreign implementors)
 - rust-lang/rust#146584 (remove duplicated columns from `rustc_error_code::error_codes!`)
 - rust-lang/rust#148717 (Point at span within local macros even when error happens in nested external macro)
 - rust-lang/rust#149565 (rustdoc: Add unstable `--merge-doctests=yes/no/auto` flag)
 - rust-lang/rust#149770 (Rename some issue-* tests)
 - rust-lang/rust#149807 (Use ubuntu:24.04 for the `x86_64-gnu-miri` job)
 - rust-lang/rust#149850 (Remove "tidy" tool for `tests/rustdoc` testsuite)
 - rust-lang/rust#149863 (Do not suggest moving expression out of for loop when hitting `break` from desugaring)
 - rust-lang/rust#149867 (only resolve main in bin crates)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-12 06:30:06 +00:00
Matthias Krüger
1c937f1e7f
Rollup merge of #149867 - 21aslade:lib-crate-main, r=Kivooeo
only resolve main in bin crates

Fixes rust-lang/rust#149412
2025-12-11 22:09:58 +01:00
Matthias Krüger
eb309e5182
Rollup merge of #149863 - estebank:issue-149861, r=mati865
Do not suggest moving expression out of for loop when hitting `break` from desugaring

Fix rust-lang/rust#149861.
2025-12-11 22:09:58 +01:00
Matthias Krüger
17940e27c8
Rollup merge of #149770 - GrigorenkoPV:tests/consts, r=WaffleLapkin
Rename some issue-* tests

Also fixes one incorrect issue number: https://github.com/rust-lang/rust/pull/100168#issuecomment-3622946835
2025-12-11 22:09:54 +01:00
Matthias Krüger
0dfc23839b
Rollup merge of #149565 - jyn514:force-doctest-merge, r=notriddle
rustdoc: Add unstable `--merge-doctests=yes/no/auto` flag

This is useful for changing the *default* for whether doctests are merged or not. Currently, that default is solely controlled by `edition = 2024`, which adds a high switching cost to get doctest merging. This flag allows opting in even on earlier editions.

Unlike the `edition = 2024` default, `--merge-doctests=yes` gives a hard error if merging fails instead of falling back to running standalone tests. The user has explicitly said they want merging, so we shouldn't silently do something else.

`--merge-doctests=auto` is equivalent to the current 2024 edition behavior, but available on earlier editions.

Helps with https://github.com/rust-lang/rust/issues/141240. ``@epage`` said in that issue he would like a per-doctest opt-in, and that seems useful to me in addition to this flag, but I think it's a separate use case from changing the default.
2025-12-11 22:09:54 +01:00
Matthias Krüger
215d7b661e
Rollup merge of #148717 - estebank:macro-spans-2, r=petrochenkov
Point at span within local macros even when error happens in nested external macro

Address issue noticed at https://users.rust-lang.org/t/error-message-does-not-specify-where-in-macro/135157/1. On errors occurring within a macro expansion, point at the innermost local macro expansion point.

```
error[E0308]: mismatched types
  --> $DIR/macro-span-caller-replacement.rs:5:17
   |
LL |             s = format!("{arg}");
   |                 ^^^^^^^^^^^^^^^^ expected `&str`, found `String`
...
LL |     macro_with_format!();
   |     -------------------- in this macro invocation
   |
   = note: this error originates in the macro `format` which comes from the expansion of the macro `macro_with_format` (in Nightly builds, run with -Z macro-backtrace for more info)
```
2025-12-11 22:09:53 +01:00
Matthias Krüger
52cadc06f1
Rollup merge of #142380 - GuillaumeGomez:neg-implementors, r=yotamofek
Put negative implementors first and apply same ordering logic to foreign implementors

Fixes rust-lang/rust#51129.

This PR changeda surprisingly small amount of things to put negative trait impls before the others: basically just adding a new information in the generated JS file for foreign implementors and a "negative marker" DOM element to know where to insert negative impls.

I also used this occasion to make the foreign implementors sort the same as the local ones by using `compare_names`.

You can test it [here](https://rustdoc.crud.net/imperio/neg-implementors/core/marker/trait.Sync.html#implementors).

r? ```@notriddle```
2025-12-11 22:09:51 +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
cyrgani
43fa2a95c9 add regression test for proc_macro error subdiagnostics 2025-12-11 18:15:15 +00:00
Esteban Küber
c60ed211d1 Do not suggest moving expression out of for loop when hitting break from desugaring 2025-12-11 15:00:48 +00:00
Jamie Hill-Daniel
c96ff2d429 Remove uses of cfg(any()/all()) 2025-12-10 23:41:19 +00:00
21aslade
c27bcef6f8 don't resolve main in lib crates 2025-12-10 14:17:47 -07:00
bors
f520900083 Auto merge of #149853 - matthiaskrgr:rollup-m2rkwqr, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#148052 (Stabilize `const_mul_add`)
 - rust-lang/rust#149386 (Display funding link in the github overview)
 - rust-lang/rust#149489 (Experimentally add *heterogeneous* `try` blocks)
 - rust-lang/rust#149764 (Make `--print=backend-has-zstd` work by default on any backend)
 - rust-lang/rust#149838 (Build auxiliary in pretty tests)
 - rust-lang/rust#149839 (Use `PointeeSized` bound for `TrivialClone` impls)
 - rust-lang/rust#149846 (Statically require links to an issue or the edition guide for all FCWs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-10 20:12:15 +00:00
Esteban Küber
1bd7934d89 Point at span within local macros even when error happens in nested external macro
```
error[E0308]: mismatched types
  --> $DIR/macro-span-caller-replacement.rs:5:17
   |
LL |             s = format!("{arg}");
   |                 ^^^^^^^^^^^^^^^^ expected `&str`, found `String`
...
LL |     macro_with_format!();
   |     -------------------- in this macro invocation
   |
   = note: this error originates in the macro `format` which comes from the expansion of the macro `macro_with_format` (in Nightly builds, run with -Z macro-backtrace for more info)
```
2025-12-10 19:27:40 +00:00
Esteban Küber
507b67f457 Add test for incorrect macro span replacement 2025-12-10 19:21:32 +00:00
Guillaume Gomez
2bc2a0db69 For now, ignore target checking for doc attributes in attr_parsing 2025-12-10 20:18:42 +01:00
Pavel Grigorenko
96a7000101 Rename some issue-* tests 2025-12-10 20:31:10 +03: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
Matthias Krüger
02a58a9bee
Rollup merge of #149489 - scottmcm:try-bikeshed, r=nnethercote
Experimentally add *heterogeneous* `try` blocks

rust-lang/rust#148725 moved the default to being homogeneous; this adds heterogeneous ones back under an obvious-bikeshed syntax so people can experiment with that as well.

Essentially resolves rust-lang/rust#149025 by letting them move to this syntax instead.

New tracking issue: rust-lang/rust#149488
Related RFC: https://github.com/rust-lang/rfcs/pull/3721#issuecomment-3208342727 (specifically about experimenting)
2025-12-10 17:16:47 +01:00
Guillaume Gomez
13091ddc93 Make implementors list visible only when filled 2025-12-10 16:18:22 +01:00
Guillaume Gomez
985178dacf Add GUI test to ensure that negative impls are correctly sorted 2025-12-10 16:18:22 +01:00
Rémy Rakic
99f7e785c5 mark crash test as requiring debug-assertions 2025-12-10 14:47:50 +00:00
Rémy Rakic
cdf43ad5ef add test from modcholesky breakage 2025-12-10 14:47:49 +00:00
Rémy Rakic
fa77598824 update tests and bless expectations
just to show the diagnostics impact
2025-12-10 14:47:49 +00:00
Jana Dönszelmann
1ef1ec13d8
bless the tests 2025-12-10 15:15:56 +01:00
bors
198328ad79 Auto merge of #136776 - BoxyUwU:forbid_object_lifetime_casts, r=lcnr
Forbid freely casting lifetime bounds of dyn-types

Fixes rust-lang/rust#136702

Reference PR:

- https://github.com/rust-lang/reference/pull/1951

Background reading about VTable calls/dyn compatibility: https://hackmd.io/zUp-sgZ0RFuFgsNfD4JqYw

This PR causes us to start enforcing that lifetimes of dyn types are constrained through pointer casts. Currently on stable casting `*mut dyn Trait + 'a` to `*mut dyn Trait + 'b` passes with no requirements on `'a` or `'b`. Under this PR we now require `'a` to outlive `'b`.

Even though the pointee of `*mut` pointers is considered to be invariant, we still use subtyping rather than equality. This mirrors how we support coercing `&mut dyn Trait + 'a` to `&mut dyn Trait + 'b` while requiring only `'a: 'b`. I believe this coercion is sound as there is no way for safe code to `mem::swap` two `dyn Trait`'s, and the same is definitely true of raw pointers.

See the changes to this test: https://github.com/rust-lang/rust/pull/136776/files#diff-5523f20a800287a89c9f3e92646c887f3f7599be006b29dd9315f734a2137764

We also do not enforce any constraints on the lifetime of the dyn types if there are multiple pointer indirections. For example `*mut *mut dyn Trait + 'a` is allowed to be casted to `*mut *mut dyn Trait + 'b` with no requirements on `'a` or 'b`. This case is just a normal thin pointer cast where we do not care about the pointee type as there is no VTable in play.

Test: https://github.com/rust-lang/rust/pull/136776/files#diff-3b6c8da342bb6530524158d686455a545bb8fd6f59cf5ff50d1d991ce74c9649

Finally, this is about *any* cast where the pointee is *unsized* with dyn-type metadata, not just *literally* the pointee type being a dyn-type. E.g. casting `*mut Wrapper<dyn Trait + 'a>` to `*mut Wrapper<dyn Trait + 'b>` requires `'a: 'b` under this PR.

Test: https://github.com/rust-lang/rust/pull/136776/files#diff-ca0c44df62ae1ad1be70f892f01a59714336c7baf78602a5887ac1cf81145c96

### Breakage

This is a breaking change.
Crater Report Comment: https://github.com/rust-lang/rust/pull/136776#issuecomment-3594165533
Generated Report: https://crater-reports.s3.amazonaws.com/pr-136776-2/index.html

The majority of the breakage is caused by the `metrics` crate with 142 of the regressions, and the `may` crate with 14 of the regressions. The `metrics` crate has been fixed and has backported the fix to previous versions of the crate that were also affected. The`may` crate has also been fixed.

PRs against affected crates have been opened and can be seen here:
- secona/belalang#6
- tyilo/multi-vec#1
- luksan/lox#1
- pfzetto/bring-your-own-memory-demo#1
- vitorhnn/bfr#1
- paperartifact/PPSMC#1
- orengine/orengine#33
- maroider/async_scoped_task#1
- WorldSEnder/scoped_worker_thread#1
- Wind-Corporation/trapiron#5
- Thombrom/snek#1
- Xudong-Huang/may#113
- metrics-rs/metrics#564
- DouglasDwyer/micropool#1
- Magicolo/phylactery#8
- HellButcher/pulz#29
- UxuginPython/rrtk#1
- wvwwvwwv/scalable-delayed-dealloc#4
- ultimaweapon/tsuki#32

There were six regressions I've not filed PRs against:
- https://github.com/weiznich/diesel_benches depends on a ~6year old version of diesel (where the regression is)
- https://crates.io/crates/cogo/0.1.36 is an old version of cogo, since that release cogo has already been updated to not depend on pattern this PR breaks
- https://github.com/cruise-automation/webviz-rust-framework is an archived read only repo so 🤷‍♀️
- makepad_render, doesn't seem to have source available and is 6 years old 🤷‍♀️
- outsource-heap - not on github
- zaplib - I couldn't get it to compile locally as it failed to compile a dependency

r? `@ghost`
2025-12-10 13:16:35 +00:00
Guillaume Gomez
9fdec8194e Fix new merge conflict 2025-12-10 12:35:17 +01:00
Guillaume Gomez
64aaeacd71 Update to new API, allowing to remove check_doc_cfg.rs file from librustdoc 2025-12-10 12:28:08 +01:00
Guillaume Gomez
4191e94715 Improve spans for auto_cfg(hide/show) errors 2025-12-10 12:28:08 +01:00
Guillaume Gomez
348d9d98e0 Correctly iterate doc comments in intra-doc resolution in rustc_resolve 2025-12-10 12:28:07 +01:00
Guillaume Gomez
4936973d49 Fix ui tests 2025-12-10 12:28:05 +01:00
Guillaume Gomez
e4f57dd4b3 Finish fixing ui tests 2025-12-10 12:27:34 +01:00
Guillaume Gomez
9c8c67bfdd Fix warning messages 2025-12-10 12:27:34 +01:00
bors
377656d3dd Auto merge of #149836 - matthiaskrgr:rollup-1ypvt7r, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#147725 (Remove -Zoom=panic)
 - rust-lang/rust#148294 (callconv: fix mips64 aggregate argument passing for C FFI)
 - rust-lang/rust#148491 ( Correctly provide suggestions when encountering `async fn` with a `dyn Trait` return type)
 - rust-lang/rust#149458 (Run clippy on cg_gcc in CI)
 - rust-lang/rust#149679 (Restrict spe_acc to PowerPC SPE targets)
 - rust-lang/rust#149781 (Don't suggest wrapping attr in unsafe if it may come from proc macro)
 - rust-lang/rust#149795 (Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std)
 - rust-lang/rust#149816 (Make typo in field and name suggestions verbose)
 - rust-lang/rust#149824 (Add a regression test for issue 145748)
 - rust-lang/rust#149826 (compiletest: tidy up `adb_path`/`adb_test_dir` handling)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-10 10:05:47 +00:00
Boxy
85aeb4f259 Forbid object lifetime changing pointer casts 2025-12-10 09:38:56 +00:00