Commit graph

20916 commits

Author SHA1 Message Date
Lukas Wirth
c286786888
Merge pull request #18254 from ChayimFriedman2/fix-mut
fix: Nail destructuring assignment once and for all
2024-10-22 17:40:52 +00:00
Chayim Refael Friedman
0beec9081d Add test for tuple struct destructuring assignment where the path comes from a macro 2024-10-22 20:27:09 +03:00
Lukas Wirth
3ae93bcb82 Merge binding_mode inlay hints into one 2024-10-22 17:12:16 +02:00
Lukas Wirth
db60fb42bb Merge adjustment inlay hints into one 2024-10-22 16:56:13 +02:00
Lukas Wirth
13acfbfae4 Merge closure capture inlay hints into one 2024-10-22 16:29:15 +02:00
bors
d509449d7e Auto merge of #18370 - duncpro:goto-def-ranges, r=Veykril
feat: resolve range patterns to their structs

Closes #18367
2024-10-22 12:24:25 +00:00
bors
4c4f186e23 Auto merge of #18368 - Veykril:test-lsif_contains_generated_macros, r=lnicola
tests: Add `lsif_contains_generated_constant` test

Closes https://github.com/rust-lang/rust-analyzer/pull/18309
2024-10-22 12:10:07 +00:00
bors
eddab6e98c Auto merge of #18349 - dqkqd:issue-18344, r=Veykril
feat: render docs from aliased type when type has no docs

Trying to close #18344

- [x] ~Find the docs by traversing upwards if the type itself has none but aliasing for another type that might have.~
- [x] Show docs from aliased type.
- [x] Showing description that we are displaying documentation for different definition in hover box.

![image](https://github.com/user-attachments/assets/820d6f97-aa2c-4dc4-8a25-75746e32d950)
2024-10-22 11:56:16 +00:00
bors
c58427ff94 Auto merge of #18371 - Veykril:veykril/push-kwttrusywysp, r=Veykril
fix: Fix incorrect parsing of use bounds

Fixes https://github.com/rust-lang/rust-analyzer/issues/18357
2024-10-22 11:42:11 +00:00
Lukas Wirth
95298a2e61 fix: Fix incorrect parsing of use bounds
Also lower them a bit more
2024-10-22 13:34:26 +02:00
Khanh Duong Quoc
44e48d75dd
feat: render docs from aliased type when docs are missing 2024-10-22 20:27:05 +09:00
Duncan Proctor
4fd471c571 tidy 2024-10-22 06:54:44 -04:00
Duncan Proctor
2e0fae3579 tidy 2024-10-22 06:37:12 -04:00
Duncan Proctor
c679551d6b remove duplicate test 2024-10-22 06:25:13 -04:00
Duncan Proctor
271f64f94d resolve range patterns to the their struct types 2024-10-22 06:20:16 -04:00
Lukas Wirth
6c23f25e7f Fix new nightly lints 2024-10-22 11:48:41 +02:00
Johann Hemmann
505c9c9fb3 tests: Add lsif_contains_generated_constant test 2024-10-22 11:38:54 +02:00
Lukas Wirth
232432411e Cleanup file structure proto handling 2024-10-22 10:51:08 +02:00
bors
17055aaca9 Auto merge of #18362 - duncpro:goto-def-ranges, r=Veykril
feat: goto definition on range operators

Closes #18342
2024-10-22 07:49:18 +00:00
Duncan Proctor
2f6923b844 tidy 2024-10-22 03:19:47 -04:00
Laurențiu Nicola
a32039278f Replace some LayoutError variants with the rustc_abi errors 2024-10-22 10:19:25 +03:00
Laurențiu Nicola
250bf98d58 Merge from rust-lang/rust 2024-10-22 10:12:22 +03:00
Duncan Proctor
f54a863965 goto definition on RangeFrom, RangeFull, RangeTo, and RangeToInclusive links to respective struct 2024-10-22 03:11:23 -04:00
duncanproctor
c7a8be110d Move explicit range handling out of goto_definition, use OperatorClass instead 2024-10-21 20:07:07 -04:00
bors
de2ff17bc5 Auto merge of #18360 - roife:safe-kw-3, r=Veykril
feat: better completions for extern blcoks

This PR refactors `add_keywords` (making it much clearer!) and enhances completion for `extern` blocks.

It is recommended to reviewing the changes in order of the commits:

- The first commit (f3c4dde0a4) doesn’t change any logic but refactors parts of the `add_keywords` function and adds detailed comments.
- The second commit (5dcc1ab649) improves completion for `extern` kw and extern blocks.
2024-10-21 17:59:05 +00:00
roife
cf3544a0ec minor: refactor completions in item_list 2024-10-22 01:31:57 +08:00
duncanproctor
3bc6e27993 GotoDefinition on a Range or InclusiveRange operator will link to the struct definition 2024-10-21 11:29:05 -04:00
bors
487152b90f Auto merge of #18361 - Veykril:veykril/push-uzsokssoyznx, r=Veykril
fix: Fix token downmapping failing for include! inputs

Supercedes https://github.com/rust-lang/rust-analyzer/pull/18325

Fixes https://github.com/rust-lang/rust-analyzer/pull/18325
Fixes https://github.com/rust-lang/rust-analyzer/issues/18313
Fixes https://github.com/rust-lang/rust-analyzer/issues/18314
2024-10-21 15:27:42 +00:00
Lukas Wirth
d878b8caad fix: Fix token downmapping failing for include! inputs 2024-10-21 17:22:18 +02:00
roife
5dcc1ab649 feat: better completions for extern blcoks 2024-10-21 22:23:16 +08:00
roife
f3c4dde0a4 refactor add_keywords in ide-completions for clarity 2024-10-21 22:23:01 +08:00
bors
546da8a5ad Auto merge of #18294 - Giga-Bowser:master, r=Veykril
Add wrap/unwrap return type in Option

I pretty much just copied over the code and tests for wrapping/unwrapping return types in `Result` and then did a bunch of find and replace changes.

I handled unwrapping statements returning `None` by just replacing `None` with the unit type, but I'm open to suggestions for more intuitive behavior here.
2024-10-21 13:56:01 +00:00
bors
dc2a348bdd Auto merge of #18337 - dqkqd:issue-18287, r=Veykril
fix: private items are shown in completions for modules in fn body

Close: #18287
2024-10-21 13:41:27 +00:00
Khanh Duong Quoc
5fdcbdddfa
fix: private items are shown in completions for modules in fn body 2024-10-21 21:42:46 +09:00
Lukas Wirth
02e189dcb5 fix: FIx mbe bench tests being iteration order dependent 2024-10-21 11:54:49 +02:00
Lukas Wirth
70d0b57cf0 Update ide tests 2024-10-21 11:28:19 +02:00
Lukas Wirth
1cdc34fa4a Fix recursive_adt fixture 2024-10-21 11:28:18 +02:00
Noratrieb
6a2b8270c9 Update rustc-hash to version 2
This brings in the new optimized algorithm that was shown to have small performance benefits for
rustc.
2024-10-21 11:28:18 +02:00
roife
834ccbffba fix: classify safe as a contextual kw 2024-10-21 02:56:21 +08:00
Chayim Refael Friedman
2d4d6b678f Store patterns desugared from destructuring assignments in source map
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-20 19:11:32 +03:00
Chayim Refael Friedman
61f162a43d Handle destructuring assignments uniformly
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-20 19:09:51 +03:00
Chayim Refael Friedman
4379153e59 Remove now-incorrect code
Because our lint infra *can* handle allows from within macro expansions!

(Also, what did this reason have to do with something that is a hard error and not a lint? I'm puzzled).

I wonder how many such diagnostics we have...

Maybe that also mean we can change `unused_mut` to no-longer-experimental? But this is a change I'm afraid to do without checking.
2024-10-20 19:09:51 +03:00
roife
002f6ad6f1 fix: do not emit unsafe diagnositcs for safe statics in extern blocks 2024-10-20 19:49:57 +08:00
roife
9f1e450c4f feat: initial support for safe_kw in extern blocks 2024-10-20 17:12:52 +08:00
Stuart Cook
d6350f60f7
Rollup merge of #131942 - workingjubilee:reduce-haruspicy, r=lukas-code,lnicola
compiler: Adopt rust-analyzer impls for `LayoutCalculatorError`

We're about to massively churn the internals of `rustc_abi`. To minimize the immediate and future impact on rust-analyzer, as a subtree that depends on this crate, grow some API on `LayoutCalculatorError` that reflects their uses of it. This way we can nest the type in theirs, and they can just call functions on it without having to inspect and flatten-out its innards.
2024-10-20 14:06:04 +11:00
Jubilee Young
90ec8053c2 rust-analyzer: Nest LayoutCalculatorError in hir_ty::LayoutError 2024-10-19 11:09:24 -07:00
Giga Bowser
2c823865c6 Combine entry points for wrapping/unwrapping return types 2024-10-19 11:59:52 -04:00
Wei Xu
cfa5df107a
Increase TOKEN_LIMIT for hir-expand 2024-10-18 17:36:24 -07:00
Johannes Altmanninger
94a4c3abaa Clamp Position::character to line length
LSP says about Position::character

> If the character value is greater than the line length it defaults back to the line length.

but from_proto::offset() doesn't implement this.

A client might for example request code actions for a whole line by sending
Position::character=99999.  I don't think there is ever a reason (besides laziness) why the
client can't specify the line length instead but I guess we should not crash but follow protocol.

Technically it should be a warning, not an error but warning is not shown by default so keep
it at error I guess.

Fixes #18240
2024-10-18 15:07:13 +02:00
bors
a40c399a3f Auto merge of #18331 - Veykril:veykril/push-tsolukqqyllz, r=Veykril
internal: Add more trivially `Sized` types to `is_sized` check
2024-10-18 10:55:51 +00:00