Lukas Wirth
ada65feaa1
Improve proc-macro panic message and workspace loading failure diagnostic
2024-08-22 18:46:23 +02:00
Lukas Wirth
c2a07e21f5
Thread file id through descension API for semantic highlighting
2024-08-22 16:45:37 +02:00
Lukas Wirth
f979667fb5
Remove DescendPreference::SameText
2024-08-22 12:34:20 +02:00
Lukas Wirth
d44a3ab30c
internal: Implement module_path
macro
2024-08-21 13:50:05 +02:00
Chayim Refael Friedman
9d3368f2c2
Properly account for editions in names
...
This PR touches a lot of parts. But the main changes are changing
`hir_expand::Name` to be raw edition-dependently and only when necessary
(unrelated to how the user originally wrote the identifier),
and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware
(this was done in #17896 , but the FIXMEs were fixed here).
It is possible that I missed some cases, but most IDE parts should properly
escape (or not escape) identifiers now.
The rules of thumb are:
- If we show the identifier to the user, its rawness should be determined
by the edition of the edited crate. This is nice for IDE features,
but really important for changes we insert to the source code.
- For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update
tests when an edition becomes stable, to avoid churn).
- For debugging tools (helper methods and logs), I used `Edition::LATEST`.
2024-08-16 16:46:24 +03:00
Lukas Wirth
f90bdfc13d
internal: Properly check the edition for edition dependent syntax kinds
2024-08-15 15:57:47 +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
bors
fbed308ebe
Auto merge of #17799 - Veykril:syntax-bridge, r=Veykril
...
Split out syntax-bridge into a separate crate
This functionality is not really tied to mbe macros, so imo it has no place in that crate.
2024-08-05 12:31:45 +00:00
Lukas Wirth
d2dd4f6d5f
Split out syntax-bridge into a separate crate
2024-08-05 13:45:00 +02:00
Lukas Wirth
fcb88832de
Simplify FileDelegate
2024-08-05 13:03:03 +02:00
Lukas Wirth
ad71abb9ad
fix: Fix builtin includes rejecting raw string literals
2024-07-30 08:19:32 +02:00
Lukas Wirth
fab30c45cb
Add missing doc string
2024-07-29 16:05:21 +02:00
Lukas Wirth
d46060b168
Fix error spans for include! and compile_error!
2024-07-29 15:57:01 +02:00
Lukas Wirth
ae9c553902
Make basic use of spans for macro expansion errors
2024-07-29 14:52:40 +02:00
Lukas Wirth
7beac14cba
Internal: Cleanup proc-macro error handling
2024-07-26 14:38:19 +02:00
Lukas Wirth
df15b6f668
fix: Fix includes not working with expr fragment inputs
2024-07-26 10:12:06 +02:00
Lukas Wirth
bd359b32b0
LRU body_with_source_map
query
2024-07-22 16:34:59 +02:00
Lukas Wirth
1141c35a4b
Make CfgExpr
slimmer
2024-07-21 14:50:44 +02:00
bors
b333f85a9d
Auto merge of #17639 - Veykril:salsa-perf, r=Veykril
...
Some more small salsa memory improvements
This does limit our lru limits to 2^16 but if you want to set them higher than that you might as well not set them at all. Also makes `LRU` opt-in per query now, allowing us to drop all the unnecessary LRU stuff for most queries
2024-07-19 18:45:16 +00:00
Lukas Wirth
92f5e806f1
Fix edition used for include macro parsing
2024-07-19 20:29:53 +02:00
Lukas Wirth
6d4989b3c7
Make LRU opt-in
2024-07-19 18:38:08 +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
e75dbe52a1
Don't call macro_arg directly in ExpandDatabase::syntax_context
2024-07-16 22:10:42 +02:00
Lukas Wirth
2346a80ab4
Remove Name::to_smol_str
2024-07-16 12:43:58 +02:00
Lukas Wirth
df5f1777b8
More symbol usage
2024-07-16 12:05:16 +02:00
Lukas Wirth
c30bdfcc84
Use symbol in cfg
2024-07-16 10:41:42 +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
dcfda55c82
Escape fetched env vars in env! expansion
2024-07-15 13:08:29 +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
f2d51073d2
Use statics + clone instead of const until const can access statics
2024-07-14 17:52:59 +02:00
Lukas Wirth
3fe815b0f3
Use Symbol in Name
2024-07-12 16:06:44 +02:00
Laurențiu Nicola
bd6de0cb57
Merge from rust-lang/rust
2024-07-11 20:06:05 +03:00
beetrees
d5db933f9d
Add f16
and f128
support
2024-07-10 10:43:14 +01:00
Lukas Wirth
013b6a883f
Fix up the syntax tree for macro 2.0
2024-07-03 10:41:19 +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
5374ebbf36
Simplify
2024-06-30 14:00:55 +02:00
Lukas Wirth
bfb187aacd
Fix expression scope calculation when within macro expansions
2024-06-30 13:26:17 +02:00
xFrednet
770b139a1a
RFC 2383: Stabilize lint_reasons
🎉
2024-06-25 17:22:22 +02:00
Lukas Wirth
8df034d453
Shrink mbe's Op
2024-06-24 10:07:32 +02:00
Wyatt Herkamp
f51b161568
Check that Expr is none before adding fixup
2024-06-20 08:55:05 -04:00
bors
e08f7953f4
Auto merge of #17462 - Veykril:sema-attr-macro-res, r=Veykril
...
fix: Fix IDE features breaking in some attr macros
Fixes https://github.com/rust-lang/rust-analyzer/issues/17453 , Fixes https://github.com/rust-lang/rust-analyzer/issues/17458
2024-06-20 09:11:44 +00:00
Lukas Wirth
ee8a3458ee
fix: Fix IDE features breaking in some attr macros
2024-06-20 11:00:19 +02:00
bors
7b38f8ab12
Auto merge of #17439 - Veykril:paralleler-prime-caches, r=Veykril
...
Properly prime all crate def maps in parallel_prime_caches
2024-06-17 15:58:09 +00:00
Lukas Wirth
158626bed4
Add some more syntax fixup rules
2024-06-17 13:10:56 +02:00
bors
6b8b8ff4c5
Auto merge of #17417 - Wilfred:intern_macros_salsa, r=Veykril
...
refactor: Prefer plain trait definitions over macros for impl_intern_value_trivial
`impl_intern_value_trivial` can be defined with a trait directly, so prefer that over a macro definition.
2024-06-14 06:20:26 +00:00
Wilfred Hughes
3874681cb6
Prefer plain trait definitions over macros for salsa
2024-06-13 17:32:06 -07:00
Wilfred Hughes
d68e549205
internal: Fix rustdoc warnings
...
`cargo doc` generates a bunch of warnings on rust-analyzer. Fix all the
bare URL and empty code block warnings.
2024-06-13 17:29:10 -07:00
bors
22648b2655
Auto merge of #17405 - Veykril:modpath-clone, r=Veykril
...
internal: Don't unnecessarily clone ModPaths in early name res
2024-06-12 09:27:49 +00:00
Lukas Wirth
855282fa53
internal: Don't unnecessarily clone ModPaths in early name res
2024-06-12 11:25:19 +02:00
Lukas Wirth
8ebabce475
internal: Remove FileId::BOGUS
2024-06-12 08:16:07 +02:00
Lukas Wirth
2328085a79
Don't intern attribute inputs as their spans make them unique
2024-06-09 21:21:33 +02:00
Wilfred Hughes
27182bb96b
chore: Prefer tracing span shorthand macros
2024-06-06 16:52:25 -07:00
Lukas Wirth
7d40763c88
Cache parse trees in Semantics
2024-06-04 15:29:24 +02:00
Lukas Wirth
97b58f2846
Try caching macro calls more aggressively
2024-06-04 15:23:00 +02:00
Lukas Wirth
6f0207d594
Cleanup some inert attribute stuff
2024-06-04 12:38:20 +02:00
Lukas Wirth
60fa981df1
Simplify
2024-06-03 19:06:58 +02:00
Lukas Wirth
c0171bdd32
fix: Fix container search failing for tokens originating within derive attributes
2024-06-01 20:57:29 +02:00
bors
b98690ba74
Auto merge of #17221 - Veykril:lazier-validation, r=Veykril
...
internal: Lazier macro parse tree validation
2024-05-13 15:16:46 +00:00
Lukas Wirth
caddcccea5
parse_macro_expansion_error
almost never contains values so Option
it
2024-05-13 17:02:08 +02:00
Lukas Wirth
56552f4839
Push macro-parsing error calculation out of fundamental queries
2024-05-13 16:56:26 +02:00
Lukas Wirth
a39c0493a1
Render literal escaping errors in hovers
2024-05-13 12:51:57 +02:00
Lukas Wirth
e1aeed3aed
Implement unsafe attribute parsing
2024-05-06 12:11:29 +02:00
Lukas Wirth
36c1c77cf9
fix: Fix doc comment desugaring for proc-macros
2024-04-27 13:30:51 +02:00
Laurențiu Nicola
4c94e69115
Add in-rust-tree feature to hir-expand
2024-04-20 18:44:27 +03:00
roife
3e232bb78a
fix: replace unescape fn with the one in ra-ap-rustc_lexer
2024-04-19 20:32:53 +08:00
roife
a543516ea4
fix: handle escaped chars in doc comments
2024-04-19 14:57:37 +08:00
Lukas Wirth
4135696ea7
Cleanup
2024-04-18 11:00:22 +02:00
Lukas Wirth
6bfdd38c69
Render matched macro arm on hover of macro calls
2024-04-18 10:51:58 +02:00
Lukas Wirth
a483d3bc37
internal: Thread edition through to parsing/tt-to-syntax-tree routines for macros
2024-04-14 16:02:38 +02:00
Lukas Wirth
83370fe5d7
Use Edition::CURRENT
2024-04-14 15:30:29 +02:00
Johann Hemmann
2cf5d8811a
Raise edition one more level
2024-04-14 15:11:33 +02:00
Lukas Wirth
2b62d4b2ba
Fix some cfg censoring bugs
2024-04-03 16:43:08 +02:00
Lukas Wirth
8e324e98a1
Rename ProcMacroKind::FuncLike to Bang
2024-03-22 11:20:56 +01:00
roife
0e8170e846
fix: handle self::super in lowering of UseTree
2024-03-22 15:36:00 +08:00
bors
16c8deeb86
Auto merge of #16835 - wyatt-herkamp:use_one_tt_for_a_derive, r=Veykril
...
Have Derive Attribute share a token tree with it's proc macros.
The goal of this PR is to stop creating a token tree for each derive proc macro.
This is done by giving the derive proc macros an id to its parent derive element.
From running the analysis stat on the rust analyzer project I did see a small memory decrease.
```
Inference: 42.80s, 362ginstr, 591mb
MIR lowering: 8.67s, 67ginstr, 291mb
Mir failed bodies: 18 (0%)
Data layouts: 85.81ms, 609minstr, 8mb
Failed data layouts: 135 (6%)
Const evaluation: 440.57ms, 5235minstr, 13mb
Failed const evals: 1 (0%)
Total: 64.16s, 552ginstr, 1731mb
```
After Change
```
Inference: 40.32s, 340ginstr, 593mb
MIR lowering: 7.95s, 62ginstr, 292mb
Mir failed bodies: 18 (0%)
Data layouts: 87.97ms, 591minstr, 8mb
Failed data layouts: 135 (6%)
Const evaluation: 433.38ms, 5226minstr, 14mb
Failed const evals: 1 (0%)
Total: 60.49s, 523ginstr, 1680mb
```
Currently this breaks the expansion for the actual derive attribute.
## TODO
- [x] Pick a better name for the function `smart_macro_arg`
2024-03-21 18:04:38 +00:00
Wyatt Herkamp
c381d0fc64
Review Updates
2024-03-21 13:41:46 -04:00
Wyatt Herkamp
262e06f1ef
Remove MacroCallKind::DeriveAttr
2024-03-21 12:50:58 -04:00
Wyatt Herkamp
70f5344deb
macro_arg_considering_derives is now in ExpandDatabase and now takes in the MacroCallKind
2024-03-21 08:07:54 -04:00
Wyatt Herkamp
2c2bbe07fd
Treat Derive Macro specially.
2024-03-21 08:07:54 -04:00
Wyatt Herkamp
4bd2f948bb
Formatting
2024-03-21 08:07:54 -04:00
Wyatt Herkamp
f499564d0a
censor attribute derive
2024-03-21 08:06:43 -04:00
Wyatt Herkamp
15d183be79
Initial Attempt limiting number of token tree in macro expansion.
2024-03-21 08:06:43 -04:00
Lukas Wirth
0036762b9d
Make use of ThinArc
in RawAttrs
2024-03-21 11:49:09 +01:00
Lukas Wirth
928d847cc2
Keep the span for Attr::Literal
2024-03-21 10:28:25 +01:00
Lukas Wirth
6d1071962f
Resolve whether $pat is $pat_param or not via 🌟 hygiene 🌟
2024-03-21 10:22:45 +01:00
Lukas Wirth
7e88fa5d3a
Remove span generics from most of the mbe crate
2024-03-21 10:21:44 +01:00
Lukas Wirth
255a8aef92
Move Edition into span crate
2024-03-21 10:21:44 +01:00
goodmost
d6b0aae019
chore: remove repetitive words
...
Signed-off-by: goodmost <zhaohaiyang@outlook.com>
2024-03-19 22:14:13 +08:00
Lukas Wirth
0dd89d7ee7
Remove usages of SpanData where Span suffices
2024-03-15 13:02:40 +01:00
Lukas Wirth
b59c8c76db
Repalce Span with SyntaxContextId in MacroCallLoc
2024-03-15 12:47:05 +01:00
Lukas Wirth
08327e0e5d
Drop eager macro parse errors, they can't crop up
2024-03-15 11:45:51 +01:00
Lukas Wirth
3b1ad2379d
internal: Make def site span for proc-macro more invalidation resistant
2024-03-15 10:14:00 +01:00
Lukas Wirth
c50c4f8bbb
internal: Use assoc items as anchors for spans
2024-03-15 09:28:39 +01:00
Lukas Wirth
d085ade631
Remove dead test code
2024-03-14 16:24:51 +01:00
Lukas Wirth
d2f8eae2ec
feat: Support macro calls in eager macros for IDE features
2024-03-14 15:40:35 +01:00