Commit Graph

24 Commits

Author SHA1 Message Date
Jana Dönszelmann
7c085f7ffd
add rustc_macro_edition_2021 2025-03-19 17:37:35 +01:00
Matthias Krüger
d93ef397ce
Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu
Use `RUSTC_LINT_FLAGS` more

An alternative to the failed #138084.

Fixes #138106.

r? ````@jieyouxu````
2025-03-12 17:59:08 +01:00
Jakub Beránek
c054bac89a
Rollup merge of #138063 - compiler-errors:improve-attr-unpretty, r=jdonszelmann
Improve `-Zunpretty=hir` for parsed attrs

0. Rename `print_something` to `should_render` to make it distinct from `print_attribute` in that it doesn't print anything, it's just a way to probe if a type renders anything.
1. Fixes a few bugs in the `PrintAttribute` derive. Namely, the `__printed_anything` variable was entangled with the `should_render` call, leading us to always render field names but never render commas.
2. Remove the outermost `""` from the attr.
3. Debug print `Symbol`s. I know that this is redundant for some parsed attributes, but there's no good way to distinguish symbols that are ident-like and symbols which are cooked string literals. We could perhaps *conditionally* to fall back to a debug printing if the symbol doesn't match an ident? But seems like overkill.

Based on #138060, only review the commits not in that one.
2025-03-11 13:30:51 +01:00
Nicholas Nethercote
ff0a5fe975 Remove #![warn(unreachable_pub)] from all compiler/ crates.
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-11 13:14:21 +11:00
许杰友 Jieyou Xu (Joe)
063ef18fdc Revert "Use workspace lints for crates in compiler/ #138084"
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to
consider options that avoids breaking downstream usages of cargo on
distributed `rustc-src` artifacts, where such cargo invocations fail due
to inability to inherit `lints` from workspace root manifest's
`workspace.lints` (this is only valid for the source rust-lang/rust
workspace, but not really the distributed `rustc-src` artifacts).

This breakage was reported in
<https://github.com/rust-lang/rust/issues/138304>.

This reverts commit 48caf81484, reversing
changes made to c6662879b2.
2025-03-10 18:12:47 +08:00
Michael Goulet
279377f87a Fix pretty printing of parsed attrs in hir_pretty 2025-03-10 02:04:26 +00:00
Michael Goulet
6a38322d26 Rename print_something to should_render 2025-03-10 02:03:19 +00:00
Matthias Krüger
d88752a4b5
Rollup merge of #138160 - jdonszelmann:move-find-attr2, r=oli-obk
depend more on attr_data_structures and move find_attr! there

r?  ``@oli-obk``

This should be an easy one. It just moves some imports around. This is necessary for other changes that I'm working on not to have import cycles. However, it's an easy one to just merge on its own.
2025-03-09 10:34:52 +01:00
Nicholas Nethercote
8a3e03392e Remove #![warn(unreachable_pub)] from all compiler/ crates.
(Except for `rustc_codegen_cranelift`.)

It's no longer necessary now that `unreachable_pub` is in the workspace
lints.
2025-03-08 08:41:43 +11:00
Nicholas Nethercote
beba32cebb Specify rust lints for compiler/ crates via Cargo.
By naming them in `[workspace.lints.rust]` in the top-level
`Cargo.toml`, and then making all `compiler/` crates inherit them with
`[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`,
because they're a bit different.)

The advantages of this over the current approach:
- It uses a standard Cargo feature, rather than special handling in
  bootstrap. So, easier to understand, and less likely to get
  accidentally broken in the future.
- It works for proc macro crates.

It's a shame it doesn't work for rustc-specific lints, as the comments
explain.
2025-03-08 08:41:09 +11:00
Jana Dönszelmann
4203e9c56d
depend more on attr_data_structures and move find_attr! there 2025-03-07 18:05:42 +01:00
Alona Enraght-Moony
df845c97f3 Spruce up AttributeKind docs
- Remove dead link to `rustc_attr` crate.
- Add link to `rustc_attr_parsing` crate.
- Split up first paragraph so it looks better at crate-level summary
2025-02-26 22:21:36 +00:00
Jana Dönszelmann
95b52d51ea
pretty print hir attributes 2025-02-24 14:31:19 +01:00
Jana Dönszelmann
7e0f5b5016
Introduce new-style attribute parsers for several attributes
note: compiler compiles but librustdoc and clippy don't
2025-02-24 14:31:17 +01:00
Jana Dönszelmann
dbd3b7928e
Introduce new parsing infrastructure and types for parsed attributes
fixup docs in parser
2025-02-24 14:26:06 +01:00
Michael Goulet
76d341fa09 Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
Ralf Jung
3320e91575 rustc_allowed_through_unstable_modules: require deprecation message 2025-02-02 12:36:12 +01:00
clubby789
5ac95a5c47 Rename OptimizeAttr::None to Default 2025-01-24 19:34:01 +00:00
clubby789
7a9661d768 Disable non-required MIR opts with optimize(none)
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2025-01-23 17:40:41 +00:00
clubby789
cd848c9f3e Implement optimize(none) attribute 2025-01-23 17:19:53 +00:00
Ralf Jung
cf0ab86251 allowed_through_unstable_modules: support showing a deprecation message when the unstable module name is used 2025-01-15 09:41:33 +01:00
David Wood
f86169a58f
mir_transform: implement forced inlining
Adds `#[rustc_force_inline]` which is similar to always inlining but
reports an error if the inlining was not possible, and which always
attempts to inline annotated items, regardless of optimisation levels.
It can only be applied to free functions to guarantee that the MIR
inliner will be able to resolve calls.
2025-01-10 18:37:54 +00:00
Pietro Albini
80cdaeac3d
avoid replacing the definition of CURRENT_RUSTC_VERSION
Before this commit, replace-version-placeholder hardcoded the path
defining CURRENT_RUSTC_VERSION (to avoid replacing it). After a refactor
moved the file defining it without changing the hardcoded path, the tool
started replacing the constant itself with the version number.

To avoid this from happening in the future, this changes the definition
of the constant to avoid the tool from ever matching it.
2025-01-06 21:53:48 +01:00
Jonathan Dönszelmann
efb98b6552
rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures 2024-12-16 19:08:19 +01:00