Commit graph

358 commits

Author SHA1 Message Date
Lukas Wirth
8ce30264c8 cargo clippy --fix 2025-07-31 10:55:10 +02:00
Chayim Refael Friedman
de312d0c71 Don't run doctests 2025-06-23 00:50:22 +03:00
Tadeo Kondrak
a7c09532a0 Allow lifetime repeats in macros: $($x)'a*
This works in rustc. This change isn't motivated by any real code.
I just learned about it and decided to see why it doesn't work with
rust-analyzer.
2025-06-13 18:13:01 -06:00
Chayim Refael Friedman
4bcf03e28b Use stable AST IDs
Instead of simple numbering, we hash important bits, like the name of the item.

This will allow for much better incrementality, e.g. when you add an item. Currently, this invalidates the IDs of all following items, which invalidates pretty much everything.
2025-06-12 08:47:22 +03:00
Lukas Wirth
f0e39c77cc Add some more hir_expand::files conversions 2025-05-30 14:48:56 +02:00
Lukas Wirth
9d1364b730 minor: Add a mbe test for parsing negative literals 2025-05-05 12:10:48 +02:00
Chayim Refael Friedman
0f325c7ff8 Remove unnecessary predefined symbol clones
Now that they're const it's no longer needed.

Nothing manual was performed: only a regexp search of `sym::([\w][\w\d]*)\.clone\(\)` and replace by `sym::$1`.
2025-04-21 03:10:13 +03:00
Lukas Wirth
33c3f67764
Merge pull request #19511 from snprajwal/fixmes
chore: clean up some FIXMEs
2025-04-07 10:30:46 +00:00
Prajwal S N
72c7cd3869
chore: clean up some FIXMEs
Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
2025-04-04 17:40:56 +05:30
Chayim Refael Friedman
3953b604ce Fix a bug in MBE expansion that arose from incorrect fixing of an older bug in MBE
Specifically, #18744 was the PR that was supposed to fix the old bug, but it fixed it incorrectly (and didn't add a test!) The underlying reason was that we marked metavariables in expansions as joint if they were joint in the macro call, which is incorrect.

This wrong fix causes other bug, #19497, which this PR fixes by removing the old (incorrect) fix.
2025-04-01 21:05:51 +03:00
Lukas Wirth
500ea05aef chore: Bump dependencies 2025-03-23 08:46:10 +01:00
Lukas Wirth
d4122434dd chore: Remove unused dependencies 2025-03-23 08:08:17 +01:00
Lukas Wirth
a505420751 chore: Bump Edition::CURRENT to 2024 2025-03-17 12:29:19 +01:00
Lukas Wirth
a06aadb9f0 internal: Render root syntax contexts more clearly 2025-03-16 16:26:07 +01:00
BenjaminBrienen
7535bb4661 cargo fmt 2025-03-15 21:32:01 +01:00
Lukas Wirth
02a793bd59 chore: Remove legacy SyntaxContextId re-export 2025-03-15 17:09:17 +01:00
David Barsky
74620e64ec internal: port rust-analyzer to new Salsa 2025-03-10 13:30:51 -04:00
¨Florian
5335d8cbc5 Fix syntax fixup producing invalid punctuation
Fixes #19206.
Fixes #18244.
2025-03-08 13:21:00 +01:00
BenjaminBrienen
b19ef6b046 fix doc tests 2025-02-27 14:58:46 +01:00
BenjaminBrienen
bd7375a58f enable doctest 2025-02-27 14:58:46 +01:00
Chayim Refael Friedman
8ab18927ce Fix another bug when reaching macro expansion limit caused a stack overflow
This time without missing bindings.

Solve it by returning to the old ways, i.e. just throw the extra nodes away.

In other words, I acknowledge defeat.
2025-01-13 15:55:30 +02:00
Lukas Wirth
3fe50ef83c
Merge pull request #18861 from ChayimFriedman2/await-edition
fix: Make edition per-token, not per-file
2025-01-09 10:20:11 +00:00
Chayim Refael Friedman
97afb7bfba Make edition per-token, not per-file
More correctly, *also* per-token. Because as it turns out, while the top-level edition affects parsing (I think), the per-token edition affects escaping of identifiers/keywords.
2025-01-09 05:43:08 +02:00
Chayim Refael Friedman
0d4af7bce3 Fix a bug with missing binding in MBE
We should immediately mark them as finished, on the first entry.

The funny (or sad) part was that this bug was pre-existing, but previously to #18327, it was causing us to generate bindings non-stop, 65535 of them, until we get to the hardcoded repetition limit, and then throw it all away. And it was so Blazingly Fast that nobody noticed.

With #18327 however, this is still what happens, except that now instead of *merging* the fragments into the result, we write them on-demand. Meaning that when we hit the limit, we've already written all previous entries. This is a minor change, I thought for myself when I was writing this, and it's actually for the better, so who cares. Minor change? Not so fast. This caused us to emit 65535 repetitions, all of which the MBE infra needs to handle when calling other macros with the expansion, and convert to rowan tree etc., which resulted a *massive* hang.

The test (and also `analysis-stats`) used to crash with stack overflow on this macro, because we were dropping some crazily deep rowan tree. Now they work properly. Because I am lazy, and also because I could not find the exact conditions that causes a macro match but with a missing binding, I just copied all macros from tracing. Easy.
2025-01-07 23:04:53 +02:00
Lukas Wirth
bff9bd0286 Drop unnecessary tracing::warn
We already emit an error
2025-01-07 14:40:00 +01:00
Lukas Wirth
4b6007115a minor: New clippy lints 2025-01-06 17:57:17 +01:00
Chayim Refael Friedman
ceba289f80 Store token trees in contiguous Vec instead of as a tree
I expected this to be faster (due to less allocations and better cache locality), but benchmarked it is not (neither it is slower). Memory usage, however, drops by ~50mb (of `analysis-stats .`). I guess tt construction is just not hot.

This also simplifies using even less memory for token trees by compressing equal span, which I plan to do right after.

Some workflows are more easily expressed with a flat tt, while some are better expressed with a tree. With the right helpers, though (which was mostly a matter of trial and error), even the worst workflows become very easy indeed.
2025-01-02 19:21:46 +02:00
Lukas Wirth
9997374b0c Remove dangling outdated test module 2024-12-24 10:37:24 +01:00
Lukas Wirth
02e189dcb5 fix: FIx mbe bench tests being iteration order dependent 2024-10-21 11:54:49 +02:00
Lukas Wirth
70d0b57cf0 Update ide tests 2024-10-21 11:28:19 +02:00
Laurențiu Nicola
f84aa5de4a Add missing rustc_private 2024-09-25 10:56:37 +03:00
bors
d4689f183a Auto merge of #18151 - ChayimFriedman2:metavar-concat, r=Veykril
feat: Support the `${concat(...)}` metavariable expression

I didn't follow rustc precisely, because I think it does some things wrongly (or they are FIXME), but I only allowed more code, not less. So we're all fine.

Closes #18145.
2024-09-20 07:23:43 +00:00
Chayim Refael Friedman
5c06f047b9 When checking for forbidden expr kind matches, account for rawness
An expression starting with `r#const` etc. should be accepted even in edition <=2021.
2024-09-19 23:38:48 +03:00
Chayim Refael Friedman
8a50aecb07 Support the ${concat(...)} metavariable expression
I didn't follow rustc precisely, because I think it does some things wrongly (or they are FIXME), but I only allowed more code, not less. So we're all fine.
2024-09-19 22:19:12 +03:00
bors
990c48cb0d Auto merge of #18131 - ChayimFriedman2:macro-expand-dollar-crate, r=Veykril
fix: Get rid of `$crate` in expansions shown to the user

Be it "Expand Macro Recursively", "Inline macro" or few other things.

We replace it with the crate name, as should've always been.

Probably fixes some issues, but I don't know what they are.
2024-09-18 20:17:21 +00:00
Chayim Refael Friedman
cfb701ac78 Get rid of $crate in expansions shown to the user
Be it "Expand Macro Recursively", "Inline macro" or few other things.

We replace it with the crate name, as should've always been.
2024-09-18 18:30:59 +03:00
Shoyu Vanilla
d34a663c70 feat: Implement expr_2021 2024-09-18 15:58:03 +09:00
Lukas Wirth
4502a602a7 internal: Lay basic ground work for standalone mbe tests 2024-09-01 12:42:44 +02:00
Vincent Esche
7dec7e92ea Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
Vincent Esche
6f329e6d5b Add repository URL for published crates' missing [package.repository] fields 2024-08-06 00:25:02 +02:00
Vincent Esche
b5b0f4bc5a Replace "TBD" with more helpful desciptions in published crates' [package.description] fields 2024-08-06 00:25:02 +02:00
Lukas Wirth
d2dd4f6d5f Split out syntax-bridge into a separate crate 2024-08-05 13:45:00 +02:00
Lukas Wirth
ae9c553902 Make basic use of spans for macro expansion errors 2024-07-29 14:52:40 +02:00
Lukas Wirth
f4199f786e Parse contextual dyn keyword properly in edition 2015 2024-07-19 20:20:30 +02:00
Lukas Wirth
546eb6b530 Test macros doing edition dependent parsing 2024-07-19 16:43:58 +02:00
Lukas Wirth
5264f86242 Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
Lukas Wirth
7011094685 Add always disabled gen parse support 2024-07-17 10:49:12 +02:00
Lukas Wirth
93024ad411 Switch token trees to use Symbols 2024-07-16 10:11:59 +02:00
Lukas Wirth
05ce57efd5 Fix incorrect encoding of literals in the proc-macro-api on version 4 2024-07-15 14:51:01 +02:00
Lukas Wirth
e846c04fbe Encode ident rawness and literal kind separately in tt::Leaf 2024-07-15 12:24:40 +02:00