about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/hir
AgeCommit message (Collapse)AuthorLines
2024-10-22Merge pull request #18254 from ChayimFriedman2/fix-mutLukas Wirth-110/+111
fix: Nail destructuring assignment once and for all
2024-10-22Auto merge of #18370 - duncpro:goto-def-ranges, r=Veykrilbors-0/+27
feat: resolve range patterns to their structs Closes #18367
2024-10-22tidyDuncan Proctor-2/+1
2024-10-22resolve range patterns to the their struct typesDuncan Proctor-0/+28
2024-10-22Fix new nightly lintsLukas Wirth-1/+1
2024-10-22Auto merge of #18362 - duncpro:goto-def-ranges, r=Veykrilbors-8/+36
feat: goto definition on range operators Closes #18342
2024-10-22tidyDuncan Proctor-1/+1
2024-10-22goto definition on RangeFrom, RangeFull, RangeTo, and RangeToInclusive links ↵Duncan Proctor-3/+11
to respective struct
2024-10-21Move explicit range handling out of goto_definition, use OperatorClass insteadduncanproctor-8/+28
2024-10-21fix: Fix token downmapping failing for include! inputsLukas Wirth-26/+54
2024-10-20Store patterns desugared from destructuring assignments in source mapChayim Refael Friedman-99/+102
And few more fixups. I was worried this will lead to more memory usage since `ExprOrPatId` is double the size of `ExprId`, but this does not regress `analysis-stats .`. If this turns out to be a problem, we can easily use the high bit to encode this information.
2024-10-20Handle destructuring assignments uniformlyChayim Refael Friedman-12/+10
Instead of lowering them to `<expr> = <expr>`, then hacking on-demand to resolve them, we lower them to `<pat> = <expr>`, and use the pattern infrastructure to handle them. It turns out, destructuring assignments are surprisingly similar to pattern bindings, and so only minor modifications are needed. This fixes few bugs that arose because of the non-uniform handling (for example, MIR lowering not handling slice and record patterns, and closure capture calculation not handling destructuring assignments at all), and furthermore, guarantees we won't have such bugs in the future, since the programmer will always have to explicitly handle `Expr::Assignment`. Tests don't pass yet; that's because the generated patterns do not exist in the source map. The next commit will fix that.
2024-10-04Auto merge of #18227 - davidbarsky:davidbarsky/push-lmntvwvznyyx, r=davidbarskybors-1/+1
internal: add json `tracing` Layer for profiling startup On `buck2/integrations/rust-project`, this results in the following being printed: ```json {"name":"discover_command","elapsed_ms":18703} {"name":"parallel_prime_caches","elapsed_ms":0} {"name":"vfs_load","elapsed_ms":5895} {"name":"vfs_load","elapsed_ms":547} {"name":"parallel_prime_caches","elapsed_ms":23} {"name":"parallel_prime_caches","elapsed_ms":84} {"name":"parallel_prime_caches","elapsed_ms":5819} ```
2024-10-04internal: add JSON formatting for hprofDavid Barsky-1/+1
2024-10-04Auto merge of #18234 - Veykril:veykril/push-vzynqtlxmrnl, r=Veykrilbors-42/+58
internal: Filter out opaque tokens in some IDE feature macro descensions
2024-10-04internal: Filter out opaque tokens in some of IDE feature macro descensionsLukas Wirth-42/+58
2024-10-01Fix: Handle block exprs as modules when finding their parentsShoyu Vanilla-3/+2
2024-09-30Auto merge of #18210 - ChayimFriedman2:label-macro, r=Veykrilbors-24/+22
fix: Fix resolution of label inside macro When working on Something Else (TM) (I left a hint in the commits :P), I noticed to my surprise that labels inside macros are not resolved. This led to a discovery of *two* unrelated bugs, which are hereby fixed in two commits.
2024-09-30When resolving labels in `break` and `continue` for the IDE, do not resolve ↵Chayim Refael Friedman-24/+22
them textually, instead reuse the results of HIR lowering This fixes a bug where labels inside macros were not resolved, but more importantly this prepares us to a future where we have hygiene, and textual equivalence isn't enough to resolve identifiers.
2024-09-29Rename object_safety to dyn_compatibilityNoah Bright-3/+3
Up to a trait implemented by another package, linking to $CARGO_HOME/registry/cache/index.crates.io-6f17d22bba15001f/
2024-09-19Handle lint attributes that are under `#[cfg_attr]`Chayim Refael Friedman-0/+13
2024-09-18Auto merge of #18131 - ChayimFriedman2:macro-expand-dollar-crate, r=Veykrilbors-1/+1
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-18Get rid of `$crate` in expansions shown to the userChayim Refael Friedman-1/+1
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-18Auto merge of #18117 - ChayimFriedman2:issue-18089, r=Veykrilbors-31/+29
fix: Always cache macro expansions' root node in Semantics Previously some expansions were not cached, but were cached in the expansion cache, which caused panics when later queries tried to lookup the node from the expansion cache. Fixes #18089.
2024-09-18Add diagnostics for `unsafe_op_in_unsafe_fn`Chayim Refael Friedman-2/+5
Turns out it's pretty easy, but I did have to add support for allowed-by-default lints.
2024-09-17Always cache macro expansions' root node in SemanticsChayim Refael Friedman-31/+29
Previously some expansions were not cached, but were cached in the expansion cache, which caused panics when later queries tried to lookup the node from the expansion cache.
2024-09-16Fix printing of constants greater than `i128::MAX`Chayim Refael Friedman-3/+9
2024-09-12Use more correct handling of lint attributesChayim Refael Friedman-2/+43
The previous analysis was top-down, and worked on a single file (expanding macros). The new analysis is bottom-up, starting from the diagnostics and climbing up the syntax and module tree. While this is more efficient (and in fact, efficiency was the motivating reason to work on this), unfortunately the code was already fast enough. But luckily, it also fixes a correctness problem: outline parent modules' attributes were not respected for the previous analysis. Case lints specifically did their own analysis to accommodate that, but it was limited to only them. The new analysis works on all kinds of lints, present and future. It was basically impossible to fix the old analysis without rewriting it because navigating the module hierarchy must come bottom-up, and if we already have a bottom-up analysis (including syntax analysis because modules can be nested in other syntax elements, including macros), it makes sense to use only this kind of analysis. Few other bugs (not fundamental ti the previous analysis) are also fixed, e.g. overwriting of lint levels (i.e. `#[allow(lint)] mod foo { #[warn(lint)] mod bar; }`.
2024-09-11Auto merge of #18075 - roife:fix-issue-17858, r=Veykrilbors-5/+8
feat: render patterns in params for hovering Fix #17858 This PR introduces an option to [hir-def/src/body/pretty.rs](https://github.com/rust-lang/rust-analyzer/blob/08c7bbc2dbe4dcc8968484f1a0e1e6fe7a1d4f6d/crates/hir-def/src/body/pretty.rs) to render the result as a single line, which is then reused for rendering patterns in parameters for hovering.
2024-09-11Auto merge of #18052 - Coekjan:fix-inline-const, r=Veykrilbors-0/+11
fix: Fix `inline_const_as_literal` error when the number >= 10 ## Description ### The Bug This PR fixes a small bug in the IDE assistence (`inline_const_as_literal`). When the being-inlined constant is a number and it is greater than or equal to 10, the assistence inserts unexpected string `(0x...)` after the number itself. A simple example is followed: Current `inline_const_as_literal` changes ```rs const A: usize = 16; fn f() -> usize { A // inline the constant } ``` into ```rs const A: usize = 16; fn f() -> usize { 16 (0x10) } ``` The bug originates from #14925 & #15306 . #14925 added some unittests, but it just tested the number-inlining behavior when the number is `0`. https://github.com/rust-lang/rust-analyzer/blob/50882fbfa204027c84753e6d51a1a12884dc1b19/crates/ide-assists/src/handlers/inline_const_as_literal.rs#L124-L138 And #15306 modified the behavior of `Const::render_eval` and added the `(0x...)` part after the number (if the number >= `10`). Because of insufficient unittests in #14925, changes about `Const::render_eval` in #15306 introduced this bug with no CI failure. ### The Fix I think `Const::render_eval` is intended for user-facing value displaying (e.g. hover) and not designed for `inline_const_as_literal`. To fix the bug, I defined a new function named `Const::eval`, which evaluates the value itself faithfully and simply and does nothing else. ## Thanks Thanks `@roife` for your kind help. Your guidance helped me better understand the code.
2024-09-09fix: use `pretty_print_pat` for params in fnroife-5/+8
2024-09-05asm! parsing and lowering fixesLukas Wirth-3/+8
2024-09-05Fix name fetching being incorrect for asm operandsLukas Wirth-11/+8
2024-09-05Support more IDE features for asm operandsLukas Wirth-6/+45
2024-09-05Give InlineAsmOperand a HIR representationLukas Wirth-21/+100
2024-09-05Lower asm expressionsLukas Wirth-1/+0
2024-09-05fix: Fix `inline_const_as_literal` error when the number >= 10coekjan-0/+11
2024-09-03feat: Implement cast typechecksShoyu Vanilla-2/+30
2024-09-02Auto merge of #18016 - IvarWithoutBones:wrap-return-ty-local-result, r=Veykrilbors-3/+14
fix: use Result type aliases in "Wrap return type in Result" assist This commit makes the "Wrap return type in Result" assist prefer type aliases of standard library type when the are in scope, use at least one generic parameter, and have the name `Result`. The last restriction was made in an attempt to avoid false assumptions about which type the user is referring to, but that might be overly strict. We could also do something like this, in order of priority: * Use the alias named "Result". * Use any alias if only a single one is in scope, otherwise: * Use the standard library type. This is easy to add if others feel differently that is appropriate, just let me know. Fixes #17796
2024-09-02chore: fix some commentscuishuang-1/+1
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-02fix: use Result type aliases in "Wrap return type in Result" assistIvar Scholten-3/+14
This commit makes the "Wrap return type in Result" assist prefer type aliases of standard library type when the are in scope, use at least one generic parameter, and have the name "Result". The last restriction was made in an attempt to avoid false assumptions about which type the user is referring to, but that might be overly strict. We could also do something like this, in order of priority: * Use the alias named "Result". * Use any alias if only a single one is in scope, otherwise: * Use the standard library type. This is easy to add if others feel differently that is appropriate, just let me know.
2024-09-01Auto merge of #17967 - Veykril:mbe-tests, r=Veykrilbors-0/+1
internal: Lay basic ground work for standalone mbe tests Most of our mbe hir-def tests don't actually do anything name res relevant, we can (and should) move those down the stack into `mbe/hir-expand`.
2024-09-01internal: Lay basic ground work for standalone mbe testsLukas Wirth-0/+1
2024-09-01Complete desugared and resugared async fn in trait implsLukas Wirth-31/+13
2024-09-01feat(ide-completion): extra sugar auto-completion `async fn ...` in `impl ↵Yunfei-0/+47
trait` for `async fn in trait` that's defined in desugar form
2024-08-29Auto merge of #17814 - ShoyuVanilla:object-safety, r=Veykrilbors-1/+6
feat: Implement object safety and its hovering hint Resolves #17779 - [x] Fill missing implementations - [x] Hover rendering - [x] Implement object safety's own test suite, like layout - [x] Add test cases (from rustc maybe) - [x] Clean up ugly codes - [x] Add doc string
2024-08-29feat: Implement object safetyShoyu Vanilla-1/+6
2024-08-29Auto merge of #17940 - ChayimFriedman2:closure-to-fn, r=Veykrilbors-0/+87
feat: Create an assist to convert closure to freestanding fn The assist converts all captures to parameters. Closes #17920. This was more work than I though, since it has to handle a bunch of edge cases... Based on #17941. Needs to merge it first.
2024-08-27Create an assist to convert closure to freestanding fnChayim Refael Friedman-0/+87
The assist converts all captures to parameters.
2024-08-27Revert "feat: Implement `module_path` macro"Lukas Wirth-37/+9