Commit graph

31574 commits

Author SHA1 Message Date
Lukas Wirth
26cd745104 Simplify CompletionRelevance 2024-09-02 13:17:49 +02:00
bors
21b7608fd7 Auto merge of #18025 - cuishuang:master, r=lnicola
minor: remove repetitive words
2024-09-02 10:48:27 +00:00
cuishuang
680de15ec3 chore: fix some comments
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-02 18:33:23 +08:00
DropDemBits
db649195e9
handle merging two syntax editors together 2024-09-02 00:09:30 -04:00
DropDemBits
883e429179
elaborate SyntaxEdit comments 2024-09-02 00:02:32 -04:00
DropDemBits
ad9595d729
wip: new syntax tree editor 2024-09-02 00:02:32 -04:00
Ivar Scholten
4e9d17b96d 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.
2024-09-02 02:00:19 +02:00
bors
779d9eee2e Auto merge of #17967 - Veykril:mbe-tests, r=Veykril
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-01 11:44:58 +00:00
Lukas Wirth
4502a602a7 internal: Lay basic ground work for standalone mbe tests 2024-09-01 12:42:44 +02:00
bors
bae49517f2 Auto merge of #17985 - riverbl:explicit-enum-discriminant, r=Veykril
Add explicit enum discriminant assist

Add assist for adding explicit discriminants to all variants of an enum.

Closes #17798.
2024-09-01 09:38:28 +00:00
Lukas Wirth
1e30cc0f35 minor: Reduce friction for updating minicore 2024-09-01 11:32:55 +02:00
bors
72fe274605 Auto merge of #17737 - hyf0:hyf_32089420384, r=Veykril
feat(ide-completion): extra sugar auto-completion `async fn ...` in `impl trait` for `async fn in trait` that's defined in desugar form

Solves #17719.

---

Preview

<img width="670" alt="image" src="https://github.com/user-attachments/assets/64ccef84-4062-4702-8760-89220585f422">

<img width="540" alt="image" src="https://github.com/user-attachments/assets/d22637f9-d531-43b2-a9f1-cd40a002903a">

<img width="631" alt="image" src="https://github.com/user-attachments/assets/21cd2142-bb8e-4493-9ac7-e6a9e7076904">
2024-09-01 09:24:04 +00:00
Lukas Wirth
eb64cc8c35 Complete desugared and resugared async fn in trait impls 2024-09-01 11:22:50 +02:00
bors
18757840be Auto merge of #18020 - Veykril:cyclic-deps, r=Veykril
minor: Downgrade cyclic deps error to warning

As the issue here is no longer workable for us and this appearing for some repos due to package cycles which can cause we should downgrade it as some people tend to think this breaks r-a when it doesn't
2024-09-01 08:09:12 +00:00
Yunfei
18feb726be feat(ide-completion): extra sugar auto-completion async fn ... in impl trait for async fn in trait that's defined in desugar form 2024-09-01 10:08:25 +02:00
Lukas Wirth
2e2f798a74 minor: Downgrade cyclic deps error to warning 2024-09-01 10:02:41 +02:00
bors
8d1d5cdfc1 Auto merge of #18015 - ChayimFriedman2:flip-comma-attribute, r=Veykril
Handle attributes correctly in "Flip comma"

Attributes often contain path followed by a token tree (e.g. `align(2)`), and the previous code handled them as two separate items, which led to results such as `#[repr(alignC, (2))]`.

An alternative is to just make the assist unavailable in attributes, like we do in macros. But contrary to macros, attributes often have a fixed form, so this seems useful.

Fixes #18013.
2024-09-01 06:25:29 +00:00
bors
715e9ffcdb Auto merge of #18006 - ChayimFriedman2:hide-deprecated, r=Veykril
Provide an option to hide deprecated items from completion

Fixes #17989.

I wonder if this should be instead done in the editor, that will do it in a language-agnostic way. Can't hurt to do it in rust-analyzer, I guess.
2024-09-01 06:06:49 +00:00
Chayim Refael Friedman
5c14f13ce0 Handle attributes correctly in "Flip comma"
Attributes often contain path followed by a token tree (e.g. `align(2)`, and the previous code handled them as two separate items, which led to results such as `#[repr(alignC, (2))]`.

An alternative is to just make the assist unavailable in attributes, like we do in macros. But contrary to macros, attributes often have a fixed form, so this seems useful.
2024-09-01 02:07:05 +03:00
Chayim Refael Friedman
01cc847158 Provide an option to hide deprecated items from completion 2024-09-01 01:04:21 +03:00
riverbl
db1ccb8bec Rename function and remove flag argument
Use less confusing name for function, duplicate logic rather than taking flag as argument.
2024-08-31 10:17:37 +01:00
riverbl
fbc9d8a675 Update generated doctests
Update generated doctests, change unit test to be different to doctest.
2024-08-31 10:17:37 +01:00
riverbl
6d3ef599f7 Add explicit enum discriminant assist
Add assist for adding explicit discriminants to all variants of an enum.
2024-08-31 10:17:37 +01:00
bors
914a1caab5 Auto merge of #18012 - Veykril:inlay-hints-lt, r=Veykril
fix: Fix lifetime elision inlay hints breaking for ranged requests
2024-08-31 08:52:59 +00:00
Lukas Wirth
82f96b5e6a fix: Fix lifetime elision inlay hints breaking for ranged requests 2024-08-31 10:51:13 +02:00
bors
1a84cd68a8 Auto merge of #18011 - Wilfred:op_queue_doc_comments, r=Veykril
internal: Add doc comments to OpQueue

I spent a while debugging some OpQueue behaviours and found the API slightly confusing, so I've added doc comments to clarify what each OpQueue method does.
2024-08-31 04:54:50 +00:00
bors
30c14ca30d Auto merge of #17945 - alibektas:ratoml_categorization, r=alibektas
Recategorize config classes
2024-08-31 01:17:08 +00:00
Ali Bektas
b17f1eee7d Apply changes, fix path information in a comment in config.rs 2024-08-31 03:01:54 +02:00
bors
9fd7051950 Auto merge of #18010 - Veykril:inlay-hints-lt, r=Veykril
feat: Support fn-ptr and fn-path types for lifetime elision hints

All still syntax based unfortunately but that won't change for quite a while
2024-08-30 17:37:33 +00:00
Lukas Wirth
16077975fa Support fn-ptr and fn-path types for lifetime elision hints 2024-08-30 19:36:18 +02:00
bors
64c538f9fb Auto merge of #18009 - Veykril:reformat-no-rustup, r=Veykril
fix: do not assume rustup is installed in xtask codegen take 2

7d9e4fcc07 broke this on rustup toolchains, the `cmd` command is trying to be too smart here
2024-08-30 14:19:36 +00:00
Lukas Wirth
3ad54a74ab Allow xtask::reformat to work without rustup 2024-08-30 16:17:45 +02:00
Lukas Wirth
38c1d6e337 Revert "fix: do not assume rustup is installed in xtask codegen"
This reverts commit 7d9e4fcc07.
2024-08-30 16:15:01 +02:00
bors
1cb426654a Auto merge of #18008 - Veykril:inlay-hints-resolve, r=Veykril
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-30 13:59:05 +00:00
Lukas Wirth
5ca5d52697 Improve inlay hint resolution reliability 2024-08-30 15:57:52 +02:00
bors
2890b10b40 Auto merge of #18005 - rami3l:fix/for-completion-in-impl, r=Veykril
fix(ide-completion): fix handling of `for` in `impl T for A` in function body

Closes #17787.
2024-08-30 13:45:04 +00:00
rami3l
0b28126599
fix(ide-completion): fix handling of for in impl T for A in function body 2024-08-30 21:39:53 +08:00
bors
13ac53e73d Auto merge of #18003 - ChayimFriedman2:addr_of-static-mut, r=Veykril
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-30 07:55:50 +00:00
bors
aefe34d876 Auto merge of #17999 - ShoyuVanilla:issue-17998, r=Veykril
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;

0ae42bd425/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-30 05:53:23 +00:00
bors
1b48c76078 Auto merge of #17982 - IvarWithoutBones:generate-impl-indent, r=Veykril
fix: consider indentation in the "Generate impl" and "Generate trait impl" 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. See the added tests for an example.

At first I tried to call some of the convenient helpers that delegate to `IndentLevel::increase_indent` on the generated impl, but as the comment on that function notes it does not indent the first token, making it inapplicable here. I hope the solution in this PR is acceptable, please let me know if I missed something :)
2024-08-30 05:38:59 +00:00
Ivar Scholten
f4070afb02 fix: consider indentation in the "Generate impl" and "Generate trait impl" 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-29 22:12:25 +02:00
Chayim Refael Friedman
91f2016ee1 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.
2024-08-29 22:58:26 +03:00
Chayim Refael Friedman
3d21d5e614 Add diagnostic for accessing an extern static 2024-08-29 22:12:12 +03:00
Shoyu Vanilla
231083958a fix: std::error::Error is object unsafe 2024-08-30 02:00:38 +09:00
bors
0ae42bd425 Auto merge of #17814 - ShoyuVanilla:object-safety, r=Veykril
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-29 13:24:54 +00:00
Shoyu Vanilla
6520a43ca3 feat: Implement object safety 2024-08-29 22:22:21 +09:00
bors
b3fa443eb2 Auto merge of #17975 - IvarWithoutBones:dont-assume-rustup, r=Veykril
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-29 10:27:39 +00:00
bors
d5a424f338 Auto merge of #17993 - ChayimFriedman2:convert-to-tuple-attrs, r=Veykril
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-29 08:28:46 +00:00
bors
5350c65443 Auto merge of #17991 - ChayimFriedman2:extract-variable-ref, r=Veykril
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-29 08:14:04 +00:00
bors
d9be51bbc9 Auto merge of #17987 - ChayimFriedman2:column-macro, r=Veykril
fix: Fix name resolution of shadowed builtin macro

Fixes #17969.
2024-08-29 07:59:12 +00:00