Commit graph

5344 commits

Author SHA1 Message Date
Aleksey Kladov
2638bec66c Merge refs_to_def and process_def 2020-03-04 12:22:06 +01:00
Aleksey Kladov
1874b6738a Move ReferenceKind 2020-03-04 12:22:06 +01:00
Aleksey Kladov
a549da7e3e Move SearchScope 2020-03-04 12:22:06 +01:00
bors[bot]
66ec6bdfb0
Merge #3432
3432: Feature/snippet completions r=matklad a=iTZAvishay

This PR implements #1705 and is based on #3430 to avoid future conflicts.

The completions are placing default values with the names of the parameters, demo: 
![call_me_demo](https://user-images.githubusercontent.com/5567310/75828341-461ca400-5db4-11ea-88d8-88e59ac1a197.gif)


Co-authored-by: Avishay Matayev <me@avishay.dev>
2020-03-04 11:05:14 +00:00
Aleksey Kladov
5095573139 Remove stray FIXME 2020-03-04 11:55:25 +01:00
Aleksey Kladov
19115e9fab Support cross-crate marks 2020-03-04 11:55:25 +01:00
Avishay Matayev
fb34a5ba06 Support function's completion snippet
Note that `detail` was replced with `function_signature` to avoid
calling `from` on FunctionSignature twice.

I didn't add new tests because the current ones seem enough.
2020-03-04 11:03:32 +02:00
bors[bot]
437329d3f5
Merge #3429
3429: Fix panic on eager expansion r=matklad a=edwin0cheng

When lazy expanding inside an eager macro, its *parent* file of that lazy macro call must be already exists such that a panic is occurred because that parent file is the eager macro we are processing.

This PR fix this bug by store the argument syntax node as another eager macro id for that purpose.

Personally I don't know if it is a good answer for this bug. 




Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-04 00:05:10 +00:00
Florian Diebold
e55fc286fc Fix completion snippet for reexported functions
Fixes #3356.
2020-03-03 20:49:50 +01:00
Edwin Cheng
5ea83fee01 Fixed a typo in comment 2020-03-04 02:57:54 +08:00
Edwin Cheng
e04c0f4222 Fix panic on eager expansion 2020-03-04 02:41:33 +08:00
bors[bot]
5abc45982b
Merge #3428
3428: Move reference classification to ra_ide_db r=matklad a=matklad

Lost some marks along the way :-(



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-03 17:55:25 +00:00
Aleksey Kladov
53cab1cd21 Fix imports 2020-03-03 18:54:39 +01:00
Aleksey Kladov
177229bfde Move reference classification to ra_ide_db
Lost some marks along the way :-(
2020-03-03 18:50:15 +01:00
bors[bot]
074474fe00
Merge #3427
3427: Rename NameDefinition -> Definition r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-03 17:41:25 +00:00
Aleksey Kladov
d49a4d1863 Rename NameDefinition -> Definition 2020-03-03 18:40:27 +01:00
bors[bot]
7a322f9aff
Merge #3392
3392: Implement concat eager macro  r=matklad a=edwin0cheng

This PR implements the following things:

1. Add basic eager macro infrastructure by introducing `EagerCallId` such that the new `MacroCallId` is defined as :

```
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MacroCallId {
    LazyMacro(LazyMacroId),
    EagerMacro(EagerMacroId),
}
```

2. Add `concat!` builtin macro.




Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-03 17:30:08 +00:00
Edwin Cheng
4d5e80c6c8 Fix for rebasing 2020-03-04 01:24:33 +08:00
bors[bot]
13b25d73b5
Merge #3426
3426: Refactor reference search a bit r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-03 17:23:39 +00:00
Aleksey Kladov
7d71cc72b5 Refactor reference search a bit 2020-03-03 18:22:52 +01:00
Edwin Cheng
1e9a3233f7 Move pub function first 2020-03-04 01:21:14 +08:00
Edwin Cheng
02b865019b Add doc about eager expansion name resolution 2020-03-04 01:21:14 +08:00
Edwin Cheng
fe04c28b59 Add test 2020-03-04 01:21:14 +08:00
Edwin Cheng
1465cc0c4f Implement concat macro 2020-03-04 01:21:14 +08:00
Edwin Cheng
0d55454073 Add LazyMacroId 2020-03-04 01:21:14 +08:00
bors[bot]
cebb995d21
Merge #3425
3425: Fix a bug for single dollar sign macro r=matklad a=edwin0cheng

This PR fixed a bug to allow the following valid `macro_rules!` :

```rust
macro_rules! m {
    ($) => ($)
}
```

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-03 17:07:27 +00:00
Edwin Cheng
3dc3d9d18f Fix a bug for single dollar sign macro 2020-03-04 01:03:44 +08:00
bors[bot]
674770ef04
Merge #3422
3422: Add profile call r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-03 16:17:38 +00:00
Aleksey Kladov
2ff2c29a1e Add profile call 2020-03-03 17:11:25 +01:00
Aleksey Kladov
cf0ececb7a Highlight assist tests 2020-03-03 17:03:46 +01:00
Aleksey Kladov
1cca6b2a3d Fix applicability of inline local 2020-03-03 16:56:42 +01:00
Aleksey Kladov
8f3677a94a Remove stray dbg 2020-03-03 16:41:52 +01:00
Laurențiu Nicola
91e02ace06 Drop larlpop-intern dep 2020-03-03 07:57:16 +02:00
Laurențiu Nicola
f60cf882a8 Update chalk for Ty interners 2020-03-03 00:02:19 +02:00
Laurențiu Nicola
807a56bebf Update chalk for RawId removal 2020-03-02 23:30:38 +02:00
kjeremy
2d9acfb118 Simplify by using to_vec 2020-03-02 14:05:44 -05:00
bors[bot]
a484e9c730
Merge #3406
3406: Simplify: remove couple of useless functions r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-02 18:09:00 +00:00
Aleksey Kladov
1a6f51da66 Simplify: remove couple of useless functions 2020-03-02 19:03:46 +01:00
bors[bot]
7928ac4bbd
Merge #3405
3405: More principled approach for gotodef for field shorhand r=matklad a=matklad

Callers can now decide for themselves if they should prefer field or
local definition. By default, it's the local.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-02 18:01:50 +00:00
Aleksey Kladov
2716a1fa3f More principled approach for gotodef for field shorhand
Callers can now decide for themselves if they should prefer field or
local definition. By default, it's the local.
2020-03-02 19:00:38 +01:00
kjeremy
c6f4e8de5e lsp-types 0.72 2020-03-02 11:52:46 -05:00
bors[bot]
02f761ba4b
Merge #3397 #3398
3397: Minimal viable meta r=matklad a=matklad



bors r+
🤖

3398: Reformat? r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-02 13:31:56 +00:00
Aleksey Kladov
62e62d1c23 Reformat? 2020-03-02 14:28:34 +01:00
bors[bot]
79c874803b
Merge #3385
3385: Fix #3373 r=matklad a=flodiebold

Basically, we need to allow variables in the caller self type to unify with the
impl's declared self type. That requires some more contortions in the variable
handling. I'm looking forward to (hopefully) handling this in a cleaner way when
we switch to Chalk's types and unification code.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-03-02 13:23:24 +00:00
Aleksey Kladov
503ffb4893 One more assert 2020-03-02 13:59:35 +01:00
Aleksey Kladov
8f8980cedf Tighten up an assert 2020-03-02 13:45:26 +01:00
bors[bot]
b71fc18abe
Merge #3387
3387: Type inference for slice patterns r=flodiebold a=JoshMcguigan

Fixes #3043 

Notes to reviewer:

1. This only works if `expected` is `Ty::Apply`. I'm not sure of the implications of this.
1. This only works if the slice pattern only has a prefix. I think this means it doesn't work for subslice patterns, which are currently only available behind a feature flag.

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-01 22:36:47 +00:00
Josh Mcguigan
f5efa17515 handle array pattern matching type inference 2020-03-01 14:02:32 -08:00
Josh Mcguigan
b9ef7a6b98 remove match statement, handle suffix 2020-03-01 12:13:05 -08:00
Josh Mcguigan
d0e282f6b1 handle arbitrary length slices 2020-03-01 07:35:15 -08:00
Josh Mcguigan
f353625705 match single prefix slice 2020-03-01 06:25:38 -08:00
bors[bot]
ea67e2346e
Merge #3384
3384: fix #2377 super::super::* r=flodiebold a=JoshMcguigan

Thanks @matklad for the detailed explanation on #2377. I believe this fixes it.

One thing I'm not sure about is you said the fix would involve changing `crates/ra_hir_def/src/path/lower/lower.rs`, but I only changed `crates/ra_hir_def/src/path/lower/lower_use.rs`. I'm not sure what kind of test code I'd have to write to expose the issue in `lower.rs`, but I'd be happy to add it if you are able to provide additional guidance. 

closes #2377

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-01 13:36:44 +00:00
Florian Diebold
336a3c6121 Fix #3373
Basically, we need to allow variables in the caller self type to unify with the
impl's declared self type. That requires some more contortions in the variable
handling. I'm looking forward to (hopefully) handling this in a cleaner way when
we switch to Chalk's types and unification code.
2020-03-01 14:31:35 +01:00
Josh Mcguigan
0057d1e10d fix completion for super::super:: 2020-02-29 21:04:21 -08:00
Josh Mcguigan
69faf81e0d fix #2377 super::super::* 2020-02-29 19:48:55 -08:00
bors[bot]
6db2da4993
Merge #3383
3383: Slightly refactor inlay hints r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-29 22:32:27 +00:00
Aleksey Kladov
584c8d9875 Slightly refactor inlay hints 2020-02-29 23:24:50 +01:00
bors[bot]
61fe34b709
Merge #3382
3382: ra_project_model: migrate to Sysroot::alloc() r=matklad a=Veetaha



Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-29 22:24:21 +00:00
Veetaha
9f1adf8498 ra_project_model: migrate to Sysroot::alloc() 2020-03-01 00:16:57 +02:00
bors[bot]
6ee3470975
Merge #3381
3381: Remove debug print r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-29 22:10:14 +00:00
Aleksey Kladov
2e0d89401a Remove debug print 2020-02-29 23:03:49 +01:00
Florian Diebold
31171eed5e Do autoderef for indexing 2020-02-29 22:48:53 +01:00
Florian Diebold
e313efb992 Do array unsizing for method receivers
It turns out rustc actually only unsizes array method receivers, so we don't
need to do any trait solving for this (at least for now).

Fixes #2670.
2020-02-29 22:48:53 +01:00
Aleksey Kladov
a1e1869554 Rename ast::ImplBlock -> ast::ImplDef 2020-02-29 21:33:15 +01:00
Aleksey Kladov
f316e074d2 Add a FIXME 2020-02-29 21:23:16 +01:00
Aleksey Kladov
7f09083c6f Handle tuple fields as well 2020-02-29 18:35:45 +01:00
Aleksey Kladov
14ea21617a Minor 2020-02-29 18:34:34 +01:00
Aleksey Kladov
28332d9b63 Simplify SourceBinder 2020-02-29 18:32:18 +01:00
Aleksey Kladov
a6a623dfbb Small cleanup 2020-02-29 16:57:56 +01:00
bors[bot]
099a8f37f5
Merge #3309
3309: Find cargo toml up the fs r=matklad a=not-much-io

Currently rust-analyzer will look for Cargo.toml in the root of the project and if failing that then go down the filesystem until root.

This unfortunately wouldn't work automatically with (what I imagine is) a fairly common project structure. As an example with multiple languages like:
```
js/
  ..
rust/
  Cargo.toml
  ...
```

Added this small change so rust-analyzer would glance one level up if not found in root or down the filesystem.

## Why not go deeper?

Could be problematic with large project vendored dependencies etc.

## Why not add a Cargo.toml manual setting option?

Loosely related and a good idea, however the convenience of having this automated also is hard to pass up. 

## Testing?

Build a binary with various logs and checked it in a project with such a structure:

```
[ERROR ra_project_model] find_cargo_toml()
[ERROR ra_project_model] find_cargo_toml_up_the_fs()
[ERROR ra_project_model] entities: ReadDir("/workspaces/my-project")
[ERROR ra_project_model] candidate: "/workspaces/my-project/rust/Cargo.toml", exists: true
```

## Edge Cases?

If you have multiple Cargo.toml files one level deeper AND not in the root, will get whatever comes first (order undefined), example:
```
crate1/
    Cargo.toml
crate2/
     Cargo.toml
... (no root Cargo.toml)
```

However this is quite unusual and wouldn't have worked before either. This is only resolvable via manually choosing.

Co-authored-by: nmio <kristo.koert@gmail.com>
2020-02-29 15:36:03 +00:00
Florian Diebold
5fe220b987 Fix a common false-positive type mismatch
E.g. for `&{ some_string() }` in a context where a `&str` is expected, we
reported a mismatch inside the block. The problem is that we're passing an
expectation of `str` down, but the expectation is more of a hint in this case.
There's a long comment in rustc about this, which I just copied.

Also, fix reported location for type mismatches in macros.
2020-02-29 15:31:07 +01:00
nmio
b9fbb3da17 lint warn fix 2020-02-29 13:14:31 +00:00
nmio
e15424c1b7 keep one CargoTomlNotFoundError 2020-02-29 13:05:10 +00:00
Aleksey Kladov
9abcab1669 Fix typo 2020-02-29 13:51:23 +01:00
Aleksey Kladov
5f8b37563e Cleanup editing API 2020-02-29 13:51:23 +01:00
Aleksey Kladov
ca713e462b More orthogonal API for building paths 2020-02-29 11:55:36 +01:00
Aleksey Kladov
067cb928f0 Simplify 2020-02-28 22:43:13 +01:00
Aleksey Kladov
ff42008679 Move insert_use util to utils 2020-02-28 21:53:20 +01:00
Aleksey Kladov
e7c82eab21 Reduce visibility 2020-02-28 17:28:29 +01:00
bors[bot]
c692e07b4f
Merge #3367
3367: Fix highlighting of const patterns r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-28 15:56:07 +00:00
Aleksey Kladov
56ce34c6a7 Correctly flag 'lifetime definitions as definitions 2020-02-28 16:53:12 +01:00
Aleksey Kladov
5ebfcb9cb7 Fix highlighting of const patterns 2020-02-28 16:38:36 +01:00
bors[bot]
93f632ca4e
Merge #3366
3366: Simpilfy original_range logic r=matklad a=edwin0cheng

This PR fixed another [bug](https://github.com/rust-analyzer/rust-analyzer/issues/3000#issuecomment-592474844) which incorrectly map the wrong range of `punct` in macro_call and simplify the logic a little bit by introducing an `ascend_call_token` function.



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-02-28 15:07:33 +00:00
Edwin Cheng
7a5ff0f37c Simpilfy origin_range logic 2020-02-28 22:53:59 +08:00
Aleksey Kladov
209eb32796 Classify name takes const patterns into account 2020-02-28 15:27:52 +01:00
Aleksey Kladov
da40149572 Fix union classification 2020-02-28 15:03:09 +01:00
bors[bot]
2995fd2c87
Merge #3363
3363: Cleanup highlighting tags r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-28 13:48:42 +00:00
Aleksey Kladov
9464ca97c9 Fix highlighting test 2020-02-28 14:47:33 +01:00
Aleksey Kladov
701cf43606 Cleanup highlighting tags 2020-02-28 12:13:37 +01:00
Aleksey Kladov
996e18846d add more tags 2020-02-28 10:39:31 +01:00
bors[bot]
553353e316
Merge #3360
3360: Parse attribues in RHS of let statments r=matklad a=edwin0cheng

Fixed #3315

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-02-28 09:23:41 +00:00
bors[bot]
4741ae7852
Merge #3359
3359: Remove AnalysisHost::type_of  r=matklad a=edwin0cheng

This PR remove ` AnalysisHost::type_of` (It is subsume by hover now) and use `Semantics::type_of_x` to infer the type inside `hover` directly. 

And this also solved a bug : Right now hovering on a string literal inside a macro will show up a `&str` popup correctly. (Except if that involved builtin macro, e.g. `println`)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-02-28 07:53:19 +00:00
Edwin Cheng
cda04d2077 Fix typo 2020-02-28 15:39:34 +08:00
Edwin Cheng
f4e48ad3e4 Parse attr in rhs of let stmts 2020-02-28 13:08:47 +08:00
Edwin Cheng
5f30dd6f72 Remove hover::type_of 2020-02-28 11:37:22 +08:00
Douglas Campos
34a7e4fbaf introduce const visibility assist 2020-02-28 01:15:17 +00:00
nmio
12b595e817 remove code used for testing 2020-02-27 22:06:51 +00:00
nmio
f9f8edfb06 fix unneeded body 2020-02-27 22:03:29 +00:00
nmio
9391b1c8ce fixes and improvements 2020-02-27 21:52:10 +00:00
Aleksey Kladov
e74484e133 Refactor string literals 2020-02-27 17:19:53 +01:00