1402 Commits

Author SHA1 Message Date
Stuart Cook
74e90d8804
Rollup merge of #148688 - JonathanBrouwer:remove_features, r=jdonszelmann
Remove unused argument `features` from `eval_config_entry`
2025-11-09 13:22:35 +11: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
Jonathan Brouwer
c52b7036c0
Remove unused argument features from eval_config_entry
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-11-08 10:48:08 +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
Noah Lev
0515aa5a3e mgca: Add ConstArg representation for const items 2025-11-01 14:59:10 -04:00
Matthias Krüger
48db5270a0
Rollup merge of #147438 - reddevilmidzy:rename-non-inline-module-in-msg, r=fee1-dead
Rename "non-inline module" to "file module" in proc macro diagnostics

This PR updates diagnostic messages to use "file module" instead of "non-inline module". because the term "non-inline module" can be confusing, especially for non-native English speakers.

follow up PR rust-lang/rust#147395
related of rust-lang/rust#147314, [#general > Rename "non-inline modules" to "external modules"](https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/.E2.9C.94.20Rename.20.22non-inline.20modules.22.20to.20.22external.20modules.22/near/543361244)

cc ```@Kivooeo```
2025-10-18 23:54:44 +02:00
Matthias Krüger
2b582ea0ba
Rollup merge of #147532 - JonathanBrouwer:cfg_attr2, r=jdonszelmann
Port `#[cfg_attr]` to the new attribute parsing infrastructure

This work in progress, not ready for review.
PR mostly for ci/perf runs
2025-10-18 15:09:03 +02:00
reddevilmidzy
a1a9113aa8 Rename "non-inline module" to "file module" in proc macro diagnostics 2025-10-18 11:54:57 +09:00
bors
f5242367f4 Auto merge of #146221 - camsteffen:ast-boxes, r=cjgillot
Remove boxes from ast list elements

Less indirection should be better perf.
2025-10-16 02:31:44 +00:00
Jonathan Brouwer
7113d58c8e
Port #[cfg_attr] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-15 22:18:18 +02:00
Jonathan Brouwer
e0c190f681
Move parse_cfg_attr to rustc_attr_parsing
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-15 22:18:18 +02:00
Jonathan Brouwer
52cc311828
Rename some functions
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-15 22:18:17 +02:00
Matthias Krüger
6332a76b3d
Rollup merge of #147395 - reddevilmidzy:refact-error-msg, r=Kivooeo,jackh726
Improve diagnostics: update note and add help message

I moved the content from the note to a help message, as it seemed more appropriate there, and then added new information to the note(`Modules are usually placed outside of blocks, at the top level of the file`)!

resolve: rust-lang/rust#147314
2025-10-07 07:04:18 +02:00
reddevilmidzy
02126adc1b Improve diagnostics: replace 'non-inline module' with 'file module' and update note/help messages 2025-10-07 02:53:45 +09:00
Kivooeo
67bc030833 change flt back to ftl 2025-10-04 18:18:58 +00:00
Cameron Steffen
c44500b4a1 Remove boxes from ast Pat lists 2025-10-04 12:39:58 -05:00
Matthias Krüger
ac7beab527
Rollup merge of #146535 - joshtriplett:mbe-unsafe-attr, r=petrochenkov
mbe: Implement `unsafe` attribute rules

This implements `unsafe attr` rules for declarative `macro_rules!` attributes, as specified in [RFC 3697](https://github.com/rust-lang/rfcs/pull/3697).

An invocation of an attribute that uses an `unsafe attr` rule requires the `unsafe(attr(...))` syntax.

An invocation of an attribute that uses an ordinary `attr` rule must *not* use the `unsafe(attr(...))` syntax.

`unsafe` is only supported on an `attr` rule, not any other kind of `macro_rules!` rule.

Tracking issue for `macro_rules!` attributes: https://github.com/rust-lang/rust/issues/143547
2025-10-02 10:27:49 +02:00
Josh Triplett
4fc0a0d42a mbe: expand_invoc: Add comment about not needing to check safety of LegacyAttr here
`LegacyAttr` is only used for builtin attributes, and builtin attributes
have their safety checked by `check_attribute_safety`, so we don't need
to check `unsafety` here.
2025-10-01 16:19:39 -07:00
Josh Triplett
6bff1abf9d mbe: Support unsafe attribute rules 2025-10-01 16:19:39 -07:00
Josh Triplett
30d57abccf mbe: Rename a local variable to match corresponding field names
This simplifies subsequent initialization of enum variants.
2025-10-01 16:19:39 -07:00
Matthias Krüger
618942b86f
Rollup merge of #147040 - joshtriplett:mbe-fix-comments, r=petrochenkov
mbe: macro_check: Fix function comments referencing non-existent parameters

Several functions had comments referencing a non-existent `valid`
parameter. Remove those. The `guar` parameter that handles errors is
already documented.

In the process, remove another duplicate reference to an
already-documented parameter (`binders`).
2025-09-29 21:42:42 +02:00
Matthias Krüger
978c960ed6
Rollup merge of #147031 - joshtriplett:mbe-opt-collect, r=lcnr
mbe: Simplify check_redundant_vis_repetition

Eliminate a use of `map_or` in favor of a match.

Inline some variable definitions that don't add clarity, and that
prevent short-circuiting.
2025-09-26 18:11:14 +02:00
Matthias Krüger
ba93a4f674
Rollup merge of #146849 - joshtriplett:macro-reduce-legacy-bang, r=petrochenkov
Reduce some uses of `LegacyBang`

- **Switch `dummy_bang` from `LegacyBang` to `Bang`**
- **mbe: Switch dummy extension used for errors from `LegacyBang` to `Bang`**
2025-09-26 18:11:12 +02:00
Josh Triplett
9e3f7487e9 mbe: Simplify check_redundant_vis_repetition
Eliminate a use of `map_or` in favor of a match.

Inline some variable definitions that don't add clarity, and that
prevent short-circuiting.
2025-09-25 07:54:28 -07:00
Josh Triplett
89a3a445bf mbe: macro_check: Fix function comments referencing non-existent parameters
Several functions had comments referencing a non-existent `valid`
parameter. Remove those. The `guar` parameter that handles errors is
already documented.

In the process, remove another duplicate reference to an
already-documented parameter (`binders`).
2025-09-25 07:18:36 -07:00
Matthias Krüger
15c323fa6d
Rollup merge of #146802 - joshtriplett:mbe-simplifications, r=petrochenkov
mbe: Simplifications and refactoring

A few simplifications and refactors in advance of other work.

Macro metavariable expressions were using `Ident::as_str` and doing string
comparisons; I converted them to use symbols.

I factored out a function for transcribing a `ParseNtResult`, which will help
separate the evaluation and transcription of future macro metavariable
expressions.
2025-09-23 18:13:54 +02:00
Josh Triplett
a1646bf90c mbe: Switch dummy extension used for errors from LegacyBang to Bang 2025-09-22 00:41:22 +08:00
Josh Triplett
e99e226748 Switch dummy_bang from LegacyBang to Bang 2025-09-22 00:41:22 +08:00
Jonathan Brouwer
6abcadc235
Port #[macro_export] to the new attribute parsing infrastructure
Co-authored-by: Anne Stijns <anstijns@gmail.com>
2025-09-21 10:42:47 -04:00
Josh Triplett
a54111a548 mbe: metavar expressions: Use symbols rather than ident.as_str()
Identify metavariable functions by using named symbols rather than
string comparisons.
2025-09-20 10:38:36 +08:00
Josh Triplett
fc41c38379 mbe: Factor out a function to transcribe a ParseNtResult 2025-09-20 10:38:36 +08:00
Josh Triplett
bb430f8e1e mbe: Simplify match in transcribe_metavar
Factor out the check for a variable that's still repeating.
2025-09-20 10:38:36 +08:00
Josh Triplett
3ab89abac4 mbe: Fix feature gate for macro_derive 2025-09-19 23:17:12 +08:00
León Orell Valerian Liehr
ec7ad59789
Move more early buffered lints to dyn lint diagnostics (4/N) 2025-09-14 12:38:12 +02:00
León Orell Valerian Liehr
31c0d96cb6
Move more early buffered lints to dyn lint diagnostics (2/N) 2025-09-14 12:38:11 +02:00
León Orell Valerian Liehr
2e816736ef
Move more early buffered lints to dyn lint diagnostics (1/N) 2025-09-14 12:38:11 +02:00
Stuart Cook
40520c6357
Rollup merge of #146308 - cyrgani:concat-integer-literals, r=jackh726
support integer literals in `${concat()}`

Tracking issue: rust-lang/rust#124225

Adds support for using integer literals as arguments to `${concat()}` macro expressions.
Integer formatting such as `1_000` is preserved by this.
2025-09-12 20:02:11 +10:00
Matthias Krüger
86d39a0673
Rollup merge of #146340 - fmease:frontmatter-containment, r=fee1-dead,Urgau
Strip frontmatter in fewer places

* Stop stripping frontmatter in `proc_macro::Literal::from_str` (RUST-146132)
* Stop stripping frontmatter in expr-ctxt (but not item-ctxt!) `include`s (RUST-145945)
* Stop stripping shebang (!) in `proc_macro::Literal::from_str`
  * Not a breaking change because it did compare spans already to ensure there wasn't extra whitespace or comments (`Literal::from_str("#!\n0")` already yields `Err(_)` thankfully!)
* Stop stripping frontmatter+shebang inside some rustdoc code where it doesn't make any observable difference (see self review comments)
* (Stop stripping frontmatter+shebang inside internal test code)

Fixes https://github.com/rust-lang/rust/issues/145945.
Fixes https://github.com/rust-lang/rust/issues/146132.

r? fee1-dead
2025-09-10 20:29:09 +02:00
León Orell Valerian Liehr
7a66925a81
Strip frontmatter in fewer places 2025-09-09 19:49:40 +02:00
Jana Dönszelmann
6087d89004
fixup limit handling code 2025-09-08 15:07:12 -07:00
cyrgani
1cb749aa3b support integer literals in ${concat()} 2025-09-07 22:09:37 +02:00
Stuart Cook
57e8a5317a
Rollup merge of #146090 - Kobzol:invisible-origin-eq, r=petrochenkov
Derive `PartialEq` for `InvisibleOrigin`

For https://github.com/rust-lang/rust/pull/145354, we need `PartialEq` for `TokenStream` to "just work". However, due to the special comparison implementation that was used for `InvisibleOrigin`, this wasn't the case.

So I derived `PartialEq` for `InvisibleOrigin`, and used the previous special comparison logic only on the single place where it was actually required.

r? `````````@petrochenkov`````````
2025-09-04 10:01:58 +10:00
Guillaume Gomez
7b2bfa361e
Rollup merge of #146064 - jullanggit:patch-1, r=fmease
Add compiler error when trying to use concat metavar expr in repetitions

## Disclaimer
This is my first PR to rust, so if I missed/could improve something about this PR, please excuse and tell me!
## The improvement
The [metavar_expr_concat feature](https://github.com/rust-lang/rust/issues/124225) currently does not seem to support nested repetitions, and throws an ICE without much explanation if the relevant code path is hit.
This PR adds a draft compiler error that attempts to explain the issue. I am not 100% sure what all the ways of triggering this error are, so the message is currently pretty generic, please do correct me if there's something wrong with it or it could be improved.

Thank you for you time!

Fixes rust-lang/rust#140479.
2025-09-02 17:08:54 +02:00
Jakub Beránek
a8537ab84b
Remove special implementation of PartialEq for InvisibleOrigin outside macro matching 2025-09-02 16:38:31 +02:00
Nicholas Nethercote
301655eafe Revert introduction of [workspace.dependencies].
This was done in #145740 and #145947. It is causing problems for people
using r-a on anything that uses the rustc-dev rustup package, e.g. Miri,
clippy.

This repository has lots of submodules and subtrees and various
different projects are carved out of pieces of it. It seems like
`[workspace.dependencies]` will just be more trouble than it's worth.
2025-09-02 19:12:54 +10:00
jullang
f6e7c81061 Add compiler error when trying to use concat metavar expr in repetitions
Replace unimplemented()! with a more helpful compiler error.
2025-09-01 08:27:30 +02:00
Nicholas Nethercote
c50d2cc807 Add tracing to [workspace.dependencies]. 2025-08-27 14:21:19 +10:00
Nicholas Nethercote
777e2d6a2a Add thin-vec to newly added [workspace.dependencies]. 2025-08-27 13:59:32 +10:00
Jonathan Brouwer
3851e6c7b6
Warn on macro calls for attributes that had this behaviour previously 2025-08-24 14:29:03 +02:00