Commit Graph

26668 Commits

Author SHA1 Message Date
bors
ab62c0186f Auto merge of #15696 - rmehri01:14293_tuple_return_type_to_struct, r=Veykril
feat: implement tuple return type to tuple struct assist

This PR implements the `convert_tuple_return_type_to_struct` assist, for converting the return type of a function or method from a tuple to a tuple struct. Additionally, it moves the `to_camel_case` and `char_has_case` functions from `case_conv` to `stdx` so that they can be used similar to `to_lower_snake_case`.

[tuple_return_type_to_tuple_struct.webm](https://github.com/rust-lang/rust-analyzer/assets/52933714/2803ff58-fde3-4144-9495-7c7c7e139075)

Currently, the assist puts the struct definition above the function, or above the nearest `impl` or `trait` if applicable and only rewrites literal tuples that are returned in the body of the function. Additionally, it only attempts to rewrite simple tuple pattern usages with the corresponding tuple struct pattern but does so across files and modules.

I think that this is sufficient for the majority of use cases but I could be wrong. One thing I'm still not sure how to approach is handling `Self` and generics/lifetimes in the tuple type to be extracted. I was thinking of either manually figuring out what lifetimes and generics are in scope and using them (sort of similar to the `generate_function` assist) or maybe using `ctx.sema.resolve_type` and `generic_params` on `hir::Type` but this seems to not deal with lifetimes.

Closes #14293
2023-10-09 08:14:42 +00:00
bors
dca63d1b21 Auto merge of #15713 - Veykril:flyimport-completions-short, r=Veykril
Do flyimport completions by prefix search for short paths

Fixes https://github.com/rust-lang/rust-analyzer/issues/15711
2023-10-09 07:56:02 +00:00
DaniPopes
0c4be03456
feat: generate descriptors for all unstable features 2023-10-09 09:36:47 +02:00
bors
d646ae80c5 Auto merge of #15681 - Tyrubias:custom_target_dir, r=Veykril
Add config option to use `rust-analyzer` specific target dir

Adds a Rust Analyzer configuration option to set a custom target directory for builds. This is a workaround for Rust Analyzer blocking debug builds while running `cargo check`. This change should close #6007.

This is my first time contributing to this project, so any feedback regarding best practices that I'm not aware of are greatly appreciated! Thanks to all the maintainers for their hard work on this project and reviewing contributions.
2023-10-09 07:27:03 +00:00
Victor Song
a39d2076db Addressed PR style comments 2023-10-09 02:15:05 -05:00
Victor Song
9771e1e18f Don't pass any target directory options to custom flycheck 2023-10-09 02:15:05 -05:00
Victor Song
2290cc3cf3 Pass target directory as flag instead of env variable 2023-10-09 02:15:05 -05:00
Victor Song
3682c3791b Set CARGO_TARGET_DIR when using Flycheck custom command 2023-10-09 02:15:05 -05:00
Victor Song
ef0b3bbef1 Clarify documentation on new parameter 2023-10-09 02:15:05 -05:00
Victor Song
53b6700594 Add dedicated target_dir field to CargoConfig and FlycheckConfig
Add dedicated field for `target_dir` in the configurations for Cargo
and Flycheck. Also change the directory to be a `PathBuf` as opposed to
a `String` to be more appropriate to the operating system.
2023-10-09 02:15:05 -05:00
Victor Song
aeef7b644b Add config option to use rust-analyzer specific target dir
Adds a Rust Analyzer configuration option to set a custom
target directory for builds. This is a workaround for Rust Analyzer
blocking debug builds while running `cargo check`. This change
should close #6007
2023-10-09 02:15:05 -05:00
bors
7e9b25bff7 Auto merge of #15725 - DaniPopes:fix-lintgen, r=Veykril
internal: fix automatic rustc/rustdoc lint generation

Missed in #15680: the output of `-Whelp` changed since the last run so it generated some bad rustdoc lints entries.
Also preemptively fix a `-Whelp` breakage that might get merged in rust-lang/rust#116412
2023-10-09 06:32:50 +00:00
Elias Holzmann
3dfc1bfc67 Use vscode.env.openExternal instead of the vscode.open command for docs
According to the VS Code documentation, the vscode.open command opens the URL
_in the editor_ (https://code.visualstudio.com/api/references/commands).
However, in reality, it seems to do so only for file:// URLs, falling back to
other applications for other URL schemes (at least for HTTP/HTTPS).

Until now, the URL to the documentation was always HTTP based, so using the
vscode.open command was perfectly fine. However, displaying local documentation
will be supported from now on (see next commit). Local documentation is not
HTTP-based, but instead addressed via a file:// URL. The file URL would
therefore be opened in VS Code instead of in the browser — this is definitely
not what the user wants.

Therefore, the vscode.env.openExternal function is used instead, this function
never opens the URL in VS Code.
2023-10-08 04:56:48 +02:00
DaniPopes
c5d9bfaa52
internal: fix automatic rustc/rustdoc lint generation 2023-10-07 23:24:55 +02:00
bors
b1f89a84ab Auto merge of #15600 - davidbarsky:davidbarsky/broken-rustfmt-in-ra, r=Veykril
fix: ensure `rustfmt` runs when configured with `./`

(Hopefully) resolves https://github.com/rust-lang/rust-analyzer/issues/15595. This change kinda approaches canonicalization—which I am not a fan of—but only in service of making `./`-configured commands run correctly.

Longer-term, I feel like this code should be removed once `rustfmt` supports recursive searches of configuration files or interpolation of values like `${workspace_folder}` lands in rust-analyzer.

## Testing

I cloned `rustc`, setup rust-analyzer as suggested in the [`rustc` dev guide](https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc), saved and formatted files in `src/tools/miri` and `compiler`, and saw `rustfmt` (seemingly) correctly.
2023-10-06 11:33:52 +00:00
Lukas Wirth
b3ebc9ab6a Check for both path separators on windows 2023-10-06 13:26:36 +02:00
bors
ef58843b9f Auto merge of #15721 - Veykril:shrink-pat-ptr, r=Veykril
Shrink PatPtr by swapping its AstPtr and Either wrap order

Will have neglible perf results I imagine, but it cleans up some code
2023-10-06 10:34:24 +00:00
Lukas Wirth
88a00bf49d Shrink PatPtr by swapping its AstPtr and Either wrap order 2023-10-06 12:32:37 +02:00
bors
a158670432 Auto merge of #15718 - Toby222:master, r=lnicola
Fix typos exec_intrinsic

Fix names of intrinsics in error messages from exec_intrinsic
(moved from rust-lang/rust#116478)
2023-10-06 07:29:12 +00:00
Tobias Berger
114f8a07e9
Fix typos exec_intrinsic 2023-10-06 09:24:28 +02:00
bors
03c5603035 Auto merge of #15714 - lnicola:rust-bors, r=lnicola
minor: Prepare for rust-bors

This [only works](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/testing.20new.20bors.20implementation/near/395026488) for try builds at the moment, unfortunately.
2023-10-05 22:50:31 +00:00
bors
fd39a30b6c Auto merge of #15712 - cuishuang:master, r=lnicola
minor: Remove repetitive words
2023-10-05 22:29:45 +00:00
bors
54866a0df7 Auto merge of #15668 - connorskees:feat/close-backtick, r=Veykril
feat: add backtick to surrounding and auto-closing pairs

Makes backticks always complete as a pair and also surround the current selection, similar to double quotes. This is useful primarily in the context of markdown doc comments, but is applied globally for simplicity.

Closes https://github.com/rust-lang/rust-analyzer/issues/11381
2023-10-05 22:08:15 +00:00
Laurențiu Nicola
e7295ff40c Prepare for rust-bors 2023-10-05 15:26:09 +03:00
cui fliter
58239f2990 Remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-10-05 19:40:41 +08:00
Lukas Wirth
4af730eb26 Do flyimport completions by prefix search for short paths 2023-10-05 13:21:12 +02:00
bors
695c612489 Auto merge of #15641 - alibektas:15598/fix_into_to_from, r=Veykril
fix: preceding QualifiedPathType for into_to_from assist

fixes #15598
2023-10-05 08:25:58 +00:00
bors
b57658d9a9 Auto merge of #15707 - dfireBird:default-statusbar-action-config, r=lnicola
Add configuration for the default action of the status bar click action in VSCode

Fixes #15441

Please suggest any changes if necessary.
2023-10-04 17:31:44 +00:00
dfireBird
ab091b73d0
Add config for the default click action of extension status bar 2023-10-04 21:07:50 +05:30
Ryan Mehri
9ba8dbc902 style: clean up magic number for finding pattern usages 2023-10-04 08:04:59 -07:00
bors
ad73597448 Auto merge of #15690 - Enselic:fix-regexp, r=Veykril
vscode: Fix line and col regexp for `rustc` problem matcher

When building the Rust compiler with `./x check` from within VS Code, the current `rustc` problem matcher thinks that the output from that command that looks like this:

    Build completed successfully in 0:00:26

is about a problem in a file named `0` on line 00, col 26. This wouldn't be so bad if it wasn't for that VS Code tends to get stuck on this problem because of problems with opening the file '0'.

The rust compiler will never output problems with a line or a column that starts with 0, so change the regexp to require lines and cols to begin with `[1-9]` to fix this problem.
2023-10-04 12:01:04 +00:00
bors
7e9da40078 Auto merge of #15700 - rmehri01:15694_iterator_demorgan, r=Veykril
feat: add assist for applying De Morgan's law to `Iterator::all` and `Iterator::any`

This PR adds an assist for transforming expressions of the form `!iter.any(|x| predicate(x))` into `iter.all(|x| !predicate(x))` and vice versa.

[IteratorDeMorgans.webm](https://github.com/rust-lang/rust-analyzer/assets/52933714/aad1a299-6620-432b-9106-aafd2a7fa9f5)

Closes #15694
2023-10-04 11:08:44 +00:00
Lukas Wirth
c266387e13
Replace unwrap with expect 2023-10-04 13:06:23 +02:00
bors
36be9134b8 Auto merge of #15709 - Veykril:runnables-custom-main, r=Veykril
fix: Recognize custom main function as binary entrypoint for runnables
2023-10-04 10:09:00 +00:00
Lukas Wirth
fe398163b6 Recognize custom main function as binary entrypoint for runnables 2023-10-04 12:07:41 +02:00
David Barsky
a8ec77dc7e address PR feedback. 2023-10-03 16:44:09 -04:00
bors
7b8330f283 Auto merge of #15706 - lnicola:rustc-dependencies-description, r=lnicola
minor: Add mock description to rustc-dependencies

Hopefully fixes auto-publishing.
2023-10-03 14:34:48 +00:00
Laurențiu Nicola
7c113ee77c Add mock description to rustc-dependencies 2023-10-03 17:32:57 +03:00
bors
4c9d2c75b5 Auto merge of #15698 - rmehri01:15695_make_guarded_return_more_lenient, r=Veykril
fix: allow more kinds of if let patterns in guarded return assist

Removes the checks that require the pattern to be a tuple struct with exactly 1 field that is unqualified and has an identifier pattern in it. I'm not sure if there should be more checks in place but they seem unnecessary now?

Closes #15695
2023-10-02 09:23:49 +00:00
bors
d7faec816b Auto merge of #15701 - lnicola:rustc_layout_scalar_valid_range2, r=lnicola
fix: strip base prefix in `layout_scalar_valid_range`

CC https://github.com/rust-lang/rust-analyzer/pull/15688/files#r1342311078
2023-10-02 07:49:53 +00:00
Laurențiu Nicola
084ee934b8 Strip base prefix in layout_scalar_valid_range 2023-10-02 10:47:18 +03:00
Ryan Mehri
34d3490198 feat: add assist for applying De Morgan's law to iterators 2023-10-01 21:30:10 -07:00
Ryan Mehri
146a7cc490 fix: allow more kinds of if let patterns in guarded return assist 2023-10-01 11:48:10 -07:00
Ryan Mehri
2611fbf623 implement basic version of convert_tuple_return_type_to_struct assist 2023-09-30 17:07:01 -07:00
Ryan Mehri
40f80e29a5 move to_camel_case and char_has_case from case_conv to stdx 2023-09-30 08:04:04 -07:00
bors
0840038f02 Auto merge of #15693 - HKalbasi:unused-var, r=HKalbasi
Downgrade `unused_variables` to experimental

I feel problems like #15679 are common.
2023-09-30 05:13:57 +00:00
hkalbasi
af28458643 Downgrade unused_variables to experimental 2023-09-30 08:38:55 +03:30
bors
4791a5de21 Auto merge of #15692 - Veykril:underscore-completions, r=Veykril
fix: Typing underscore should not trigger completions in types or patterns
2023-09-29 19:08:15 +00:00
Lukas Wirth
ae5d74dffb typing underscore should not trigger completions in types or patterns 2023-09-29 21:06:47 +02:00
Martin Nordholts
dd8ea977b7 vscode: Fix line and col regexp for problem matcher
When building the Rust compiler with `./x check` from within VS Code,
the current `rustc` problem matcher thinks that the output from that
command that looks like this:

    Build completed successfully in 0:00:26

is about a problem in a file named `0` on line 00, col 26. This wouldn't
be so bad if it wasn't for that VS Code tends to get stuck on this
problem because of problems with opening the file '0'.

The rust compiler will never output problems with a line or a column
that starts with 0, so change the regexp to require lines and cols to
begin with [1-9] to fix this problem.
2023-09-29 17:46:58 +02:00