2064 Commits

Author SHA1 Message Date
Matthias Krüger
7e9b67d355
Rollup merge of #148716 - camelid:finish-type_const, r=BoxyUwU
mgca: Finish implementation of `#[type_const]`

tracking issue: rust-lang/rust#132980
fixes rust-lang/rust#140729
fixes rust-lang/rust#140860

- **Fix `#[type_const]` attribute placement validation**
- **Perform WF-checking on type_const RHS's**
- **Check type_const type is ConstParamTy_ and that RHS matches it**
- **Check that impls of `#[type_const]` consts also have the attr**

r? ```@BoxyUwU```
2025-11-09 17:37:07 +01:00
Matthias Krüger
e5a69bb215
Rollup merge of #148683 - fmease:rm-const_trait-attr, r=fee1-dead
Remove `#[const_trait]`

Remove `#[const_trait]` since we now have `const trait`. Update all structured diagnostics that still suggested the attribute.

r? ```@rust-lang/project-const-traits```
2025-11-09 17:37:05 +01:00
Noah Lev
e56de95478 Fix #[type_const] attribute placement validation 2025-11-08 23:05:08 -05:00
bors
72b21e1a64 Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU
mgca: Add ConstArg representation for const items

tracking issue: rust-lang/rust#132980
fixes rust-lang/rust#131046
fixes rust-lang/rust#134641

As part of implementing `min_generic_const_args`, we need to distinguish const items that can be used in the type system, such as in associated const equality projections, from const items containing arbitrary const code, which must be kept out of the type system. Specifically, all "type consts" must be either concrete (no generics) or generic with a trivial expression like `N` or a path to another type const item.

To syntactically distinguish these cases, we require, for now at least, that users annotate all type consts with the `#[type_const]` attribute. Then, we validate that the const's right-hand side is indeed eligible to be a type const and represent it differently in the HIR.

We accomplish this representation using a new `ConstItemRhs` enum in the HIR, and a similar but simpler enum in the AST. When `#[type_const]` is **not** applied to a const (e.g. on stable), we represent const item right-hand sides (rhs's) as HIR bodies, like before. However, when the attribute is applied, we instead lower to a `hir::ConstArg`. This syntactically distinguishes between trivial const args (paths) and arbitrary expressions, which are represented using `AnonConst`s. Then in `generics_of`, we can take advantage of the existing machinery to bar the `AnonConst` rhs's from using parent generics.
2025-11-08 22:31:33 +00:00
Noah Lev
66267da3e9 Use "rhs" terminology instead of "body" 2025-11-08 13:50:48 -05:00
Boxy Uwu
0a355170c0 fix associated_const_equality tests 2025-11-08 13:50:48 -05:00
León Orell Valerian Liehr
c262920059
Remove #[const_trait] 2025-11-08 07:37:15 +01:00
Lucas Baumann
d198633b95 add realtime sanitizer 2025-11-06 13:20:12 +01:00
Matthias Krüger
958f2a911f
Rollup merge of #148518 - bjorn3:unify_compiler_doc_config, r=GuillaumeGomez
Unify the configuration of the compiler docs

Previously it was rather inconsistent which crates got the rust logo and which didn't and setting html_root_url was forgotten in many cases.
2025-11-05 21:28:29 +01:00
Matthias Krüger
a508f6136a
Rollup merge of #147994 - jdonszelmann:duplicate-warning-struct, r=petrochenkov
Deduplicate deprecation warning when using unit or tuple structs

First commit adds a test that's broken currently, 2nd commit fixes it.

Created with `@WaffleLapkin`
2025-11-05 21:28:27 +01:00
bjorn3
973c7527b4 Unify the configuration of the compiler docs
Previously it was rather inconsistent which crates got the rust logo and
which didn't and setting html_root_url was forgotten in many cases.
2025-11-05 11:25:27 +00:00
Folkert de Vries
7be6d6f2e8
additional tests for pass_indirectly_in_non_rustic_abis
Also emit an error when `rustc_pass_indirectly_in_non_rustic_abis` is
used in combination with `repr(transparent)`.
2025-11-04 10:05:02 +01:00
beetrees
7354d3d9c2
Add #[rustc_pass_indirectly_in_non_rustic_abis] 2025-11-04 09:56:17 +01:00
Jana Dönszelmann
1b00911b5b
deduplicate warnings (attempt 2) 2025-11-03 10:45:25 +01:00
Noah Lev
0515aa5a3e mgca: Add ConstArg representation for const items 2025-11-01 14:59:10 -04:00
Matthias Krüger
dc9060688a
Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril,traviscross
Implement pin-project in pattern matching for `&pin mut|const T`

This PR implements part of rust-lang/rust#130494. It supports pin-project in pattern matching for `&pin mut|const T`.

~Pin-projection by field access (i.e. `&pin mut|const place.field`) is not fully supported yet since pinned-borrow is not ready (rust-lang/rust#135731).~

CC ``````@traviscross``````
2025-11-01 08:25:44 +01:00
Jonathan Brouwer
a09c4fc862
Fix types being marked as dead when they are inferred generic arguments
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-30 08:31:07 +01:00
Frank King
ace83458a4 Rename #[pin_project] to #[pin_v2] to avoid naming conflicts 2025-10-30 07:56:17 +08:00
Frank King
b36f15e840 Add #[pin_project] attribute for structurally pinning 2025-10-30 07:56:17 +08:00
Matthias Krüger
8f11852e78
Rollup merge of #138679 - Shunpoco:issue-125323, r=oli-obk
Issue-125323: ICE non-ADT in struct pattern when long time constant evaluation is in for loop

This PR fixes #125323

## Context
According to the issue, the ICE happens since #121206.
In the PR, some error methods were reorganized. For example, has_errors() was renamed to has_errors_exclude_lint_errors(). However, some codes which used the original has_errors() were not switched to has_errors_exclude_lint_errors(). I finally found that report_error() in writeback.rs causes this ICE. Currently the method uses tainted_by_errors() to get guar (ErrorGuaranteed), but originally it used dcx().has_errors() but it wasn't changed to has_errors_exclude_lint_errors() when changes in #121206 were merged. I don't think I fully understand how an error is propagated, but I suppose that the error from long time constant evaluation is unexpectedly propagated other parts (in this ICE, for loop), then cause the non-ADT in struct pattern ICE.

## Change
- Fix report_error() in writeback.rs: use dcx().has_errors_exclude_lint_errors() instead of tainted_by_errors() to prevent error propagation from constant evaluation.
- Add test for the ICE
- Modify some tests to align the change: Due to this fix, E0282 error happens (or not happen anymore) in some tests.

## NOTE
The 4th commit aims to revert the fix in #123516 because I confirmed that the ICE solved by the PR doesn't happen if I modify report_error(). I think the root cause of that ICE is the same as #125323 . But I can discard this commit since we can fix #125323 without it.
2025-10-18 23:54:43 +02:00
Shunpoco
845ff73d39 address review 2025-10-17 18:20:21 +01:00
Shunpoco
8e59e3ba33 treat an error taint from const eval lint in late_lint and check_mod_deathness
error from const eval lint causes ICE at check_pat in late_lint, because the function expects the typeck result isn't tainted by error but it is.
To avoid the ICE, check_pat returns earlier if the typeck_result is tainted.

check_mod_deathness also has an issue from the same reason. visit_body for making live symbols expects the typeck result has no error.
So this commit adds a check in visit_nested_body to avoid the ICE.
However, if visit_nested_body just returns without doing anything, all codes with the error are marked as dead, because live_symbols is empty.
To avoid this side effect, visit_nested_body and other visit_* functions in MarkSymbolVistior should return appropriate error.
If a function returns ControlFlow::Break, live_symbols_and_ignore_derived_traits returns earlier with error,
then check_mod_deathness, the caller of the function returns earlier without pushing everything into dead_codes.
2025-10-17 18:20:21 +01:00
Cameron Steffen
e60e9f0826 Split impl_(opt_)trait_ref 2025-10-17 08:36:34 -05:00
Cameron Steffen
c17b2dc283 Split trait_id_of_impl into impl(_opt)_trait_id 2025-10-17 08:36:34 -05:00
Matthias Krüger
72030511bb
Rollup merge of #147685 - jdonszelmann:deprecated-no-span, r=JonathanBrouwer
remove span calls from deprecated attribute checking

r? `@JonathanBrouwer`
2025-10-15 07:09:56 +02:00
Matthias Krüger
545ee6fe6b
Rollup merge of #147683 - jdonszelmann:less-duplicate-checking, r=JonathanBrouwer
only check duplicates on old/unparsed attributes

r? ``@JonathanBrouwer``

This was effectively already what we were doing, but this was implicit because `.name()` etc were just returning None when dealing with a parsed attribute.... this makes it explicit
2025-10-14 19:47:35 +02:00
Matthias Krüger
ea0c8d8e73
Rollup merge of #147682 - jdonszelmann:convert-rustc-main, r=JonathanBrouwer
convert `rustc_main` to the new attribute parsing infrastructure

r? ``@JonathanBrouwer``
2025-10-14 19:47:34 +02:00
Jana Dönszelmann
43d915c426
remove span calls from deprecated attribute checking 2025-10-14 18:44:22 +02:00
Jana Dönszelmann
047c37cf23
convert rustc_main to the new attribute parsing infrastructure 2025-10-14 17:55:00 +02:00
Jana Dönszelmann
a51a793472
only check duplicates on old/unparsed attributes 2025-10-14 17:32:05 +02:00
Matthias Krüger
81dd4082ab
Rollup merge of #147615 - jdonszelmann:span-calls-doc-attr, r=JonathanBrouwer,GuillaumeGomez
reduce calls to attr.span() in old doc attr parsing

r? `@oli-obk`

should be trivial, can also delegate to `@GuillaumeGomez` or `@JonathanBrouwer.`

As part of making span() return an option I want to reduce the number of places we call span in without it being known what specific attr it's for. This makes that more obvious for doc. Part of a chain of PRs that's coming.

https://github.com/rust-lang/rust/issues/131229#issuecomment-3395316064
2025-10-13 16:54:15 +02:00
Jana Dönszelmann
09ef5eb8af
reduce calls to attr.span() in old doc attr parsing 2025-10-12 22:15:58 +02:00
Camille GILLOT
ca0379d6cd Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
Camille Gillot
96b70fc3a1 Always compile hir_id_validator.
Making this compilation conditional causes an unused crate dependency
warning.
2025-10-11 20:50:21 +00:00
Camille GILLOT
5620c82e53 Report uninhabited call return types on MIR. 2025-10-11 20:50:20 +00:00
Stuart Cook
9ace0de26b
Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk
Prefer to use repeat_n over repeat().take()

More from https://github.com/rust-lang/rust/pull/147464, but batch processed with `ast-grep` to find and replace.

second commit add notes for library: affaf532f9

r? ``@RalfJung``
2025-10-09 18:43:26 +11:00
yukang
53c79f4523 bless format 2025-10-09 01:29:16 +08:00
yukang
1654cce210 prefer to use repeat_n over repeat and take 2025-10-09 01:24:55 +08:00
Boxy Uwu
8e9b0c4ca9 rename select_where_possible and select_all_or_error 2025-10-07 23:02:23 +01:00
bors
981353ca16 Auto merge of #147345 - Kivooeo:tidy-flt-fix, r=Kobzol
Tidy: revert `flt` to `ftl`

As was explained here https://github.com/rust-lang/rust/pull/147191#issuecomment-3353801210, this reverting this change because `flt` is incorrect format

Also maybe there is existed PR for that? I didn't found one

Follow up https://github.com/rust-lang/rust/pull/147191

cc `@GuillaumeGomez`
2025-10-05 15:55:18 +00:00
Stuart Cook
cae84c695a
Rollup merge of #147320 - chenyukang:yukang-fix-147303-fn-arg, r=jieyouxu
Avoid to suggest pattern match on the similarly named in fn signature

Fixes rust-lang/rust#147303
2025-10-05 15:35:03 +11:00
Kivooeo
67bc030833 change flt back to ftl 2025-10-04 18:18:58 +00:00
yukang
e9a45e6646 Avoid to suggest pattern match on the similarly named in fn signature 2025-10-04 17:12:41 +08:00
Jules Bertholet
d5ba5c1c92
Mark PatternTypo suggestion as maybe incorrect 2025-10-03 16:00:15 -04:00
Guillaume Gomez
9362ab549f Improve code and fix typo 2025-09-27 11:29:50 +02:00
Guillaume Gomez
653e1036ed Apply first review round suggestions 2025-09-27 11:29:50 +02:00
Guillaume Gomez
553308b115 Improve code and better check doc(cfg(...)) attributes 2025-09-27 11:29:49 +02:00
Guillaume Gomez
1561efe41a Add code documentation, improve code and improve error message 2025-09-27 11:29:49 +02:00
Guillaume Gomez
63aefe0737 Strenghten checks for doc(auto_cfg(show/hide)) attributes 2025-09-27 11:29:48 +02:00
Guillaume Gomez
7c00bccd3b Implement RFC 3631 2025-09-27 11:29:48 +02:00