Commit graph

8321 commits

Author SHA1 Message Date
bors[bot]
662ed41ebc
Merge #6073
6073: Dont unnecessarily unnest imports r=matklad a=Veykril

Fixes #6071

This has the side effect that paths that refer to items inside of the current module get prefixed with `self`. Changing this behavior is unfortunately not straightforward should it be unwanted, though I don't see a problem with this as prefixing imports like this with `self` is what I do personally anyways 😅. You can see what I mean with this in one of the tests which had to be changed in `crates/ssr/src/tests.rs`.

There is one test that i still have to look at though, ~~which I by accident pushed with `#[ignore]` on it~~, which is `different_crate_renamed`, for some reason this now doesn't use the crate alias. This also makes me believe that aliases in general will break with this. So maybe this is not as straight forwards as I'd hoped for, but I don't really know how aliases work here.

Edit: The failing test should work now

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-25 14:57:15 +00:00
bors[bot]
dc09f1597f
Merge #6076
6076: Update chalk to 0.28.0 r=matklad a=vandenheuvel



Co-authored-by: Bram van den Heuvel <bram@vandenheuvel.online>
2020-09-25 14:47:56 +00:00
Bram van den Heuvel
dff6895ce8 Update chalk to 0.28.0 2020-09-25 15:29:31 +02:00
Lukas Wirth
747f6f64d7 Remove partial import test in insert_use 2020-09-25 15:21:50 +02:00
Lukas Wirth
e1d6981f90 Don't unnecessarily unnest imports for import insertion 2020-09-25 15:19:22 +02:00
bors[bot]
cfe987bcdf
Merge #6055
6055: Add ok postfix completion r=matklad a=mullr

Wrapping values in `Ok(...)` is so pervasive that it seems reasonable for it to
have its own postfix completion.


Co-authored-by: Russell Mull <russell.mull@gmail.com>
2020-09-25 11:55:35 +00:00
bors[bot]
163ffb8803
Merge #6072
6072: Cleanup unintended unresolved reference in syntax higlighting test r=matklad a=Nashenas88

Fixes the issue brought up here https://github.com/rust-analyzer/rust-analyzer/pull/5957#discussion_r486625707

cc @jonas-schievink 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-09-25 11:49:12 +00:00
Jean SIMARD
875ad9b5c4
Bump smol_str from 0.1.16 to 0.1.17 2020-09-24 16:39:08 +02:00
Paul Daniel Faria
ed8968af49 Cleanup unintended unresolved reference in syntax higlighting test 2020-09-24 10:14:25 -04:00
bors[bot]
5d137f21f2
Merge #6056
6056: Add dbgr postfix completion r=matklad a=lnicola

Expanding to `dbg!(&e)`.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-09-24 14:14:01 +00:00
bors[bot]
9d3483a74d
Merge #5846
5846: Add references to fn args during completion r=matklad a=adamrk

When completing a function call, if there is an argument taken as a ref or mut ref which matches the name and type of a variable in scope, we will insert a `&` or `&mut` when filling in the function arguments. This addresses https://github.com/rust-analyzer/rust-analyzer/issues/5449.

E.g. 
```rust
fn foo(x: &i32) {}
fn main() {
  let x = 5;
  foo # completing foo here generates `foo(&x)` now instead of `foo(x)`
}
```

Co-authored-by: adamrk <ark.email@gmail.com>
2020-09-24 12:23:28 +00:00
kjeremy
95d7e3ce49 lsp-types 0.82 2020-09-23 15:41:55 -04:00
Laurențiu Nicola
eb0e710779 Add dbgr postfix completion 2020-09-22 08:54:57 +03:00
Russell Mull
197d1e1b05 Cargo fmt 2020-09-21 17:47:20 -07:00
Russell Mull
e3b19da8c1 Add ok postfix completion 2020-09-21 17:15:20 -07:00
Aleksey Kladov
fcc3c49013
Apply suggestions from code review
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-09-21 15:35:42 +03:00
Aleksey Kladov
8e3082ff6e Document AstTransformation 2020-09-21 12:36:51 +02:00
Aleksey Kladov
2c916bbc18 Document SemanticScope 2020-09-21 12:30:55 +02:00
bors[bot]
3b52d3181a
Merge #6043
6043: Allow missing trait members assist without needing braces r=matklad a=M-J-Hooper

Assist to complete missing items when implementing a trait does not appear without impl def braces (see #5144 ).

The reason behind this was that this assist is based on `ast::AssocItemList` which only appears in the AST after the braces are added to the impl def.

Instead of relying on and replacing the item list, we now instead replace the entire `ast::Impl` and add the item list if its missing.

Co-authored-by: Matt Hooper <matthewjhooper94@gmail.com>
2020-09-21 09:06:24 +00:00
Matt Hooper
7d90bb1f47 Rename impl edit method to be more explicit 2020-09-21 10:01:50 +01:00
Matt Hooper
532be0e780 Added test for impl member assist when impl def is missing braces 2020-09-21 09:48:51 +01:00
Matt Hooper
9724af038b Replace entire impl def instead of only associated items for missing impl member assist (if braces are missing from an impl def then there is no associated item list in the AST) 2020-09-21 00:42:27 +01:00
Matt Hooper
ae7c982421 Add make utility for empty associated item lists 2020-09-21 00:39:17 +01:00
Matt Hooper
4362297a0b Add edit utility for adding an associated item list to a impl def 2020-09-21 00:38:18 +01:00
bors[bot]
e70cf706bb
Merge #6018
6018: Correct project_root path for ProjectJson. r=jonas-schievink a=woody77

It was already the folder containing the rust-project.json file, not the file itself.  This also removes the Option-ness of it, since it's now an infallible operation to set the member value.

Co-authored-by: Aaron Wood <aaronwood@google.com>
2020-09-20 19:25:09 +00:00
Aaron Wood
38f1ce633d Add rustdoc for ProjectJson methods 2020-09-20 12:06:12 -07:00
bors[bot]
fb1b0a4bff
Merge #6036
6036: Don't re-read open files from disk when reloading a workspace r=kjeremy a=lnicola

Fixes #5742
Fixes #4263

or so I hope.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-09-18 21:29:47 +00:00
Laurențiu Nicola
5a0bad7754 Don't re-read open files from disk when reloading a workspace 2020-09-18 22:15:44 +03:00
Jonas Schievink
46c5b557fe Log failure to load crate root file 2020-09-18 19:27:19 +02:00
kjeremy
c7243e4a59 Support active parameters at the per-signature level
Update crates
2020-09-18 11:39:25 -04:00
Jonas Schievink
9dc0afe854 Rename CustomDerive to ProcMacro
It handles fn-like macros too, and will handle attribute macros in the
future
2020-09-18 15:37:31 +02:00
Jonas Schievink
700a3d5d75 Invert condition to unindent code 2020-09-18 12:32:07 +02:00
Jonas Schievink
d328ee647f Use log::error! in a few more places 2020-09-17 17:37:52 +02:00
Jonas Schievink
6eea06415d Give ExternCrate a Name, not a ModPath 2020-09-17 15:28:23 +02:00
bors[bot]
d84c18d989
Merge #6017
6017: Don't return any TextEdit if formatting is unchanged r=jonas-schievink a=cuviper

I found that `textDocument/formatting` was always returning a full
`TextEdit` replacement, even when there are no changes, which caused Vim
(w/ vim-lsp) to always indicate a modified buffer after formatting. We
can easily compare whether there were changes and return `null` if not,
so the client knows there's nothing to do.

Co-authored-by: Josh Stone <cuviper@gmail.com>
2020-09-17 13:08:09 +00:00
bors[bot]
933fc1eb18
Merge #6016
6016: Emit diagnostics for unresolved imports and extern crates r=jonas-schievink a=jonas-schievink

AFAIK, we don't have any major bugs in name resolution that would cause a lot of false positives here (except procedural attribute macro support and some rare issues around `#[path]` on module files), so these are *not* marked as experimental diagnostics right now.

I noticed that diagnostics in a file sometimes don't get displayed after opening, but require some edit to be performed. This seems like a preexisting issue though.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-09-17 13:00:25 +00:00
Jonas Schievink
0dca7acf0f Don't diagnose imports whose base crate is missing 2020-09-17 14:48:17 +02:00
bors[bot]
3877421373
Merge #5989
5989: Rewrite import merging r=jonas-schievink a=Veykril

Rewrites how import merging is being handled. It is now a recursive function to properly handle merging of intermediate levels in the import trees. With this ordering the imports is also now possible tho it doesn't quite order it the same way as `rustfmt` does yet, namely it orders lowercase identifiers after uppercase identifiers as that is the standard character order that rust uses. This also fixes a few weird behaviors that were visible in some of the `replace_qualified_name_with_use.rs` tests.

This really took longer than I was hoping for, fighting with import trees is quite the exhausting task 😅 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-16 20:03:41 +00:00
Aaron Wood
2fbb09a73f Correct project_root path for ProjectJson.
It was already the folder containing the rust-project.json file, not the file itself.
2020-09-16 12:09:44 -07:00
Lukas Wirth
45298b5d2a Add make::glob_use_tree function to create star-only UseTree 2020-09-16 20:33:08 +02:00
bors[bot]
4bc8015370
Merge #6013
6013: Add support for custom flycheck commands with JSON project workspaces r=jonas-schievink a=woody77

Enable flychecks with JSON project workspaces if an override command was provided as part
of the client configuration:

```
    "rust-analyzer.checkOnSave.enable": true,
    "rust-analyzer.checkOnSave.overrideCommand": ["custom_tool", "arg1", "arg2"],
```


Co-authored-by: Aaron Wood <aaronwood@google.com>
2020-09-16 18:04:29 +00:00
bors[bot]
5df69d9034
Merge #5993
5993: Update chalk to 0.27 and add support for extern opaque types. r=crlf0710 a=crlf0710



Co-authored-by: Charles Lew <crlf0710@gmail.com>
2020-09-16 17:07:05 +00:00
Josh Stone
29c3421391 Don't return any TextEdit if formatting is unchanged
I found that `textDocument/formatting` was always returning a full
`TextEdit` replacement, even when there are no changes, which caused Vim
(w/ vim-lsp) to always indicate a modified buffer after formatting. We
can easily compare whether there were changes and return `null` if not,
so the client knows there's nothing to do.
2020-09-16 10:05:41 -07:00
Charles Lew
3fff5aa4d7 Use Ty::apply instead of simple and fix method resolution. 2020-09-17 00:58:41 +08:00
Charles Lew
eb96964756 Add a test. 2020-09-17 00:21:34 +08:00
Jonas Schievink
f792bc7ddd Add annotation-based nameres diagnostic tests 2020-09-16 17:26:51 +02:00
Jonas Schievink
603613a302 Update tests 2020-09-16 17:26:51 +02:00
Jonas Schievink
4785162b08 Track import sources and emit diagnostics 2020-09-16 17:26:51 +02:00
Jonas Schievink
4ac9a2e5d3 Leave extern crate items unresolved if they are 2020-09-16 17:26:51 +02:00
Jonas Schievink
2a9a66d254 Add diagnostic types for unresolved crates/imports 2020-09-16 17:26:51 +02:00