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
Lukas Wirth
9767156a29
Simplify
2024-03-13 20:02:21 +01:00
Lukas Wirth
abe3177445
Shrink MacroCallLoc
2024-03-13 18:05:27 +01:00
Lukas Wirth
87e0bbc534
Stronger typing for macro_arg query
2024-03-13 17:42:01 +01:00
bors
a2e274142f
Auto merge of #16819 - Veykril:span-upmapping, r=Veykril
...
internal: Improve rooted upmapping
cc https://github.com/rust-lang/rust-analyzer/issues/16235
2024-03-12 12:58:52 +00:00
Lukas Wirth
9ba4493918
internal: Improve rooted upmapping
2024-03-12 13:46:58 +01:00
bors
d3e6fea315
Auto merge of #16789 - wyatt-herkamp:cfg_attr, r=Veykril
...
cfg Attribute Stripping for Proc Macro Expansion
This will attempt to process cfg attributes and cfg_attr attributes for proc macro expansion.
![image](https://github.com/rust-lang/rust-analyzer/assets/11785959/b85ef203-14a5-44c9-9b67-59a65a5f2d96 )
Closes #8434 , #11657 , and #13904
2024-03-12 10:19:19 +00:00
Wyatt Herkamp
447de3d788
Review Updates and added tests.
2024-03-11 11:05:59 -04:00
Wyatt Herkamp
0fb5d0d918
Check for cfg_attr on the actual item and Debug instead of info in cfg_process
2024-03-11 06:55:04 -04:00
Wyatt Herkamp
79f2651262
Add cfg_attr and cleanup code
2024-03-09 13:25:56 -05:00
Laurențiu Nicola
0f43b55e83
Stop using an Arc when setting the file text
2024-03-08 20:30:12 +02:00
Wyatt Herkamp
f45b080965
Starting Fix for cfg stripping
2024-03-08 11:10:29 -05:00
Lukas Wirth
09b9a921a8
fix: Don't invalid body query results when generating desugared names
2024-03-07 15:03:16 +01:00
Lukas Wirth
c04c0dd5ba
fix: Don't force draw a dependency edge to the real_span_map query
2024-03-07 14:14:59 +01:00
Lukas Wirth
bd0ffb0248
Remove accidental dependency between parse_macro_expansion
and parse
2024-03-07 11:16:40 +01:00
Lukas Wirth
c3c9f5ffe1
internal: Compute syntax validation errors on demand
2024-03-04 12:06:15 +01:00
Lukas Wirth
4303e741de
Cleanup
2024-03-04 11:10:06 +01:00
Laurențiu Nicola
dd21914e9d
Remove outdated comment about static SmolStrs
2024-03-02 10:56:03 +02:00
Lukas Wirth
efd76ecff1
Move AstIdMap infra to the span crate
2024-03-01 15:39:44 +01:00
Lukas Wirth
8a5bb9d5ac
Only the ROOT syntax context has None
outer_expn
2024-03-01 15:14:17 +01:00
Lukas Wirth
eb7a4f293e
minor: Add some basic docs for spans/hygiene handling
2024-03-01 14:39:15 +01:00
Lukas Wirth
b1404d387a
fix: Split toolchain and datalayout out of CrateData
2024-02-16 14:48:25 +01:00
Lukas Wirth
c00c9ee959
fix: Respect textual length of paths in find-path
2024-02-16 10:54:54 +01:00
Lukas Wirth
1e6cef94df
fix: Fix build scripts not being rebuilt in some occasions
2024-02-14 15:20:45 +01:00
Lukas Wirth
2fa57d90bc
internal: macro_arg query always returns a TokenTree
2024-02-12 17:19:41 +01:00
Lukas Wirth
e2a985e93f
Encode disabled proc-macros via boolean flag, not special Expander
2024-02-12 13:39:38 +01:00
tamasfe
6d45afd8d8
feat: ignored and disabled macro expansion
2024-02-12 12:50:40 +01:00
Lukas Wirth
5136705fad
internal: Remove SELF_REF hack for self referential SyntaxContexts
2024-02-10 16:20:02 +01:00
Tetsuharu Ohzeki
cb95ee3bc0
hir-def: Fix warnings about clippy str_to_string
rule
2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
7669619f9a
clippy: Enable self_named_constructors
rule
2024-02-09 22:31:21 +09:00
austaras
dad0fdb13f
fix: preserve where clause when builtin derive
2024-02-08 22:44:39 +08:00
GnomedDev
a607e1b04b
Use reserve_exact for pushing to Subtree
2024-02-04 22:17:20 +00:00
GnomedDev
8011b56827
Swap Subtree::token_trees from Vec to boxed slice
2024-02-04 00:28:22 +00:00
bors
8f6a72871e
Auto merge of #16469 - Young-Flash:ci_typos, r=lnicola
...
internal: add typos check CI (part 2)
follow up https://github.com/rust-lang/rust-analyzer/pull/16448
2024-02-02 12:02:48 +00:00
Young-Flash
ba2910a3a7
minor: correct some typos
2024-02-02 18:22:54 +08:00
Johann Hemmann
c4302eaa56
unnecessary_lazy_evaluations
2024-01-31 19:06:18 +01:00
Lukas Wirth
d252247ab7
internal: Remove unnecessary usages of ExpansionInfo
2024-01-31 09:57:17 +01:00
David Barsky
e1ea7c8844
internal: switch to tracing
from log
...
This commit also adds `tracing` to NotificationDispatcher/RequestDispatcher,
bumps `rust-analyzer-salsa` to 0.17.0-pre.6, `always-assert` to 0.2, and
removes the homegrown `hprof` implementation in favor of a vendored
tracing-span-tree.
2024-01-30 12:27:31 -05:00
Johann Hemmann
43b1ae0446
cargo clippy --fix
2024-01-30 14:50:21 +01:00
bors
11b401d0b4
Auto merge of #16447 - Veykril:mir-errors, r=Veykril
...
intenral: Cleanup error variants in MIR code a bit
2024-01-30 11:38:41 +00:00
bors
22b6f9679d
Auto merge of #16439 - wasd96040501:feat/gotodef3, r=Veykril
...
feat: Support for GOTO def from *inside* files included with include! macro
close #14937
Try to implement goto def from *inside* files included with include! macro.
This implementation has two limitations:
1. Only **one** file which calls include! will be tracked. (I think multiple file be included is a rare case and we may let it go for now)
2. Mapping token from included file to macro call file (semantics.rs:646~658) works fine but I am not sure is this the correct way to implement.
2024-01-30 11:27:18 +00:00
Lukas Wirth
5860763f18
Cleanup error variants in MIR code slightly
2024-01-30 09:53:39 +01:00
YangzeLuo
b22e772cab
feat: Support for GOTO def from *inside* files included with include! macro
2024-01-27 23:36:01 +08:00
Lukas Wirth
8a5829cf28
Re-order mod declarations
2024-01-27 11:02:34 +01:00
Lukas Wirth
6cf7b5f8d7
Don't parse intra doc links as syntax trees
2024-01-26 20:00:47 +01:00
Lukas Wirth
5a343415e8
Add some size assertions
2024-01-26 19:28:39 +01:00
Lukas Wirth
d8ef6c24cc
Cleanup convert_path
2024-01-26 19:28:39 +01:00
Lukas Wirth
880baa9e56
Shuffle hir-expand things around
2024-01-26 19:28:39 +01:00
Lukas Wirth
e320004dad
Remove tt -> ast -> tt round trips in attrs lowering
2024-01-26 19:28:39 +01:00
Johann Hemmann
3041164301
Temporarily allow all lints which occur
...
They will be removed one by one
2024-01-19 12:52:12 +01:00
Johann Hemmann
fad4fa163c
cargo clippy --fix
2024-01-18 13:59:49 +01:00
Lukas Wirth
83591268ab
minor: Make use of some new SmolStr
improvements
2024-01-17 13:47:15 +01:00
Lukas Wirth
d80d2fcae0
Eagerly lower enum variants in CrateDefMap construction
2024-01-15 10:24:14 +01:00
bors
9d8889cdfc
Auto merge of #16348 - Veykril:nested-includes, r=Veykril
...
fix: Fix nested includes resolving from the wrong base file
Fixes https://github.com/rust-lang/rust-analyzer/issues/16109
2024-01-11 11:53:24 +00:00
Lukas Wirth
215ede8497
fix: Fix nested includes resolving from the wrong base file
2024-01-11 12:41:47 +01:00
Lukas Wirth
b6e6d5d3af
internal: Consider all kinds of explicit private imports in find_path
2024-01-11 12:22:04 +01:00
bors
d5366b5c19
Auto merge of #16265 - Patryk27:suggest-pub-crate-imports, r=Veykril
...
fix: Acknowledge `pub(crate)` imports in import suggestions
rust-analyzer has logic that discounts suggesting `use`s for private imports, but that logic is unnecessarily strict - for instance given this code:
```rust
mod foo {
pub struct Foo;
}
pub(crate) use self::foo::*;
mod bar {
fn main() {
Foo$0;
}
}
```
... RA will suggest to add `use crate::foo::Foo;`, which not only makes the code overly verbose (especially in larger code bases), but also is disjoint with what rustc itself suggests.
This commit adjusts the logic, so that `pub(crate)` imports are taken into account when generating the suggestions; considering rustc's behavior, I think this change doesn't warrant any extra configuration flag.
Note that this is my first commit to RA, so I guess the approach taken here might be suboptimal - certainly feels somewhat hacky, maybe there's some better way of finding out the optimal import path 😅
2024-01-11 09:54:22 +00:00
Patryk Wychowaniec
76aaf17794
Suggest pub(crate)
imports
...
rust-analyzer has logic that discounts suggesting `use`s for private
imports, but that logic is unnecessarily strict - for instance given
this code:
```rust
mod foo {
pub struct Foo;
}
pub(crate) use self::foo::*;
mod bar {
fn main() {
Foo$0;
}
}
```
... RA will suggest to add `use crate::foo::Foo;`, which not only makes
the code overly verbose (especially in larger code bases), but also is
disjoint with what rustc itself suggests.
This commit adjusts the logic, so that `pub(crate)` imports are taken
into account when generating the suggestions; considering rustc's
behavior, I think this change doesn't warrant any extra configuration
flag.
Note that this is my first commit to RA, so I guess the approach taken
here might be suboptimal - certainly feels somewhat hacky, maybe there's
some better way of finding out the optimal import path 😅
2024-01-10 18:21:16 +01:00
Lukas Wirth
7dd9f20ce3
Builtin derives are hygienic
2024-01-08 12:50:11 +01:00
bors
9279c6566b
Auto merge of #16237 - Veykril:expand-arc-alloc, r=Veykril
...
internal: Remove unnecessary `Arc` allocations in `macro_expand`
2024-01-03 14:40:10 +00:00
Lukas Wirth
3fc043ce9b
internal: Remove unnecessary Arc allocations in macro_expand
2024-01-03 15:21:18 +01:00
Lukas Wirth
cf22f02dc5
fix: Fix focus range being discarded in attributes/derives when upmapping
2024-01-03 12:15:28 +01:00
bors
86e559bf3f
Auto merge of #16211 - tetsuharuohzeki:update-lint, r=Veykril
...
Use Cargo's [workspace.lints.*] to config clippy
This change begin to use [`[workspace.lints.*]`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-lints-table ) that is stabilized since [Rust 1.74](https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html ).
By this change, we make the configure more readable and simplify `xargo lint` more.
2024-01-02 14:53:22 +00:00
Lukas Wirth
0c3fbba3b9
fix: Fix SyntaxContextID using incorrect self IDs
2024-01-01 12:54:30 +01:00
HoLLy
c13330971d
Fix out-of-bounds panic in some macros due to unhandled self_ref
2023-12-31 12:51:43 +01:00
Tetsuharu Ohzeki
efc87092b3
Use Cargo's [workspace.lints.*] to config clippy
2023-12-29 23:51:32 +09:00
Lukas Wirth
9e8e124269
Special case fixup spans in server::Span impl, they are immutable
2023-12-22 10:13:00 +01:00
Lukas Wirth
874df3bffa
Add eager-expand comment
2023-12-21 17:23:36 +01:00
Lukas Wirth
428a34a9b4
Implement server::Span::Join
2023-12-21 17:23:04 +01:00
Lukas Wirth
5bdb479131
fix: Fix span marking for builtin fn macros
2023-12-21 16:20:27 +01:00
Lukas Wirth
1e1113cf5f
Correctly set and mark the proc-macro spans
2023-12-21 10:51:54 +01:00
Lukas Wirth
7d762d18ed
Record macro def site spans
2023-12-21 09:54:47 +01:00
Lukas Wirth
51a9e7831a
Rename some things and turn macro to macro def into a query
2023-12-21 09:18:25 +01:00
Lukas Wirth
071fe4e4e9
Move Intern and Lookup traits to hir-expand
2023-12-20 21:24:20 +01:00
Lukas Wirth
7b804552a5
Remove Delimiter::DUMMY_INVISIBLE
2023-12-20 14:00:14 +01:00
Lukas Wirth
2c6ce480e3
Remove Delimier::dummy_invisible
2023-12-20 13:06:46 +01:00
Lukas Wirth
4ec81230db
Remove usages of Span::DUMMY
2023-12-20 12:53:46 +01:00
Lukas Wirth
f48ecb6e09
Try to support pre and post-change metavars
2023-12-19 20:45:12 +01:00
Lukas Wirth
002e611d09
fix: Deduplicate annotations
2023-12-19 08:49:00 +01:00
Lukas Wirth
f49a2fed3f
internal: Move out WithFixture
into dev-dep only crate
2023-12-18 15:24:08 +01:00
Lukas Wirth
ec6162308e
Move the SpanMap definition into the span crate
2023-12-18 14:50:48 +01:00
Lukas Wirth
66e29be1bd
internal: Split out a span crate
2023-12-18 14:08:33 +01:00
Lukas Wirth
35620306a6
internal: Move proc-macro knowledge out of base-db
2023-12-18 12:37:18 +01:00
bors
a7764198b1
Auto merge of #16123 - Veykril:simplify, r=Veykril
...
internal: Remove `ModuleId` from `TypeOwnerId`
It only exists due to the IDE layer, but we can encode this temporary hack more cleanly
2023-12-15 13:10:17 +00:00
Lukas Wirth
4c45d23948
fix: Syntax fixup now removes subtrees with fake spans
2023-12-15 13:52:49 +01:00
Lukas Wirth
9083017c9d
Remove ModuleId
from TypeOwnerId
2023-12-14 14:11:57 +01:00
Lukas Wirth
c209b5f97c
fix: Fix syntax bridge assigning invalid span to lifetime tokens
2023-12-12 22:05:21 +01:00
Laurențiu Nicola
13d4609f50
Merge remote-tracking branch 'upstream/master' into sync-from-rust
2023-12-12 12:26:15 +02:00
hkalbasi
801c0ea478
Replace doc_comments_and_attrs
with collect_attrs
, 2nd round
2023-12-11 22:56:50 +03:30
Laurențiu Nicola
71d98c53bd
Fix typo in cfg
2023-12-11 11:55:43 +02:00
Laurențiu Nicola
f532576ac5
Merge commit '457b966b171b09a7e57acb710fbca29a4b3526f0' into sync-from-ra
2023-12-11 11:16:01 +02:00
Lukas Wirth
b1a8f83a0c
fix: Smaller spans for unresolved field and method diagnostics
2023-12-08 18:46:36 +01:00
bors
9c3de09f6d
Auto merge of #16054 - Veykril:fix-downmapping, r=Veykril
...
fix: Fix token downmapping being quadratic
Fixes https://github.com/rust-lang/rust-analyzer/issues/16050
2023-12-08 14:28:18 +00:00
Lukas Wirth
5d951a6a46
fix: Fix token downmapping being quadratic
2023-12-08 15:26:38 +01:00
Lukas Wirth
71337f6682
fix: Fix concat_bytes!
expansion
2023-12-08 11:34:03 +01:00
David Barsky
c17dcc8d90
internal: switch to Arc::from_iter
2023-12-06 13:08:45 -05:00
Lukas Wirth
80dc20f7d8
fix: Don't print proc-macro panic backtraces in the logs
2023-12-06 17:49:48 +01:00
Lukas Wirth
634d588fd7
Simplify
2023-12-06 14:36:39 +01:00
Lukas Wirth
9cb13b6efb
Allow navigation targets to be duplicated when the focus range lies in the macro definition site
2023-12-06 12:38:19 +01:00
Lukas Wirth
5b8e386bae
Improve macro descension API
2023-12-05 17:06:57 +01:00
Igor Matuszewski
a7224c998d
Don't explicitly warn against semicolon_in_expressions_from_macros
...
This has been warn-by-default for two years now and has already been
added to the future-incompat lints in 1.68.
2023-12-05 11:35:09 +01:00
Lukas Wirth
18f1a3c3c6
Some final touches
2023-12-03 20:20:59 +01:00
Lukas Wirth
81410ab500
Cleanup FileId stuff
2023-12-02 19:32:53 +01:00
Lukas Wirth
02a3a9438a
Some more minor cleanups
2023-12-02 17:04:13 +01:00
Lukas Wirth
5edf7bddc6
Fix mod item in included file resolving incorrectly
2023-12-02 13:49:09 +01:00
Lukas Wirth
d2a31acda1
Fix macro expansion expression parenthesis wrapping
2023-12-02 13:03:46 +01:00
Lukas Wirth
efa67294ed
Fix eager macro input spans being discarded
2023-12-01 16:29:58 +01:00
Lukas Wirth
c11737cd63
Simplify include handling
2023-12-01 14:58:57 +01:00
Lukas Wirth
0003e568ca
Pass calling span through to builtin macro expansions
2023-12-01 14:11:57 +01:00
Lukas Wirth
f48fa0c6cb
Re-implement syntax fixups
2023-11-29 16:00:39 +01:00
Lukas Wirth
7a8c4c001b
Turn macro_expand from query to normal function
2023-11-28 17:23:51 +01:00
Lukas Wirth
b98597f06d
Re-enable proc-macros
2023-11-28 16:28:56 +01:00
Lukas Wirth
98cfdde8ba
Thinner TokenMap
2023-11-28 10:56:25 +01:00
Lukas Wirth
92d447f976
🧹
2023-11-28 10:55:40 +01:00
Lukas Wirth
ab8f12e169
Rename hygiene vars and fields to span_map
2023-11-28 10:55:40 +01:00
Lukas Wirth
c43078f99d
Re-implement InFile wrappers as type aliases over generic InFileWrapper
2023-11-28 10:55:40 +01:00
Lukas Wirth
30093a6d81
spans always come from real file
2023-11-28 10:55:39 +01:00
Lukas Wirth
394d11b0fa
Fix float-split hack not setting up spans correctly
2023-11-28 10:55:39 +01:00
Lukas Wirth
05f375eae2
hygiene 2.0
2023-11-28 10:55:39 +01:00
Lukas Wirth
e36b3f7b8c
Proper span representation with syntax context
2023-11-28 10:55:39 +01:00
Lukas Wirth
890eb17b4e
Replace ID based TokenMap with proper relative text-ranges / spans
2023-11-28 10:55:39 +01:00
Laurențiu Nicola
59f5d51852
Merge commit '141fc695dca1df7cfc3c9803972ec19bb178dcbc' into sync-from-ra
2023-11-16 22:27:35 +02:00