Commit graph

264763 commits

Author SHA1 Message Date
bors
c01d5e03f2 Auto merge of #17984 - ShoyuVanilla:cast, r=Veykril
feat: Implement cast typecheck and diagnostics

Fixes  #17897 and fixes #16564
Mainly adopted from 100fde5246/compiler/rustc_hir_typeck/src/cast.rs
2024-09-03 06:00:10 +00:00
bors
6faf40992e Auto merge of #18031 - roife:suggest-name-in-completion, r=Veykril
feat: Suggest name in completion for let_stmt and fn_param

fix #17780

1. Refactor: move `ide_assist::utils::suggest_name` to `ide-db::syntax_helpers::suggest_name` for reuse.
2. When completing `IdentPat`, detecte if the current node is a `let_stmt` or `fn_param`, and suggesting a new name based on the context.
2024-09-03 05:45:53 +00:00
roife
ef491f2299 tests: suggesting names in completions for let_stmt and fn_param 2024-09-03 05:23:04 +08:00
roife
5f7fcbe0d4 feat: suggest name in let_stmt and fn_param 2024-09-03 05:22:55 +08:00
roife
b880890e59 refactor: move ide_assist::utils::suggest_name to ide-db 2024-09-03 05:21:05 +08:00
Shoyu Vanilla
111c690426 feat: Implement cast typechecks 2024-09-03 04:11:36 +09:00
bors
c2f9b47c21 Auto merge of #18029 - lnicola:minor-stuff, r=lnicola
minor: fix two nits
2024-09-02 17:07:43 +00:00
Laurențiu Nicola
2f8ef4c887 Merge some strings 2024-09-02 20:05:35 +03:00
Laurențiu Nicola
42ed30f0c6 Avoid Option::is_none_or for a while 2024-09-02 20:04:35 +03:00
bors
090a38cd94 Auto merge of #18028 - Veykril:lifetime-hints-panic, r=Veykril
fix: lifetime hint panic in non generic defs
2024-09-02 16:05:36 +00:00
Lukas Wirth
011a1fc41f fix: lifetime hint panic in non generic defs 2024-09-02 18:04:21 +02:00
bors
86c6382a53 Auto merge of #18016 - IvarWithoutBones:wrap-return-ty-local-result, r=Veykril
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-02 11:33:44 +00:00
bors
7a0fc46551 Auto merge of #18026 - Veykril:completions, r=Veykril
internal:  Adjust completions scoring
2024-09-02 11:19:33 +00:00
Lukas Wirth
3414a9e94f Adjust completions scoring 2024-09-02 13:17:52 +02:00
Lukas Wirth
f5ccde6d45 Simplify CompletionRelevance 2024-09-02 13:17:49 +02:00
bors
fb38e4b851 Auto merge of #18025 - cuishuang:master, r=lnicola
minor: remove repetitive words
2024-09-02 10:48:27 +00:00
cuishuang
ddb1e41e50 chore: fix some comments
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-02 18:33:23 +08:00
Ivar Scholten
92b8b56766 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
c7f4874be0 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
01b7676fe7 internal: Lay basic ground work for standalone mbe tests 2024-09-01 12:42:44 +02:00
bors
0b926e4eab 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
61b0374cc4 minor: Reduce friction for updating minicore 2024-09-01 11:32:55 +02:00
bors
28bc643e52 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
e233c3ae22 Complete desugared and resugared async fn in trait impls 2024-09-01 11:22:50 +02:00
bors
7f9f966771 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
fc9ff79519 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
f558be0359 minor: Downgrade cyclic deps error to warning 2024-09-01 10:02:41 +02:00
bors
b9872842af 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
20ed8ce78c 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
89a39d918f 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
8116b62fd2 Provide an option to hide deprecated items from completion 2024-09-01 01:04:21 +03:00
riverbl
d6573f9b08 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
5392d56c93 Update generated doctests
Update generated doctests, change unit test to be different to doctest.
2024-08-31 10:17:37 +01:00
riverbl
ce3ca99048 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
7b0134389d 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
5acbc4f5e1 fix: Fix lifetime elision inlay hints breaking for ranged requests 2024-08-31 10:51:13 +02:00
bors
1850ce345c 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
09a421a925 Auto merge of #17945 - alibektas:ratoml_categorization, r=alibektas
Recategorize config classes
2024-08-31 01:17:08 +00:00
Ali Bektas
1350769f47 Apply changes, fix path information in a comment in config.rs 2024-08-31 03:01:54 +02:00
bors
63bb576f5e 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
3f602089dc Support fn-ptr and fn-path types for lifetime elision hints 2024-08-30 19:36:18 +02:00
bors
bfaf63144a Auto merge of #18009 - Veykril:reformat-no-rustup, r=Veykril
fix: do not assume rustup is installed in xtask codegen take 2

7d9e4fcc07e5de94e37b73436147cdbbaa35dbdc 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
6b15103152 Allow xtask::reformat to work without rustup 2024-08-30 16:17:45 +02:00
Lukas Wirth
e69d57f16f Revert "fix: do not assume rustup is installed in xtask codegen"
This reverts commit 7d9e4fcc07e5de94e37b73436147cdbbaa35dbdc.
2024-08-30 16:15:01 +02:00
bors
9fc8eae53b 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
be33a2e1bd Improve inlay hint resolution reliability 2024-08-30 15:57:52 +02:00
bors
27979adbda 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
9afdc3a1d2
fix(ide-completion): fix handling of for in impl T for A in function body 2024-08-30 21:39:53 +08:00
bors
e77de38415 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
a729229a21 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