Commit Graph

48659 Commits

Author SHA1 Message Date
Josh Triplett
8d5eb6badb mbe: Simplify compile_declarative_macro by factoring out some variables 2025-07-06 20:49:12 -07:00
Jacob Pratt
7eea141b87 Rollup merge of #143544 - workingjubilee:rename-bare-fn, r=fmease
compiler: rename BareFn to FnPtr

At some point "BareFn" was the chosen name for a "bare" function, without the niceties of `~fn`, `&fn`, or a few other ways of writing a function type. However, at some point the syntax for a "bare function" and any other function diverged even more. We started calling them what they are: function pointers, denoted by their own syntax.

However, we never changed the *internal* name for these, as this divergence was very gradual. Personally, I have repeatedly searched for "FnPtr" and gotten confused until I find the name is BareFn, only to forget this until the next time, since I don't routinely interact with the higher-level AST and HIR. But even tools that interact with these internal types only touch on them in a few places, making a migration easy enough. Let's use a more intuitive and obvious name, as this 12+ year old name has little to do with current Rust.
2025-07-07 03:26:09 +02:00
Jacob Pratt
3e76cd796f Rollup merge of #143535 - reallesee:patch-1, r=jdonszelmann
Remove duplicate word

Deleted a duplicated word to improve text clarity.

contains contains - contains
2025-07-07 03:26:08 +02:00
Jacob Pratt
a1b51aa400 Rollup merge of #143456 - joshtriplett:mbe-unused-rules-bitset, r=lqd
mbe: Change `unused_macro_rules` to a `DenseBitSet`

Now that it only contains indexes, and no other information, a bitset provides a more compact and simpler representation.

This builds on <https://github.com/rust-lang/rust/pull/143416>. Only the last commit is new.
2025-07-07 03:26:07 +02:00
Jacob Pratt
11b24c108d Rollup merge of #143344 - JonathanBrouwer:path-parser, r=jdonszelmann
Port `#[path]` to the new attribute parsing infrastructure

Ports `#[path]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197

This PR duplicates a change from https://github.com/rust-lang/rust/pull/143237
Draft until that one is merged
2025-07-07 03:26:06 +02:00
Jacob Pratt
d748e70fea Rollup merge of #143206 - Jules-Bertholet:align-attr-fixes, r=workingjubilee
Align attr fixes

- Remove references to the superseded `repr(align)` syntax
- Allow the attribute on fn items in `extern` blocks
- Test attribute in combination with `async fn` and `dyn`

r? workingjubilee

Tracking issue: https://github.com/rust-lang/rust/issues/82232
`@rustbot` label A-attributes F-fn_align T-compiler
2025-07-07 03:26:05 +02:00
Michael Goulet
a40274d6cc Dont resolve instance of root in mir_callgraph_cyclic 2025-07-06 23:01:45 +00:00
Jubilee Young
0a4f87a144 compiler: rename {ast,hir}::BareFn* to FnPtr*
Fix some comments and related types and locals where it is obvious, e.g.
- bare_fn -> fn_ptr
- LifetimeBinderKind::BareFnType -> LifetimeBinderKind::FnPtrType

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-07-06 15:03:08 -07:00
Jules Bertholet
a1cefee8d5 Support #[align(…)] on fns in extern blocks 2025-07-06 16:56:41 -04:00
Jules Bertholet
97a7b9b1b4 Remove repr(align) code 2025-07-06 16:56:39 -04:00
Jonathan Brouwer
244d64e60b Port #[path] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06 22:19:16 +02:00
Jonathan Brouwer
ef3d7741e5 Move check for new attribute to check_builtin_meta_item
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06 22:18:58 +02:00
bors
a84ab0ce6c Auto merge of #143509 - cjgillot:copy-prop-noborrow, r=tmiasko
Do not unify borrowed locals in CopyProp.

Instead of trying yet another scheme to unify borrowed locals in CopyProp, let's just stop trying. We had already enough miscompilations because of this.

I'm convinced it's possible to have both unification of some borrowed locals and soundness, but I don't have a simple and convincing formulation yet.

Fixes https://github.com/rust-lang/rust/issues/143491
2025-07-06 19:58:07 +00:00
Josh Triplett
8ee1e9817c mbe: Change unused_macro_rules to a DenseBitSet
Now that it only contains indexes, and no other information, a bitset
provides a more compact and simpler representation.
2025-07-06 12:02:23 -07:00
Micke
8b65c2f85f Remove duplicate word 2025-07-06 20:06:46 +02:00
Michael Goulet
b63f920ccf More carefully consider span context when suggesting remove &mut 2025-07-06 17:36:35 +00:00
Ralf Jung
7775166528 interpret: rename StackPopCleanup 2025-07-06 16:07:35 +02:00
Matthias Krüger
bff79a7517 Rollup merge of #143518 - joshtriplett:sort-attrs, r=Kobzol
rustc_builtin_macros: Make sure registered attributes stay sorted

As with the list of builtin macros, use tidy to make sure the list of
builtin attributes stays sorted.
2025-07-06 15:56:14 +02:00
Matthias Krüger
bae6714fe2 Rollup merge of #143492 - Diggsey:db-fix-object-ambiguity, r=RalfJung
Use `object` crate from crates.io to fix windows build error

See https://rust-lang.zulipchat.com/#narrow/channel/386786-rustc-codegen-gcc/topic/Cannot.20compile.20rustc.20on.20Windows.2010/with/527240094
2025-07-06 15:56:13 +02:00
Matthias Krüger
017fe2fb8f Rollup merge of #143252 - JonathanBrouwer:rewrite_empty_attribute, r=jdonszelmann
Rewrite empty attribute lint for new attribute parser

cc `@jdonszelmann`
2025-07-06 15:56:12 +02:00
Makai
c42a9ac602 move stable_mir back to its own crate and move rustc_internal to thestable_mir crate
As part of this reorganization, some traits need to be moved from `rustc_smir::context::traits` to `stable_mir::unstable::internal_cx`. These traits are specifically designed for `InternalCx` to clarify the behavior of different functions that share the same name. This move is necessary to avoid orphan rule violations.
2025-07-06 12:25:42 +00:00
Camille GILLOT
bab9c752e8 Do not unify borrowed locals in CopyProp. 2025-07-06 10:14:07 +00:00
Matthias Krüger
534c09a779 Rollup merge of #143484 - bvanjoi:issue-140796, r=compiler-errors
distinguish the duplicate item of rpitit

Fixes rust-lang/rust#140796

r? compiler

cc `@Zoxc`
2025-07-06 10:03:23 +02:00
Matthias Krüger
6fb00b1514 Rollup merge of #143477 - folkertdev:use-is-multiple-of, r=joshtriplett
use `is_multiple_of` and `div_ceil`

In tricky logic, these functions are much more informative than the manual implementations. They also catch subtle bugs:

- the manual `is_multiple_of` often does not handle division by zero
- manual `div_ceil` often does not consider overflow

The transformation is free for `is_multiple_of` if the divisor is compile-time known to be non-zero. For `div_ceil` there is a small cost to considering overflow. Here is some assembly https://godbolt.org/z/5zP8KaE1d.
2025-07-06 10:03:23 +02:00
Matthias Krüger
71b73e529a Rollup merge of #143416 - joshtriplett:mbe-simplifications, r=nnethercote
mbe: Defer checks for `compile_error!` until reporting an unused macro rule

The current MBE parser checks rules at initial parse time to see if their RHS has `compile_error!` in it, and returns a list of rule indexes and LHS spans that don't map to `compile_error!`, for use in unused macro rule checking.

Instead, have the unused macro rule reporting ask the macro for the rule to report, and let the macro check at that time. That avoids checking rules unless they're unused.

In the process, refactor the data structure used to store macro rules, to group the LHS and RHS (and LHS span) of each rule together, and refactor the unused rule tracking to only track rule indexes.

This builds atop a couple of minor MBE refactors. I would suggest reviewing commit-by-commit.

The overall result is a further simplification of the macro code.
2025-07-06 10:03:22 +02:00
Jonathan Brouwer
33f2cc7eda Fix line break after ":" in unpretty attribute print
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06 09:51:47 +02:00
Jonathan Brouwer
3fa0ec91d8 Rewrite empty attribute lint
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06 09:51:35 +02:00
bohan
5bbab8967d distinguish the duplicate item of rpitit 2025-07-06 14:04:40 +08:00
bors
febb10d0a2 Auto merge of #143507 - matthiaskrgr:rollup-lpg7t12, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#143238 (Port `#[ignore]` to the new attribute parsing infrastructure)
 - rust-lang/rust#143441 (Stop using `Key` trait unnecessarily)
 - rust-lang/rust#143478 (Miri subtree update)
 - rust-lang/rust#143486 (remove armv5te-unknown-linux-gnueabi target maintainer)
 - rust-lang/rust#143489 (Complete rustc_ast::mut_visit for spans.)
 - rust-lang/rust#143494 (Remove yields_in_scope from the scope tree.)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-06 04:09:12 +00:00
Josh Triplett
e99f9c5ffc rustc_builtin_macros: Make sure registered attributes stay sorted
As with the list of builtin macros, use tidy to make sure the list of
builtin attributes stays sorted.
2025-07-05 20:21:51 -07:00
dianne
68d860f8be remove DesugaringKind::CondTemporary 2025-07-05 17:14:06 -07:00
dianne
75cea03e03 de-duplicate condition scoping logic 2025-07-05 17:14:06 -07:00
Josh Triplett
63cfb3af37 mbe: Defer checks for compile_error! until reporting an unused macro rule
The MBE parser checks rules at initial parse time to see if their RHS
has `compile_error!` in it, and returns a list of rule indexes and LHS
spans that don't map to `compile_error!`, for use in unused macro rule
checking.

Instead, have the unused macro rule reporting ask the macro for the rule
to report, and let the macro check at that time. That avoids checking
rules unless they're unused.

In the process, refactor the data structure used to store macro rules,
to group the LHS and RHS (and LHS span) of each rule together, and
refactor the unused rule tracking to only track rule indexes.

This ends up being a net simplification, and reduction in code size.
2025-07-05 16:23:13 -07:00
Josh Triplett
0d5ab3e46c mbe: Simplify a match to a let-else 2025-07-05 16:23:13 -07:00
Josh Triplett
a7382eae3f mbe: Add a helper to parse a single TokenTree
The parser repeatedly invokes the `parse` function, constructing a
one-entry vector, and assuming that the return value will be a one-entry
vector. Add a helper for that case. This will simplify adding additional
callers, and put all the logic in one place to allow potential future
simplification of the one-TT case.
2025-07-05 16:23:07 -07:00
Matthias Krüger
c3c4fd7c9c Rollup merge of #143494 - cjgillot:no-yield-in-scope, r=compiler-errors
Remove yields_in_scope from the scope tree.

I believe this has not been in use since we removed the HIR-based generator interior type computation.
2025-07-05 22:34:43 +02:00
Matthias Krüger
8a5d239949 Rollup merge of #143489 - cjgillot:mut-visit-span, r=petrochenkov
Complete rustc_ast::mut_visit for spans.

Extracted from https://github.com/rust-lang/rust/pull/127241

r? `@petrochenkov`
2025-07-05 22:34:42 +02:00
Matthias Krüger
0311159e02 Rollup merge of #143441 - compiler-errors:no-key, r=petrochenkov
Stop using `Key` trait unnecessarily

Few places where the `Key` trait was being used but not really for a useful reason. This fixes those usages.

Namely, `<Ty as Key>::default_span()` is `DUMMY_SP` anyways.
2025-07-05 22:34:41 +02:00
Matthias Krüger
9a921a32f6 Rollup merge of #143238 - JonathanBrouwer:ignore_parser, r=jdonszelmann
Port `#[ignore]` to the new attribute parsing infrastructure

Ports `ignore` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197

This PR duplicates a change from https://github.com/rust-lang/rust/pull/143237
Draft until that one is merged
2025-07-05 22:34:40 +02:00
bors
5adb489a80 Auto merge of #142732 - compiler-errors:more-root, r=lcnr
Canonicalize input ty/ct infer/placeholder in the root universe

We shouldn't care what universe the inputs are, since we only ever do the leak check on the universes instantiated after entering the canonical binder.
2025-07-05 20:34:08 +00:00
Jonathan Brouwer
2d8ffff10a Port #[ignore] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-05 21:23:09 +02:00
Michael Goulet
4185874592 Don't compress input universes 2025-07-05 18:41:59 +00:00
Michael Goulet
7f5d286de3 Canonicalize input ty/ct infer/placeholder in the root universe 2025-07-05 18:37:54 +00:00
Michael Goulet
8eb9f70979 Stop using Key trait randomly 2025-07-05 18:37:11 +00:00
Michael Goulet
995eeeb54c Don't call predicates_of on a dummy obligation cause's body id 2025-07-05 17:47:28 +00:00
Diggory Blake
ea7b756875 Make tempfile a normal dependency 2025-07-05 17:24:22 +01:00
Camille GILLOT
39ee1b2d77 Remove yields_in_scope from the scope tree. 2025-07-05 15:24:15 +00:00
Diggory Blake
a839b071f7 Use object crate from crates.io to fix windows build error 2025-07-05 15:58:42 +01:00
Ralf Jung
3cd13f72a2 codegen_ssa: replace a Result by an Either 2025-07-05 15:53:56 +02:00
Camille GILLOT
90762c26b6 Complete mut_visit. 2025-07-05 12:37:17 +00:00