aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge #3746bors[bot]2020-04-035-0/+868
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3746: Add create_function assist r=flodiebold a=TimoFreiberg The function part of #3639, creating methods will come later - [X] Function arguments - [X] Function call arguments - [x] Method call arguments - [x] Literal arguments - [x] Variable reference arguments - [X] Migrate to `ast::make` API Done, but there are some ugly spots. Issues to handle in another PR: - function reference arguments: Their type isn't printed properly right now. The "insert explicit type" assist has the same issue and this is probably a relatively rare usecase. - generating proper names for all kinds of argument expressions (if, loop, ...?) Without this, it's totally possible for the assist to generate invalid argument names. I think the assist it's already helpful enough to be shipped as it is, at least for me the main usecase involves passing in named references. Besides, the Rust tooling ecosystem is immature enough that some janky behaviour in a new assist probably won't scare anyone off. - select the generated placeholder body so it's a bit easier to overwrite it - create method (`self.foo<|>(..)` or `some_foo.foo<|>(..)`) instead of create_function. The main difference would be finding (or creating) the impl block and inserting the `self` argument correctly - more specific default arg names for literals. So far, every generated argument whose name can't be taken from the call site is called `arg` (with a number suffix if necessary). - creating functions in another module of the same crate. E.g. when typing `some_mod::foo<|>(...)` when in `lib.rs`, I'd want to have `foo` generated in `some_mod.rs` and jump there. Issues: the mod could exist in `some_mod.rs`, in `lib.rs` as `mod some_mod`, or inside another mod but be imported via `use other_mod::some_mod`. - refer to arguments of the generated function with a qualified path if the types aren't imported yet (alternative: run autoimport. i think starting with a qualified path is cleaner and there's already an assist to replace a qualified path with an import and an unqualified path) - add type arguments of the arguments to the generated function - Autocomplete functions with information from unresolved calls (see https://github.com/rust-analyzer/rust-analyzer/pull/3746#issuecomment-605281323) Issues: see https://github.com/rust-analyzer/rust-analyzer/pull/3746#issuecomment-605282542. The unresolved call could be anywhere. But just offering this autocompletion for unresolved calls in the same module would already be cool. Co-authored-by: Timo Freiberg <[email protected]>
| * | Use ast::make API in add_function assistTimo Freiberg2020-04-012-67/+73
| | |
| * | Add create_function assistTimo Freiberg2020-04-014-0/+862
| | |
* | | Merge #3814bors[bot]2020-04-034-1/+230
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | 3814: Add impl From for enum variant assist r=flodiebold a=mattyhall Basically adds a From impl for tuple enum variants with one field. It was recommended to me on the zulip to maybe try using the trait solver, but I had trouble with that as, although it could resolve the trait impl, it couldn't resolve the variable unambiguously in real use. I'm also unsure of how it would work if there were already multiple From impls to resolve - I can't see a way we could get more than one solution to my query. Fixes #3766 Co-authored-by: Matthew Hall <[email protected]>
| * | Cleanup checking for existing impls in impl From assistMatthew Hall2020-04-022-48/+24
| | | | | | | | | | | | | | | Use the trait solver to check if there's an existing implementation of From<type_in_enum_variant> for the enum.
| * | Add impl From for enum variant assistMatthew Hall2020-04-014-2/+255
| | | | | | | | | | | | | | | | | | Basically adds a From impl for tuple enum variants with one field. Added to cover the fairly common case of implementing your own Error that can be created from another one, although other use cases exist.
* | | Merge #3798bors[bot]2020-04-026-120/+94
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3798: Simplify r=Veetaha a=Veetaha bear with me Co-authored-by: veetaha <[email protected]>
| * | | Apply cargo xtask formatveetaha2020-04-021-1/+0
| | | |
| * | | Migrate to privacy as per review commetsveetaha2020-04-026-15/+25
| | | |
| * | | Less mutabilityveetaha2020-04-021-19/+23
| | | |
| * | | Migrate to iters some moreveetaha2020-04-021-18/+11
| | | |
| * | | Migrate to iteratorsveetaha2020-04-021-15/+3
| | | |
| * | | Simpify workspace handlingveetaha2020-04-027-83/+63
| | | |
| * | | Don't clone where you can copyveetaha2020-04-021-1/+1
|/ / /
* | | Merge #3828bors[bot]2020-04-022-16/+24
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3828: Bumps vsce to 1.75 r=kjeremy a=kjeremy Fixes a security vulnerability Co-authored-by: kjeremy <[email protected]>
| * | | Bumps vsce to 1.75kjeremy2020-04-022-16/+24
|/ / / | | | | | | | | | Fixes a security vulnerability
* | | Merge #3811bors[bot]2020-04-025-3/+104
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3811: Add inference for literal and range patterns r=kjeremy a=flodiebold (cc @JoshMcguigan ) Co-authored-by: Florian Diebold <[email protected]>
| * | | Add inference for literal and range patternsFlorian Diebold2020-04-015-3/+104
| | | |
* | | | Merge #3827bors[bot]2020-04-021-58/+27
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3827: Fix semantic coloring r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
| * | | | Fix semantic coloringAleksey Kladov2020-04-021-58/+27
|/ / / /
* | | | Merge #3825bors[bot]2020-04-022-2/+33
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3825: Allow fully overriding check and fmt commands r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
| * | | | better wordingAleksey Kladov2020-04-021-1/+1
| | | | |
| * | | | Allow fully overriding check and fmt commandsAleksey Kladov2020-04-022-2/+33
| | | | |
* | | | | Merge #3824bors[bot]2020-04-0210-256/+229
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3824: New config names r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
| * | | | Remove vscode_lldb settingAleksey Kladov2020-04-023-20/+18
| | | | |
| * | | | SiplifyAleksey Kladov2020-04-022-7/+5
| | | | |
| * | | | Lean onto default implementation of configsAleksey Kladov2020-04-028-70/+24
| | | | |
| * | | | New config in package.jsonAleksey Kladov2020-04-022-146/+166
| | | | |
| * | | | Reorder fieldsAleksey Kladov2020-04-021-44/+47
|/ / / /
* | | | Merge #3816bors[bot]2020-04-023-20/+96
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3816: vscode: add goto ast node definition from rust source code r=Veetaha a=Veetaha By holding the `Ctrl` key you can now goto-definition of the appropriate syntax token in the syntax tree read-only editor. But actually going to the definition is not very convenient, since it opens the new editor, you'd rather just hold the `Ctrl` and look at the syntax tree because it is automatically scrolled to the proper node and the node itself is enclosed with text selection. Unfortunately, the algorithm is very simple (because we don't do any elaborate parsing of the syntax tree text received from the server), but it is enough to debug not very large source files. I tested the performance and in a bad case (rust source file with 5K lines of code) it takes `1.3` seconds to build the `rust -> ast` mapping index (lazily once on the first goto definition request) and each lookup in this worst-case is approx `20-120` ms. I think this is good enough. In the simple case where the file is < 100 lines of code, it is instant. One peculiarity that I've noticed is that vscode doesn't trigger the goto-definition provider when the user triggers it on some punctuation characters (i.e. it doesn't underline them and invoke te goto-definition provider), but if you explicitly click `Ctrl+LMB` it will only then invoke the provider and navigate to the definition in a new editor. I think this is fine ;D ![rust2ast](https://user-images.githubusercontent.com/36276403/78198718-24d1d500-7492-11ea-91f6-2687cedf26ee.gif) Related: #3682 Co-authored-by: veetaha <[email protected]>
| * | | | vscode: move docks about syntax tree to dev/README.mdveetaha2020-04-022-10/+10
| | | | |
| * | | | vscode: postrefactorveetaha2020-04-021-12/+6
| | | | |
| * | | | vscode: add docs about goto-definition for rust syntax treeveetaha2020-04-021-0/+4
| | | | |
| * | | | vscode: postrefactor variable namesveetaha2020-04-021-8/+8
| | | | |
| * | | | vscode: add goto definition from rust file to syntax tree editorveetaha2020-04-021-5/+83
|/ / / /
* | | | Merge #3820bors[bot]2020-04-029-359/+3
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3820: Remove old syntax highlighting r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
| * | | | Remove old syntax highlightingAleksey Kladov2020-04-029-359/+3
| | |_|/ | |/| |
* | | | Merge #3819bors[bot]2020-04-021-4/+5
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3819: Unique package by name and version. r=matklad a=o0Ignition0o This commit is a fixup of #3781 I introduced a bug by using a PackageId to refer to a crate when its name conflicts with a dependency. It turns out the package id currently is `name version path` while cargo expects `name:version` as argument eg: Cargo command with a `PackageId`: ``` > Executing task: cargo test --package 'config 0.1.0 (path+file:///Users/ignition/Projects/oss/config)' --test default -- test_with_name --exact --nocapture < ``` Cargo command with `name:version`: ``` > Executing task: cargo test --package 'config:0.1.0' --test default -- test_with_name --exact --nocapture < ``` Co-authored-by: o0Ignition0o <[email protected]>
| * | | | Unique package by name and version.o0Ignition0o2020-04-021-4/+5
| |/ / / | | | | | | | | | | | | | | | | This commit is a fixup of a bug I introduced by using a PackageId to refer to a crate when its name conflicts with a dependency. It turns out the package id currently is `name version path` while cargo expects `name:version` as argument.
* | | | Merge #3817bors[bot]2020-04-023-1/+50
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3817: vscode: highlight syntax tree ro editor r=matklad a=Veetaha Small textmate grammar declaration to make rust-analyzer syntax tree more easily inspectable: Btw, if we change the file extension of our `ra_syntax/test_data/**` files to `.rast` they should be highlighted in vscode too. The colors of the tokens are actually going to be color-theme dependent, or you can customize them via: ```jsonc { "editor.tokenColorCustomizations": { "textMateRules": [ { "scope": "name", "settings": { /* */ } } ] } } ``` ![image](https://user-images.githubusercontent.com/36276403/78204947-99f9d600-74a3-11ea-8315-cb1c87810c7c.png) Related: #3682 Co-authored-by: veetaha <[email protected]>
| * | | | vscode: add highlighting of syntax treeveetaha2020-04-023-1/+50
| |/ / /
* | | | Merge #3815bors[bot]2020-04-022-2/+13
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | 3815: vscode: add support for light themes in "Show Syntax Tree" command r=matklad a=Veetaha Fixes: #3810 Co-authored-by: veetaha <[email protected]>
| * | | vscode: add support for light themes and color customization for syntax tree ↵veetaha2020-04-012-2/+13
|/ / / | | | | | | | | | highlights
* | | Merge #3812bors[bot]2020-04-012-4/+4
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | 3812: rollup 2.3.2 r=kjeremy a=kjeremy Co-authored-by: kjeremy <[email protected]>
| * | rollup 2.3.2kjeremy2020-04-012-4/+4
|/ /
* | Merge #3806bors[bot]2020-04-012-3/+4
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3806: lower bool literal value r=flodiebold a=JoshMcguigan Following up on #3805, this PR adds the literal value to `ast::LiteralKind` so when we lower we can use the actual value from the source code rather than the default value for the type. Ultimately I plan to use this for exhaustiveness checking in #3706. I didn't include this in the previous PR because I wasn't sure if it made sense to add this information to `ast::LiteralKind` or provide some other mechanism to get this from `ast::Literal`. For now I've only implemented this for boolean literals, but I think it could be easily extended to other types. A possible exception to this are string literals, since we may not want to clone around an owned string to hold onto in `ast::LiteralKind`, and it'd be nice to avoid adding a generic lifetime as well. Perhaps we won't ever care about the actual value of a string literal? Co-authored-by: Josh Mcguigan <[email protected]>
| * | lower bool literal with the value from source code rather than default bool ↵Josh Mcguigan2020-04-012-3/+4
| | | | | | | | | | | | value
* | | Merge #3809bors[bot]2020-04-0114-374/+196
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3809: Less config r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
| * | | Fix pointer syntaxAleksey Kladov2020-04-012-30/+36
| | | |
| * | | Centralize defaultsAleksey Kladov2020-04-012-18/+6
| | | |