Commit graph

106 commits

Author SHA1 Message Date
Chayim Refael Friedman
de312d0c71 Don't run doctests 2025-06-23 00:50:22 +03:00
Chayim Refael Friedman
3e834add61 Support spans with proc macro servers from before the ast id changes
The only thing changed is the value of the fixup ast id, so we just swap it.
2025-06-12 16:08:48 +03: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
Chayim Refael Friedman
db72e2ff41 Adjust for salsa::Id::from_u32() being unsafe
This impacts our manual `salsa::Id` wrappers. I refactored them a bit to improve safety.
2025-04-22 15:19:35 +03:00
Lukas Wirth
34e7d60e30
Merge pull request #19644 from ChayimFriedman2/const-syms
internal: Make predefined symbols `const` instead of `static`
2025-04-21 12:34:59 +00: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
jyn
3b964a7105 allow using null to unset an environment variable
this makes three changes:
- all callsites of `toolchain::command` are changed to use
  `command(path, extra_env)`, instead of manually adding the env after
  the fact.
- all `map<str, str>` are changed to `map<str, option<str>>`.
- `command` checks for None and calls `env_remove` if so.

this caught several places where environment variables weren't being
propagated:
- when running `rustc --print=target-libdir`
- when running `cargo rustc -- --print=target-spec-json`
- when running the custom DiscoverLinkedProjects config. I *think* this
  is for use with non-cargo build systems, so I didn't change it.
2025-04-19 12:15:22 -04:00
Lukas Wirth
1e1571e1c8 fix: Fix new nightly lints 2025-03-31 13:27:54 +02:00
Lukas Wirth
faf1b49a9a fix: Fix, clarify and require a value for proc_macro_cwd of CrateData 2025-03-29 08:08:48 +01:00
Lukas Wirth
64d39c1abc
Merge pull request #19329 from Shourya742/2025-03-10-add-proc-macro-api-doc
doc: add doc to proc-macro-api
2025-03-17 09:17:35 +00:00
BenjaminBrienen
7535bb4661 cargo fmt 2025-03-15 21:32:01 +01:00
Neil
1e3026ccb7
refactor: Simplify by removing ? operator
`out.flush()` already returns a `io::Result<()>`, so there is no need for `?` operator and `Ok(())`
2025-03-15 12:34:48 -07:00
Lukas Wirth
02a793bd59 chore: Remove legacy SyntaxContextId re-export 2025-03-15 17:09:17 +01:00
Chayim Refael Friedman
c94e9efbef Salsify the crate graph
I.e. make it not one giant input but multiple, for incrementality and decreased memory usage for Salsa 3 reasons.
2025-03-12 21:02:30 +02:00
bit-aloo
3546ef2f06
doc: add doc to proc-macro-api 2025-03-10 18:43:41 +05:30
BenjaminBrienen
bd7375a58f enable doctest 2025-02-27 14:58:46 +01: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
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
b2d9486ebd Move proc-macro protocol into legacy module 2024-12-30 11:47:08 +01:00
Lukas Wirth
714b81bec1 Decouple proc-macro server protocol from the server implementation 2024-12-30 10:33:57 +01:00
Lukas Wirth
5ce14b0439 Enforce a current directory being set for spawned commands 2024-12-29 12:51:13 +01:00
Lukas Wirth
c966876f85
Revert "internal: Drop proc-macro server support for ~1.66.0 and older toolchains" 2024-12-20 20:51:09 +01:00
Lukas Wirth
5211972743 internal: Split serde derive feature into serde_derive usage
Ideally we'd not have any dependency pull in the derive feature for faster build times, once that is the case this change would have an actual effect.
See https://github.com/matklad/macro-dep-test/blob/master/README.md for context.
2024-12-20 11:55:02 +01:00
Lukas Wirth
3d63140758 Remove salsa from proc-macro server dep tree 2024-12-18 10:24:26 +01:00
Lukas Wirth
f0b5b8333d internal: Drop proc-macro server support for ~1.66.0 and older toolchains 2024-12-12 15:06:14 +01:00
benluiwj
1c71a50e01 Improve error message for too new proc-macro server 2024-11-02 21:46:05 +08:00
Lukas Wirth
6c23f25e7f Fix new nightly lints 2024-10-22 11:48:41 +02:00
Lukas Wirth
c2258d8880 Properly set the working directory for proc-macro execution 2024-09-11 12:23:12 +02:00
Lukas Wirth
9a47e6f2c8 Expand proc-macros in workspace root, not package root 2024-08-27 13:40:24 +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
f8de86b308 Apply Veykril's change suggestions 2024-08-06 00:25:02 +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
188c577855 Newtype ErasedFileAstId 2024-08-05 13:46:47 +02:00
Lukas Wirth
5264f86242 Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +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
Lukas Wirth
c6709ffe05 Improve error message when the proc-macro server unexpectedly exits 2024-07-01 14:30:21 +02:00
Lukas Wirth
956c8521a9 Arc proc-macro expander paths 2024-06-30 17:03:03 +02:00
Lukas Wirth
c236190b60 Abstract proc-macro-srv protocol format 2024-06-30 16:56:30 +02:00
Lukas Wirth
7c7c0cbffb Simplify 2024-06-30 16:43:22 +02:00
Lukas Wirth
2fb38ceb66 Faster env snapshotting in proc-macro-srv 2024-06-30 16:10:20 +02:00
Lukas Wirth
21a3d01875 Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
Lukas Wirth
e92646962a Move interior mutability into ProcMacroSrvProcess 2024-06-30 15:22:39 +02:00
Lukas Wirth
db15273d4d Move dylib version stuff to proc-macro-srv 2024-06-30 15:05:35 +02:00
Lukas Wirth
d4dc3ca83b Register virtual workspace Cargo.toml files in the VFS 2024-06-09 12:54:50 +02:00
Wilfred Hughes
27182bb96b chore: Prefer tracing span shorthand macros 2024-06-06 16:52:25 -07:00