about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-09-12Auto merge of #18105 - Veykril:push-rquxwznuuwpu, r=Veykrilbors-28/+24
fix: Faulty notifications should not bring down the server Fixes https://github.com/rust-lang/rust-analyzer/issues/18055, if a client sends us an unregistered document path in a did save notification it would force us to exit the thread. That is obviously not great behavior, we should be more fallible here
2024-09-12fix: Faulty notifications should not bring down the serverLukas Wirth-28/+24
2024-09-12Auto merge of #18101 - ChayimFriedman2:inference-fix, r=Veykrilbors-9/+51
fix: Fix inference of literals when the expectation is Castable I followed the compiler: https://github.com/rust-lang/rust/blob/5bce6d48ff09dcb2613278ec93013795718478ef/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs#L1560-L1579. Fixes #18095.
2024-09-12Fix inference of literals when the expectation is CastableChayim Refael Friedman-9/+51
I followed the compiler: https://github.com/rust-lang/rust/blob/5bce6d48ff09dcb2613278ec93013795718478ef/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs#L1560-L1579.
2024-09-11Auto merge of #18075 - roife:fix-issue-17858, r=Veykrilbors-24/+303
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 #18080 - Veykril:dedup, r=Veykrilbors-19760/+133
Remove crate graph deduplication logic Fixes https://github.com/rust-lang/rust-analyzer/issues/17748
2024-09-11Auto merge of #18078 - cuishuang:master, r=Veykrilbors-3/+5
Remove unnecessary symbols and add missing symbols
2024-09-11Auto merge of #18050 - rust-lang:davidbarsky/push-uyvtlsvoqrxw, r=Veykrilbors-0/+0
assist: ensure `replace_qualified_name_with_use` applies to the first path segment This change helps a bit with the discoverability of `replace_qualified_name_with_use`. Specifically, it ensures that a cursor on the first path segment (e.g., `$0std::fmt::Debug`, where `$0` is the cursor) would result in an import along the lines of `use std::fmt;` and `fmt::Debug;` at the usage sites.
2024-09-11Auto merge of #18057 - alibektas:better_ratoml_testing, r=Veykrilbors-103/+228
internal: Better testing infra for ratoml This PR makes some improvements on how we test configs that come from `rust-analyzer.toml` files. It was primarily used to solve #18021 but along the way I could not really determine the cause of the said issue which makes me think that it may not be related to the changes that I made earlier to the ratoml infra. In either way `custom_snippets` are now made `global` because we still don't have a tree that maps a `SourceRootId` to a set of `Snippet`s.
2024-09-11Auto merge of #18052 - Coekjan:fix-inline-const, r=Veykrilbors-4/+14
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-11Auto merge of #18018 - ChayimFriedman2:unit-ret-complete-semi, r=Veykrilbors-40/+217
feat: Automatically add semicolon when completing unit-returning functions But provide a config to suppress that. I didn't check whether we are in statement expression position, because this is hard in completion (due to the natural incompleteness of source code when completion is invoked), and anyway using function returning unit as an argument to something seems... dubious. Fixes #17263.
2024-09-11Properly set the working directory for proc-macro executionLukas Wirth-5/+29
2024-09-11Auto merge of #17904 - darichey:unresolved-references, r=Veykrilbors-0/+200
Add command to report unresolved references Adds `rust-analyzer unresolved-references` which reports unresolved references. This is useful for debugging and regression testing for both rust-analyzer and project generators like Buck's rust-project. As discussed: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Command.20to.20report.20unresolved.20references
2024-09-11Lift out workspace related data into a separate query to preserve crategraph ↵Lukas Wirth-97/+98
deduplication
2024-09-11Auto merge of #18050 - rust-lang:davidbarsky/push-uyvtlsvoqrxw, r=Veykrilbors-9/+25
assist: ensure `replace_qualified_name_with_use` applies to the first path segment This change helps a bit with the discoverability of `replace_qualified_name_with_use`. Specifically, it ensures that a cursor on the first path segment (e.g., `$0std::fmt::Debug`, where `$0` is the cursor) would result in an import along the lines of `use std::fmt;` and `fmt::Debug;` at the usage sites.
2024-09-11Remove crate graph deduplication logicLukas Wirth-19658/+6
2024-09-11Auto merge of #18093 - ShoyuVanilla:skip-dyn-trait-cast-check, r=Veykrilbors-0/+139
Skip checks for cast to dyn traits It seems that chalk fails to solve some obvious goals when there are some recursiveness in trait environments. And it doesn't support trait upcasting yet. rust-lang/chalk#796 This PR just skips for casting into types containing `dyn Trait` to prevent false positive diagnostics like #18047 and #18083
2024-09-11Skip checks for cast to dyn traitsShoyu Vanilla-0/+139
2024-09-10Auto merge of #18092 - ChayimFriedman2:fix-stringify, r=lnicolabors-6/+25
fix: Correctly escape strings in our quote macro This is a small change, but it was the cause of 90% of the errors in `rust-analyzer diagnostics .` 🫢 (because this worked incorrectly with `stringify!()`, which means every `quote!()` (the original one) quoting a string also didn't work). With this change and #18085 together, all remaining errors are type errors. This may mean we can enable more errors, but this is out of scope for this PR.
2024-09-10Correctly escape strings in our quote macroChayim Refael Friedman-6/+25
This is a small change, but it was the cause of 90% of the errors in `rust-analyzer diagnostics .` 🫢 With this change and #18085 together, all remaining errors are type errors. This may mean we can enable more errors, but this is out of scope for this PR.
2024-09-10Auto merge of #18032 - DropDemBits:sed-tree-edits, r=davidbarskybors-0/+1251
internal: Add preliminary `SyntaxEditor` functionality Related to #15710 Implements a `SyntaxEditor` interface to abstract over the details of modifying syntax trees, to both simplify creating new code fixes and code actions, as well as start on the path of getting rid of mutable syntax nodes. `SyntaxEditor` relies on `SyntaxMappingBuilder`s to feed in the correct information to map AST nodes created by `make` constructors, as `make` constructors do not guarantee that node identity is preserved. This is to paper over the fact that `make` constructors simply re-parse text input instead of building AST nodes from the ground up and re-using the provided syntax nodes. `SyntaxAnnotation`s are used to find where syntax elements have ended up after edits are applied. This is primarily useful for the `add_{placeholder,tabstop}` set of methods on `SourceChangeBuilder`, as that currently relies on the nodes provided being in the final syntax tree. Eventually, the goal should be to move this into the `rowan` crate when we move away from mutable syntax nodes, but for now it'll stay in the `syntax` crate. --- Closes #14921 as `SyntaxEditor` ensures that all replace changes are disjoint Closes #9649 by implementing `SyntaxAnnotation`s
2024-09-09feat: use shorthand when pretty-print record patroife-6/+79
2024-09-09Auto merge of #18041 - roife:fix-issue-17631, r=Veykrilbors-1/+95
feat: better name suggestions for fn fix #17631. Better name suggestions for fn-calls / method-calls in the form of `from()`, `from_xxx()`, `into()`, etc.
2024-09-09feat: better name suggestions for fnroife-1/+95
2024-09-09fix: add parenthesis for or-patternroife-1/+18
2024-09-09fix: use `pretty_print_pat` for params in fnroife-5/+123
2024-09-09feat: add prettifier for Patroife-0/+31
2024-09-09feat: Allow hir-def prettifier formatting into one-lineroife-15/+55
2024-09-09Remove unnecessary symbols and add missing symbolscuishuang-3/+5
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-08Better testing infra for ratomlAli Bektas-103/+228
2024-09-08Automatically add semicolon when completing unit-returning functionsChayim Refael Friedman-40/+217
But provide a config to suppress that. I didn't check whether we are in statement expression position, because this is hard in completion (due to the natural incompleteness of source code when completion is invoked), and anyway using function returning unit as an argument to something seems... dubious.
2024-09-08assist: ensure replace_qualified_name_with_use applies to the first path segmentDavid Barsky-9/+25
2024-09-06Auto merge of #18067 - Veykril:prevent-mir-building, r=Veykrilbors-5/+14
fix: Properly prevent mir building with unknown types present
2024-09-06fix: Properly prevent mir building with unknown types presentLukas Wirth-5/+14
2024-09-06Auto merge of #18068 - Veykril:ty-fixes, r=Veykrilbors-71/+87
fix: Always explicitly set `TraitRef` self types when lowering
2024-09-06fix: Always explicitly set trait ref self types when loweringLukas Wirth-64/+80
2024-09-06Bump lsp-serverLukas Wirth-7/+7
2024-09-06Auto merge of #18066 - Veykril:lsp-server-no-panic, r=Veykrilbors-13/+11
fix: Don't panic lsp writer thread on dropped receiver Should reduce the noise a bit (https://github.com/rust-lang/rust-analyzer/issues/18055). This removes the panic (and a follow up panic) when the server incorrectly shuts down, turning it into a proper late exit error.
2024-09-06fix: Don't panic lsp writer thread on dropped receiverLukas Wirth-13/+11
2024-09-06Auto merge of #18065 - Veykril:catchy-diagnostics, r=Veykrilbors-12/+23
fix: Catch panics from diagnostics computation
2024-09-06fix: Catch panics from diagnostics computationLukas Wirth-12/+23
2024-09-06Auto merge of #18059 - Wilfred:config_cleanups, r=Veykrilbors-61/+85
fix: Updating settings should not clobber discovered projects `linkedProjects` is owned by the user's configuration, so when users update this setting, `linkedProjects` is reset. This is problematic when `linkedProjects` also contains projects discovered with `discoverCommand`. The buggy behaviour occurred when: (1) The user configures `discoverCommand` and loads a Rust project. (2) The user changes any setting in VS Code, so rust-analyzer receives `workspace/didChangeConfiguration`. (3) `handle_did_change_configuration` ultimately calls `Client::apply_change_with_sink()`, which updates `config.user_config` and discards any items we added in `linkedProjects`. Instead, separate out `discovered_projects_from_filesystem` and `discovered_projects_from_command` from user configuration, so user settings cannot affect any type of discovered project. This fixes the subtle issue mentioned here: https://github.com/rust-lang/rust-analyzer/pull/17246#issuecomment-2185259122
2024-09-05fix: Updating settings should not clobber discovered projectsWilfred Hughes-61/+85
`linkedProjects` is owned by the user's configuration, so when users update this setting, `linkedProjects` is reset. This is problematic when `linkedProjects` also contains projects discovered with `discoverCommand`. The buggy behaviour occurred when: (1) The user configures `discoverCommand` and loads a Rust project. (2) The user changes any setting in VS Code, so rust-analyzer receives `workspace/didChangeConfiguration`. (3) `handle_did_change_configuration` ultimately calls `Client::apply_change_with_sink()`, which updates `config.user_config` and discards any items we added in `linkedProjects`. Instead, separate out `discovered_projects_from_filesystem` and `discovered_projects_from_command` from user configuration, so user settings cannot affect any type of discovered project. This fixes the subtle issue mentioned here: https://github.com/rust-lang/rust-analyzer/pull/17246#issuecomment-2185259122
2024-09-05Add command to report unresolved referencesDavid Richey-0/+200
2024-09-05Auto merge of #18053 - Veykril:asm-parse, r=Veykrilbors-18/+112
fix: Couple asm! parsing and lowering fixes
2024-09-05fix: Fix parser panicking on invalid asm optionsLukas Wirth-0/+6
2024-09-05asm! parsing and lowering fixesLukas Wirth-18/+106
2024-09-05Auto merge of #18022 - Veykril:asm-parse, r=Veykrilbors-164/+2070
feat: IDE support for `asm!` expressions Fixes https://github.com/rust-lang/rust-analyzer/issues/10461, Fixes https://github.com/rust-lang/rust-analyzer/issues/6031 Progresses https://github.com/rust-lang/rust-analyzer/issues/11621 Notably this only works for asm expressions not items yet. Most IDE features work, mainly completions need extra logic still.
2024-09-05Fix name fetching being incorrect for asm operandsLukas Wirth-93/+107
2024-09-05Add missing doc commentsLukas Wirth-0/+1