about summary refs log tree commit diff
path: root/src/tools/rust-analyzer
AgeCommit message (Collapse)AuthorLines
2024-08-30Auto merge of #18008 - Veykril:inlay-hints-resolve, r=Veykrilbors-216/+282
internal: Improve inlay hint resolution reliability The payload now ships the range the inlay hint ought to be triggered for instead of trying to estimate it from its position which is somewhat brittle
2024-08-30Improve inlay hint resolution reliabilityLukas Wirth-216/+282
2024-08-30fix(ide-completion): fix handling of `for` in `impl T for A` in function bodyrami3l-5/+81
2024-08-30Auto merge of #18003 - ChayimFriedman2:addr_of-static-mut, r=Veykrilbors-7/+78
Do not report missing unsafe on `addr_of[_mut]!(EXTERN_OR_MUT_STATIC)` The compiler no longer does as well; see https://github.com/rust-lang/rust/pull/125834. Also require unsafe when accessing `extern` `static` (other than by `addr_of!()`). Fixes #17978.
2024-08-30Auto merge of #17999 - ShoyuVanilla:issue-17998, r=Veykrilbors-21/+45
fix: `std::error::Error` is object unsafe Fixes #17998 I tried to get generic predicates of assoc function itself, not inherited from the parent here; https://github.com/rust-lang/rust-analyzer/blob/0ae42bd42576566540a84c62e118aa823edcf2ec/crates/hir-ty/src/object_safety.rs#L420-L442 But this naive equality check approach doesn't work when the assoc function has one or more generic paramters like; ```rust trait Foo {} trait Bar: Foo { fn bar(&self); } ``` because the generic predicates of the parent, `Bar` is `[^1.0 implements Foo]` and the generic predicates of `fn bar` is `[^1.1 implements Foo]`, which are different. This PR implements a correct logic for filtering out parent generic predicates for this.
2024-08-29fix: consider indentation in the "Generate impl" and "Generate trait impl" ↵Ivar Scholten-13/+76
assists This makes the generated impl's indentation match the ADT it targets, improving formatting when using nested modules inside of the same file or when defining types inside of a function.
2024-08-29Do not report missing unsafe on `addr_of[_mut]!(EXTERN_OR_MUT_STATIC)`Chayim Refael Friedman-6/+51
The compiler no longer does as well; see https://github.com/rust-lang/rust/pull/125834.
2024-08-29Add diagnostic for accessing an `extern` staticChayim Refael Friedman-1/+27
2024-08-30fix: `std::error::Error` is object unsafeShoyu Vanilla-21/+45
2024-08-29Auto merge of #17814 - ShoyuVanilla:object-safety, r=Veykrilbors-66/+1194
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-66/+1194
2024-08-29Auto merge of #17975 - IvarWithoutBones:dont-assume-rustup, r=Veykrilbors-15/+19
fix: do not assume rustup is installed in xtask codegen When formatting generated code the xtask crate attempts to run `rustup run stable rustfmt`, which fails if `rustup` is not installed. This results in test failures when another source manages the compiler toolchain, for example when using Nix (or any other distro-specific packaging solution): * xtask::codegen::grammar::test * xtask::codegen::assists_doc_tests::test With this PR xtask will first attempt to run `rustup run stable rustfmt`, and if that fails just plain `rustfmt`. It still validates a stable version is being used. This allows `cargo test` to pass on systems that do not use `rustup`.
2024-08-29Auto merge of #17993 - ChayimFriedman2:convert-to-tuple-attrs, r=Veykrilbors-11/+49
Consider field attributes when converting from tuple to named struct and the opposite Fixes #17983. I tried to use the `SourceChangeBuilder::make_mut()` API, but it duplicated the attribute...
2024-08-29Auto merge of #17991 - ChayimFriedman2:extract-variable-ref, r=Veykrilbors-10/+140
fix: Don't add reference when it isn't needed for the "Extract variable" assist I.e. don't generate `let var_name = &foo()`. Because it always irritates me when I need to fix that. Anything that creates a new value don't need a reference. That excludes mostly field accesses and indexing. I had a thought that we can also not generate a reference for fields and indexing as long as the type is `Copy`, but sometimes people impl `Copy` even when they don't want to copy the values (e.g. a large type), so I didn't do that.
2024-08-29Auto merge of #17987 - ChayimFriedman2:column-macro, r=Veykrilbors-1/+33
fix: Fix name resolution of shadowed builtin macro Fixes #17969.
2024-08-29Auto merge of #17988 - darichey:fix-scip-def, r=Veykrilbors-1/+3
Fix incorrect symbol definitions in SCIP output The SCIP output incorrectly marks some symbols as definitions because it doesn't account for the file ID when comparing the token's range to its definition's range. This means that if a symbol is referenced in a file at the same position at which it is defined in another file, that reference will be marked as a definition. I was quite surprised by how common this is. For example, `PartialEq` is defined [here](https://github.com/rust-lang/rust/blob/1.80.1/library/core/src/cmp.rs#L273) and `uuid` references it [here](https://github.com/uuid-rs/uuid/blob/1.8.0/src/lib.rs#L329). And what do you know, they're both at offset 10083! In our large monorepo, this happens for basically every common stdlib type!
2024-08-29Auto merge of #17940 - ChayimFriedman2:closure-to-fn, r=Veykrilbors-13/+1511
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-29Merge from rust-lang/rustLaurențiu Nicola-2/+4
2024-08-29Preparing for merge from rust-lang/rustLaurențiu Nicola-1/+1
2024-08-29fix: Fix TokenStream::to_string implementation dropping quotation marksLukas Wirth-3/+8
2024-08-29fix: Fix proc-macro server crashing when parsing a non-lexable string into a ↵Lukas Wirth-3/+15
TokenStream
2024-08-29Auto merge of #17992 - Wilfred:newlines_in_logs, r=Veykrilbors-2/+2
internal: Avoid newlines in fetch errors Most logs lines don't have newlines, ensure fetch errors follow this pattern. This makes it easier to see which log line is associated with the error. Before: 2024-08-28T21:11:58.431856Z ERROR FetchWorkspaceError: rust-analyzer failed to discover workspace After: 2024-08-28T21:11:58.431856Z ERROR FetchWorkspaceError: rust-analyzer failed to discover workspace
2024-08-28Fix incorrect symbol definitions in SCIP outputDavid Richey-1/+3
2024-08-28internal: Add doc comments to OpQueueWilfred Hughes-0/+11
2024-08-29Consider field attributes when converting from tuple to named struct and the ↵Chayim Refael Friedman-11/+49
opposite
2024-08-29Also handle deref expressions in "Extract variable"Chayim Refael Friedman-15/+59
And BTW, remove the parentheses of the extracted expression if there are.
2024-08-28internal: Avoid newlines in fetch workspace errorsWilfred Hughes-2/+2
Most logs lines don't have newlines, ensure fetch workspace errors follow this pattern. Before: 2024-08-28T21:11:58.431856Z ERROR FetchWorkspaceError: rust-analyzer failed to discover workspace After: 2024-08-28T21:11:58.431856Z ERROR FetchWorkspaceError: rust-analyzer failed to discover workspace
2024-08-29Don't add reference when it isn't needed for the "Extract variable" assistChayim Refael Friedman-1/+42
I.e. don't generate `let var_name = &foo()`. Anything that creates a new value don't need a reference. That excludes mostly field accesses and indexing. I had a thought that we can also not generate a reference for fields and indexing as long as the type is `Copy`, but sometimes people impl `Copy` even when they don't want to copy the values (e.g. a large type), so I didn't do that.
2024-08-28Consider all expressions that autoderef in "Extract variable", not just ↵Chayim Refael Friedman-3/+48
method and field accesses.
2024-08-28Fix name resolution of shadowed builtin macroChayim Refael Friedman-1/+33
2024-08-28Minor errorsAli Bektas-2/+2
2024-08-28Remove invalid testsAli Bektas-72/+0
2024-08-28Make almost every client config globalAli Bektas-210/+211
2024-08-28Make completion_* localAli Bektas-72/+76
2024-08-28Make diagnostics_* localAli Bektas-32/+33
2024-08-28Make workspace_symbol_search_* workspaceAli Bektas-15/+15
2024-08-28Make procMacro_* workspaceAli Bektas-7/+11
2024-08-28Make rustc_* workspaceAli Bektas-11/+11
2024-08-28Make runnables workspaceAli Bektas-22/+24
2024-08-28Make check workspaceAli Bektas-85/+89
2024-08-28Make checkOnSave workspaceAli Bektas-8/+9
2024-08-28Make cargo_ workspace againAli Bektas-157/+190
2024-08-28Auto merge of #17981 - lnicola:proc-macro-cwd, r=Veykrilbors-2/+2
minor: Fix cwd used for proc macro expansion Fixes #17980.
2024-08-28Fix cwd used for proc macro expansionLaurențiu Nicola-2/+2
2024-08-27Create an assist to convert closure to freestanding fnChayim Refael Friedman-13/+1511
The assist converts all captures to parameters.
2024-08-27Auto merge of #17757 - alibektas:toggle_macro_delimiters, r=Veykrilbors-0/+279
assist: Add new assist toggle_macro_delimiter Closes #17716
2024-08-27fix: do not assume rustup is installed in xtask codegenIvar Scholten-15/+19
When formatting generated code the xtask crate attempts to run `rustup run stable rustfmt`, which fails if `rustup` is not installed. This results in test failures when another source manages the compiler toolchain, for example when using Nix (or any other distro-specific packaging solution): * xtask::codegen::grammar::test * xtask::codegen::assists_doc_tests::test With this commit xtask will first attempt to run `rustup run stable rustfmt`, and if that fails just plain `rustfmt`. It still validates a stable version is being used. This allows `cargo test` to pass on systems that do not use `rustup`.
2024-08-27Fix testsLukas Wirth-23/+23
2024-08-27Auto merge of #17974 - lnicola:rm-apache-appendix, r=lnicolabors-50/+0
internal: Drop Apache license appendices Closes #14586 Similar to https://github.com/rust-lang/rust/pull/67734
2024-08-27Auto merge of #17973 - Veykril:proc-macro-curr-dir, r=Veykrilbors-14/+34
Expand proc-macros in workspace root, not package root Should fix https://github.com/rust-lang/rust-analyzer/issues/17748. The approach is generally not perfect though as rust-project.json projects don't benefit from this (still, nothing changes in that regard)