aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src
Commit message (Collapse)AuthorAgeFilesLines
* Add even more docsAleksey Kladov2021-05-223-3/+6
|
* Merge #8560bors[bot]2021-04-182-3/+23
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8560: Escape characters in doc comments in macros correctly r=jonas-schievink a=ChayimFriedman2 Previously they were escaped twice, both by `.escape_default()` and the debug view of strings (`{:?}`). This leads to things like newlines or tabs in documentation comments being `\\n`, but we unescape literals only once, ending up with `\n`. This was hard to spot because CMark unescaped them (at least for `'` and `"`), but it did not do so in code blocks. This also was the root cause of #7781. This issue was solved by using `.escape_debug()` instead of `.escape_default()`, but the real issue remained. We can bring the `.escape_default()` back by now, however I didn't do it because it is probably slower than `.escape_debug()` (more work to do), and also in order to change the code the least. Example (the keyword and primitive docs are `include!()`d at https://doc.rust-lang.org/src/std/lib.rs.html#570-578, and thus originate from macro): Before: ![image](https://user-images.githubusercontent.com/24700207/115130096-40544300-9ff5-11eb-847b-969e7034e8a4.png) After: ![image](https://user-images.githubusercontent.com/24700207/115130143-9cb76280-9ff5-11eb-9281-323746089440.png) Co-authored-by: Chayim Refael Friedman <[email protected]>
| * Escape characters in doc comments in macros correctlyChayim Refael Friedman2021-04-182-3/+23
| | | | | | | | | | | | | | | | | | Previously they were escaped twice, both by `.escape_default()` and the debug view of strings (`{:?}`). This leads to things like newlines or tabs in documentation comments being `\\n`, but we unescape literals only once, ending up with `\n`. This was hard to spot because CMark unescaped them (at least for `'` and `"`), but it did not do so in code blocks. This also was the root cause of #7781. This issue was solved by using `.escape_debug()` instead of `.escape_default()`, but the real issue remained. We can bring the `.escape_default()` back by now, however I didn't do it because it is probably slower than `.escape_debug()` (more work to do), and also in order to change the code the least.
* | Handle extended key value attr in mbeEdwin Cheng2021-04-171-0/+18
| |
* | Make `ast_to_token_tree` infallibleJonas Schievink2021-04-045-22/+19
| | | | | | | | It could never return `None`, so reflect that in the return type
* | Allow include! an empty content fileEdwin Cheng2021-04-031-3/+0
| |
* | Allow `,` to delimit macro 2.0 rulesJonas Schievink2021-04-033-2/+30
|/
* a lot of clippy::style fixesMatthias Krüger2021-03-214-8/+7
|
* clippy::complexity simplifications related to IteratorsMatthias Krüger2021-03-211-2/+1
|
* Fix and test edge cases of `_` as identKevin Mehall2021-03-203-3/+13
|
* Make bare underscore token an Ident rather than Punct in proc-macroKevin Mehall2021-03-205-12/+15
|
* Reorganize mbe testsEdwin Cheng2021-03-183-1959/+1952
|
* don't clone types that are copy (clippy::clone_on_copy)Matthias Krüger2021-03-172-4/+3
|
* use if let Some(x) instead of if x.is_some() and x.unwrap() ↵Matthias Krüger2021-03-171-6/+6
| | | | (clippy::unnecessary-unwrap)
* avoid converting types into themselves via .into() (clippy::useless-conversion)Matthias Krüger2021-03-174-14/+12
| | | | example: let x: String = String::from("hello world").into();
* Fix macro expansion for statements w/o semicolonEdwin Cheng2021-03-161-6/+5
|
* some clippy::performance fixesMatthias Krüger2021-03-151-6/+2
| | | | | | | use vec![] instead of Vec::new() + push() avoid redundant clones use chars instead of &str for single char patterns in ends_with() and starts_with() allocate some Vecs with capacity to avoid unneccessary resizing
* Simpify mbe bindings builderEdwin Cheng2021-03-141-63/+57
|
* Make sure ill-form macro handle propelyEdwin Cheng2021-03-141-2/+5
|
* Merge #7994bors[bot]2021-03-133-67/+221
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7994: Speed up mbe matching in heavy recursive cases r=edwin0cheng a=edwin0cheng In some cases (e.g. #4186), mbe matching is very slow due to a lot of copy and allocation for bindings, this PR try to solve this problem by introduce a semi "link-list" approach for bindings building. I used this [test case](https://github.com/weiznich/minimal_example_for_rust_81262) (for `features(32-column-tables)`) to run following command to benchmark: ``` time rust-analyzer analysis-stats --load-output-dirs ./ ``` Before this PR : 2 mins After this PR: 3 seconds. However, for 64-column-tables cases, we still need 4 mins to complete. I will try to investigate in the following weeks. bors r+ Co-authored-by: Edwin Cheng <[email protected]>
| * Add bindings builder for speed up matchingEdwin Cheng2021-03-133-67/+221
| |
* | Use upstream cov-markLaurențiu Nicola2021-03-082-6/+5
|/
* Fix fail to parse :: for meta in mbeEdwin Cheng2021-03-051-1/+2
|
* Merge #7513bors[bot]2021-03-027-163/+578
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7513: NFA parser for mbe matcher r=matklad a=edwin0cheng Almost straight porting from rustc one, but a little bit slow :( ``` rust-analyzer analysis-stats -q . ``` From: ```log Database loaded: 636.11ms, 277minstr crates: 36, mods: 594, decls: 11527, fns: 9017 Item Collection: 10.99s, 60ginstr exprs: 249618, ??ty: 2699 (1%), ?ty: 2101 (0%), !ty: 932 Inference: 28.94s, 123ginstr Total: 39.93s, 184ginstr ``` To: ```log Database loaded: 630.90ms, 277minstr crates: 36, mods: 594, decls: 11528, fns: 9018 Item Collection: 13.70s, 77ginstr exprs: 249482, ??ty: 2699 (1%), ?ty: 2101 (0%), !ty: 932 Inference: 30.27s, 133ginstr Total: 43.97s, 211ginstr ``` Fixes #4777 Co-authored-by: Edwin Cheng <[email protected]>
| * NFA parser for mbe matcherEdwin Cheng2021-02-287-163/+578
| |
* | Remove redundant semicolonDániel Buga2021-03-011-1/+1
|/
* Fix non-latin characters doc comment for mbeEdwin Cheng2021-02-282-1/+24
|
* Fix builtin macros split exprs on commaEdwin Cheng2021-02-284-69/+119
|
* Add benchmark test for mbeEdwin Cheng2021-02-242-0/+214
|
* Simpilfy mbe parsingEdwin Cheng2021-01-304-74/+71
|
* Simplify mbe match error.Edwin Cheng2021-01-296-210/+180
| | | | Handle parse error in rule parsing instead of match in mbe
* Rename mbe_expander for consistencyEdwin Cheng2021-01-294-5/+5
|
* Support Macro v2 in mbeEdwin Cheng2021-01-253-87/+227
|
* :arrow_up: rowanAleksey Kladov2021-01-201-3/+1
| | | | It now stores text inline with tokens
* .Aleksey Kladov2021-01-191-1/+1
|
* Reduce TokenMap sizeEdwin Cheng2021-01-191-10/+16
|
* shrink_to_fit `TokenMap`'s backing storageJonas Schievink2021-01-181-1/+3
|
* Swap assert_eq_text\!(expected, actual)yugo-horie2021-01-161-5/+5
|
* Merge #7211bors[bot]2021-01-141-1/+22
|\ | | | | | | | | | | | | | | | | | | | | | | 7211: Fixed expr meta var after path colons in mbe r=matklad a=edwin0cheng Fixes #7207 Added `L_DOLLAR` in `ITEM_RECOVERY_SET` , but I don't know whether it is a good idea. r? @matklad Co-authored-by: Edwin Cheng <[email protected]>
| * Fixed expr meta var after path colons in mbeEdwin Cheng2021-01-101-1/+22
| |
* | Fixed typos in public type namesVincent Esche2021-01-091-2/+2
| |
* | Fixed typos in private type namesVincent Esche2021-01-091-5/+5
| |
* | Fixed typos in testsVincent Esche2021-01-091-1/+1
| |
* | Fixed typos in `log::warn!` messageVincent Esche2021-01-091-5/+1
| |
* | Fixed typos in code commentsVincent Esche2021-01-093-3/+3
|/
* Add testEdwin Cheng2021-01-081-0/+13
|
* Fix bug when $crate in LHS in mbeEdwin Cheng2021-01-082-5/+8
|
* Merge #7145bors[bot]2021-01-083-19/+14
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7145: Proper handling $crate Take 2 [DO NOT MERGE] r=edwin0cheng a=edwin0cheng Similar to previous PR (#7133) , but improved the following things : 1. Instead of storing the whole `ExpansionInfo`, we store a similar but stripped version `HygieneInfo`. 2. Instread of storing the `SyntaxNode` (because every token we are interested are IDENT), we store the `TextRange` only. 3. Because of 2, we now can put it in Salsa. 4. And most important improvement: Instead of computing the whole frames every single time, we compute it recursively through salsa: (Such that in the best scenario, we only need to compute the first layer of frame) ```rust let def_site = db.hygiene_frame(info.def.file_id); let call_site = db.hygiene_frame(info.arg.file_id); HygieneFrame { expansion: Some(info), local_inner, krate, call_site, def_site } ``` The overall speed compared to previous PR is much faster (65s vs 45s) : ``` [WITH old PR] Database loaded 644.86ms, 284mi Crates in this dir: 36 Total modules found: 576 Total declarations: 11153 Total functions: 8715 Item Collection: 15.78s, 91562mi Total expressions: 240721 Expressions of unknown type: 2635 (1%) Expressions of partially unknown type: 2064 (0%) Type mismatches: 865 Inference: 49.84s, 250747mi Total: 65.62s, 342310mi rust-analyzer -q analysis-stats . 66.72s user 0.57s system 99% cpu 1:07.40 total [WITH this PR] Database loaded 665.83ms, 284mi Crates in this dir: 36 Total modules found: 577 Total declarations: 11188 Total functions: 8743 Item Collection: 15.28s, 84919mi Total expressions: 241229 Expressions of unknown type: 2637 (1%) Expressions of partially unknown type: 2064 (0%) Type mismatches: 868 Inference: 30.15s, 135293mi Total: 45.43s, 220213mi rust-analyzer -q analysis-stats . 46.26s user 0.74s system 99% cpu 47.294 total ``` *HOWEVER*, it is still a perf regression (35s vs 45s): ``` [WITHOUT this PR] Database loaded 657.42ms, 284mi Crates in this dir: 36 Total modules found: 577 Total declarations: 11177 Total functions: 8735 Item Collection: 12.87s, 72407mi Total expressions: 239380 Expressions of unknown type: 2643 (1%) Expressions of partially unknown type: 2064 (0%) Type mismatches: 868 Inference: 22.88s, 97889mi Total: 35.74s, 170297mi rust-analyzer -q analysis-stats . 36.71s user 0.63s system 99% cpu 37.498 total ``` Co-authored-by: Edwin Cheng <[email protected]>
| * Proper handling $crate Take 2Edwin Cheng2021-01-073-19/+14
| |
* | Simplify SubtreeTokenSourceEdwin Cheng2021-01-041-88/+60
| |