Commit graph

23769 commits

Author SHA1 Message Date
feniljain d7183fb5d0 fix: make make_body respect comments in extract_function 2022-12-09 18:30:30 +05:30
bors 34e654cd7b Auto merge of #13733 - WaffleLapkin:remove_parens, r=Veykril
feat: Add "Remove redundant parentheses" assist

![Peek 2022-12-08 22-22](https://user-images.githubusercontent.com/38225716/206542898-d6c97468-d615-4c5b-8650-f89b9c0321a0.gif)

Can be quite handy when refactoring :)
2022-12-09 11:42:09 +00:00
bors 83e2639cd1 Auto merge of #13722 - MariaSolOs:add-json-contrib, r=Veykril
Add VS Code schema validation for `rust-project.json`

Now that https://github.com/SchemaStore/schemastore/pull/2628 has been merged, adding the `jsonValidation` contribution to the VS Code extension for better editor support when modifying `rust-project.json` files.

Related issue: #13714
2022-12-09 11:29:10 +00:00
Lukas Wirth e80674e6b3 Show type info on hover of enum variant fields 2022-12-09 10:09:55 +01:00
Maybe Waffle ba6f0befc8 Simplify remove_parentheses's implementation 2022-12-08 18:54:08 +00:00
Maybe Waffle 8d42439a7d Move precedence handling to crates/syntax 2022-12-08 18:46:30 +00:00
Maybe Waffle 2870b01ec0 Explicitly say that the assist removes *redundant* parentheses 2022-12-08 18:22:57 +00:00
Ryo Yoshida 19e3085481
Only shift BoundVars that come from outside TyLoweringContext 2022-12-08 21:17:13 +09:00
Ryo Yoshida 46e1486a90
Disallow access to free BoundVars outside TyLoweringContext 2022-12-08 20:52:03 +09:00
bors 6e8a54d0f6 Auto merge of #13490 - HKalbasi:layout, r=jonas-schievink
Compute data layout of types

cc #4091

Things that aren't working:
* Closures
* Generators (so no support for `Future` I think)
* Opaque types
* Type alias and associated types which may need normalization

Things that show wrong result:
* ~Enums with explicit discriminant~
* SIMD types
* ~`NonZero*` and similar standard library items which control layout with special attributes~

At the user level, I didn't put much work, since I wasn't confident about what is the best way to present this information. Currently it shows size and align for ADTs, and size, align, offset for struct fields, in the hover, similar to clangd. I used it some days and I feel I liked it, but we may consider it too noisy and move it to an assist or command.
2022-12-07 15:22:03 +00:00
rami3l 57fb18e3bd fix: refine fallback case in generated PartialEq impl 2022-12-07 10:25:17 +08:00
hkalbasi 948a8f030b Add a fixme comment in current_target_data_layout 2022-12-07 02:29:50 +03:30
hkalbasi 05906da0ec use rustc crates instead of copy paste 2022-12-07 01:59:38 +03:30
Maybe Waffle ab061945a1 Consider expression precedense in remove_parentheses assist 2022-12-06 19:11:24 +00:00
Maybe Waffle 5f79279b48 Add remove_parentheses assist 2022-12-06 16:18:25 +00:00
rami3l fed74c8b71 fix: add fallback case in generated PartialEq impl 2022-12-06 21:54:53 +08:00
bors df07c8fafa Auto merge of #13730 - lowr:feat/builtin-macro-helper-attr, r=Veykril
Support builtin derive macro helper attributes

Closes #13244

It's a bit wasteful for `Macro2Data` to have `helpers` field currently just for `Default` derive macro, but I tend to think it's okay for the time being given how rare macro2's are used.
2022-12-06 08:16:14 +00:00
Ryo Yoshida 051c6598be
Resolve macro2's derive helpers in IDE layer
Macro2's generally don't have derive helpers, but currently builtin
derive macros are declared with macro2 syntax, which can have derive
helpers.
2022-12-06 16:01:20 +09:00
Ryo Yoshida cf54b8c3a4
Parse and collect derive helpers for builtin derive macros 2022-12-06 16:00:46 +09:00
bors f9bd487708 Auto merge of #13728 - detrumi:chalk-update, r=lnicola
Update to Chalk 88

This Chalk release introduces fuel for the recursive solver ([chalk#774](https://github.com/rust-lang/chalk/pull/774)).
I'm not sure how often it calls `should_continue` compared to the other solver, so we might want to increase `CHALK_SOLVER_FUEL`, the current default value of 100 might be too low.

This should fix a lot of hangs and crashes, for example this solves the hang in #12897.
2022-12-05 17:27:53 +00:00
Wilco Kusee a75bffc729 Increase Chalk fuel from 100 to 1000
The old value was for the old chalk-engine solver, nowadays the newer chalk-recursive solver is used.
The new solver currently uses fuel a bit more quickly, so a higher value is needed.
Running analysis-stats showed that a value of 100 increases the amount of unknown types,
while for a value of 1000 it's staying mostly the same.
2022-12-05 18:13:11 +01:00
Wilco Kusee fc627e637b Update to Chalk 88 2022-12-05 17:29:23 +01:00
feniljain 4794572e36 feat: allow unwrap block in let initializers 2022-12-05 09:00:16 +05:30
Maria José Solano fb60b104a2 Add JSON schema contribution 2022-12-04 12:04:56 -08:00
bors a2beeb8dbb Auto merge of #13721 - Veykril:incoherent-impls, r=Veykril
Support `rustc_has_incoherent_inherent_impls`

Fixes us not resolving `<dyn Error>::downcast` now that `Error` moved to core, while that assoc function is declared in `alloc`.
2022-12-04 19:37:26 +00:00
Lukas Wirth ca1389ef9f Support rustc_has_incoherent_inherent_impls 2022-12-04 20:37:17 +01:00
hkalbasi f2c9502185 support nonzero* niche optimizations 2022-12-04 00:29:34 +03:30
hkalbasi 86b5b609f1 Compute data layout of types 2022-12-04 00:29:34 +03:30
bors 957b4bb216 Auto merge of #13717 - lowr:fix/proc-macro-ident-is-raw, r=Veykril
Handle raw identifiers in proc macro server

Fixes #13706

When proc macros create `proc_macro::Ident`s, they pass an identifier text without "r#" prefix and a flag `is_raw` to proc macro server. Our `tt::Ident` currently stores the text *with* "r#" so we need to adjust them somewhere.

Rather than following rustc and adding `is_raw` field to our `tt::Ident`, I opted for adjusting the representation of identifiers in proc macro server, because we don't need the field outside it.

It's hard to write regression test for this, but at least I:
- ran `cargo +nightly t --features sysroot-abi` and all the tests passed
- built proc macro server with `cargo +nightly b -r --bin rust-analyzer-proc-macro-srv --features sysroot-abi` and made sure #13706 resolved
  - For the record, the nightly versions used are `rustc 1.67.0-nightly (32e613bba 2022-12-02)` and `cargo 1.67.0-nightly (e027c4b5d 2022-11-25)`.
2022-12-03 18:42:33 +00:00
Ryo Yoshida de591f08d6
Handle raw identifiers in proc macro server 2022-12-04 00:26:05 +09:00
bors 04a2ac2de2 Auto merge of #13707 - lowr:feat/move-const-to-impl, r=Veykril
Add `move_const_to_impl` assist

Closes #13277

For the initial implementation, this assist:
- only applies to inherent impl. Much as we can *technically* provide this assist for default impl in trait definitions, it'd be complicated to get it right.
- may break code when the const's name collides with an item of a trait the self type implements.

Comments in the code explain those caveats in a bit more detail.
2022-12-03 13:16:22 +00:00
bors d7be2fa1a6 Auto merge of #13713 - allanbrondum:bug/trait-method-callers, r=Veykril
check reference is a NameRef (and not Name)

Fixes that implementing methods are shown in call hierarchy https://github.com/rust-lang/rust-analyzer/issues/13712
2022-12-03 12:45:27 +00:00
feniljain ec268c0d6c fix: breaking snippets on typed incomplete suggestions
Fix the case where if a user types `&&42.o`, snippet completion
was still applying &&Ok(42). Note this was fixed previously
on `&&42.` but this still remained a problem for this case
2022-12-03 08:43:13 +05:30
Allan Brondum Rasmussen 30736b54c9 fmt 2022-12-03 01:20:27 +01:00
Allan Brondum Rasmussen cc4f9db086 remove unneeded test 2022-12-03 00:53:56 +01:00
Allan Brondum Rasmussen bce3b63700 check reference is a NameRef (and not Name) 2022-12-02 23:50:39 +01:00
Ryo Yoshida 6d4538734e
Add move_const_to_impl assist 2022-12-03 01:22:00 +09:00
bors 398a71affb Auto merge of #13697 - jonas-schievink:version-inlay-hint-resolve-data, r=jonas-schievink
internal: Version the inlay hint resolve data

cc https://github.com/rust-lang/rust-analyzer/issues/13657
cc https://github.com/rust-lang/rust-analyzer/issues/13372
cc https://github.com/rust-lang/rust-analyzer/issues/13170

This will make us log an error and return the unmodified inlay hints when the client attempts to resolve inlay hints in a file that has since been modified.
2022-11-29 18:37:00 +00:00
Jonas Schievink 32f59cf01d Update hash 2022-11-29 19:33:16 +01:00
Jonas Schievink 335cb26050 Version the inlay hint resolve data 2022-11-29 19:20:32 +01:00
bors e69fb5e9ef Auto merge of #13696 - jonas-schievink:signature-help-between-closing-delims, r=jonas-schievink
fix: Fix signature help not showing up when cursor is between `))` or `>>`

Fixes https://github.com/rust-lang/rust-analyzer/issues/13672
2022-11-29 17:51:15 +00:00
Jonas Schievink b65b02fd97 Fix signature help not showing up when cursor is between )) or >> 2022-11-29 18:50:21 +01:00
bors 3827e3ddf1 Auto merge of #13695 - detrumi:chalk-update, r=Veykril
Update Chalk to version 87

Changes:
- Support new `tuple_trait` lang item ([chalk#782](https://github.com/rust-lang/chalk/pull/782))
- Removed empty lifetime ([chalk#783](https://github.com/rust-lang/chalk/pull/783))
2022-11-29 14:58:09 +00:00
Wilco Kusee 16bf32fcdd Update Chalk to version 87 2022-11-29 15:25:09 +01:00
bors acd06de16a Auto merge of #13690 - Crauzer:vararg-type, r=Veykril
feat: Implement vararg parameter type inference

This PR implements the "collection" of the `va_list` type into the function parameter types list.
2022-11-29 07:55:57 +00:00
bors 3769cc35fa Auto merge of #13686 - MariaSolOs:test-lenses, r=Veykril
Don't show runnable code lenses in libraries outside of the workspace

Addresses #13664. For now I'm just disabling runnable code lenses since the ones that display the number of references and implementations do work correctly with external code.

Also made a tiny TypeScript change to use the typed `sendNotification` overload.
2022-11-29 07:42:35 +00:00
Maria José Solano 9914d30450 Fix formatting 2022-11-28 19:10:16 -08:00
Crauzer b3bd5a471e implement vararg type collection from function params 2022-11-29 00:32:13 +01:00
Maria José Solano 2174aca8f8 Check for workspace root in runnable codelens 2022-11-27 10:07:09 -08:00
Maria José Solano 8661740626 Use typed notification method 2022-11-27 09:46:37 -08:00