Commit graph

2923 commits

Author SHA1 Message Date
Alan Du
b28ca32db2 Fix clippy::or_fun_call 2019-06-04 18:05:07 -04:00
Alan Du
40424d4222 Fix clippy::identity_conversion 2019-06-04 18:05:07 -04:00
Alan Du
ed3d93b875 Fix clippy::single_char_pattern 2019-06-04 18:05:07 -04:00
Alan Du
682bf04bf4 Fix clippy::new_without_default 2019-06-04 18:05:07 -04:00
Alan Du
6939011b27 Fix clippy::assign_op_pattern 2019-06-04 18:05:07 -04:00
Alan Du
21d7964bc3 Fix clippy::useless_format 2019-06-04 18:05:07 -04:00
Alan Du
fb592d76aa Fix clippy::into_iter_on_ref 2019-06-04 18:05:07 -04:00
Alan Du
619a615298 Fix clippy::len_zero 2019-06-04 18:05:07 -04:00
Alan Du
7bcd8d6290 Fix clippy::unused_mut 2019-06-04 18:05:07 -04:00
Alan Du
6095e3fe19 Fix clippy::unnecessary_mut_passed 2019-06-04 18:05:07 -04:00
Alan Du
fafca4cb11 Fix clippy::ptr_arg 2019-06-04 18:05:07 -04:00
Alan Du
4e449fb0b0 Fix clippy::if_same_then_else 2019-06-04 18:05:07 -04:00
Alan Du
63e37f9536 Fix clippy::expect_fun_call 2019-06-04 18:05:07 -04:00
Alan Du
b9af1d7c42 Fix clippy::match_ref_pats 2019-06-04 18:05:07 -04:00
Alan Du
dddcb0ad94 Fix clippy::needless_return 2019-06-04 18:05:07 -04:00
Alan Du
ecd420636e Fix clippy::single_match 2019-06-04 18:05:07 -04:00
Simon Bihel
ec31f475ca
Use inline snapshots in complete_keyword 2019-06-04 21:26:12 +01:00
Aleksey Kladov
d2b23599b6 fix debug scopes 2019-06-04 14:46:22 +03:00
Alan Du
354db651da Fix clippy::clone_double_ref 2019-06-04 03:00:58 -04:00
Alan Du
573a6bb5c9 Fix clippy::match_bool 2019-06-04 03:00:58 -04:00
Alan Du
07ebf5528e Allow clippy::map_clone
We should turn it on after Iterator::copied stabilizes
2019-06-04 03:00:58 -04:00
Alan Du
557e90c6ca Allow clippy::needless_pass_by_value 2019-06-04 03:00:58 -04:00
Alan Du
a181fd318b Implement cargo lint to run clippy 2019-06-03 20:34:00 -04:00
Aleksey Kladov
5264711b5d add couple of debug utils 2019-06-04 00:27:49 +03:00
bors[bot]
6aa8d8b99d Merge #1369
1369: don't cache parses twice r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-06-02 17:21:42 +00:00
Aleksey Kladov
8b7f58976b don't cache parses twice
Before this commit, `Parse`s for original file ended up two times in
salsa's db: first, when we parse original file, and second, when we
parse macro or a file.

Given that parse trees are the worst ofenders in terms of memory, it
makes sense to make sure we store them only once.
2019-06-02 20:15:10 +03:00
bors[bot]
ae8fd982c0 Merge #1368
1368: Store referece instead of full token tree in tokenbuffer r=matklad a=edwin0cheng

This PR try to minimize the memory allocation in converting `SyntaxNode` to `TokenTree` by using reference isnteead of full token tree in `TokenBuffer`. 

Note that the final goal is replace `TokenTree` with TokenBuffer such that there is no conversion between them.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-06-02 17:09:49 +00:00
Edwin Cheng
824f413d75 unnecessary paranthesis 2019-06-03 01:05:58 +08:00
Edwin Cheng
54ea251bd4 Store referece in tokenbuffer 2019-06-03 00:54:33 +08:00
Aleksey Kladov
2f02e1a8ba collect macro queries 2019-06-02 18:58:49 +03:00
Aleksey Kladov
5af9e475f4 add AstDatabase 2019-06-02 12:27:36 +03:00
Aleksey Kladov
011599df27 collect types and bodies 2019-06-01 22:47:20 +03:00
Aleksey Kladov
f7d3a87305 collect impl source maps 2019-06-01 22:31:22 +03:00
Aleksey Kladov
d7a2a9171e don't cache ast_id_to_node 2019-06-01 22:14:42 +03:00
Aleksey Kladov
37e80c5297 show macro expanded trees in the stats as well 2019-06-01 22:13:24 +03:00
bors[bot]
ccec71165b Merge #1360
1360: Improve goto definition for MBE r=matklad a=edwin0cheng

This PR improve the macro resolution for goto definition and expression macro invocation by using proper path resolution for external macros. 



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-06-01 17:48:06 +00:00
Edwin Cheng
371961be0e Improve goto definition for MBE 2019-06-01 19:34:19 +08:00
bors[bot]
1e6b45b05a Merge #1359
1359: don't poison mutex around chalk r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-06-01 08:00:00 +00:00
Aleksey Kladov
f89d34be6a don't poison mutex around chalk
We use panics for cancellation, so we could trigger panic while
holding the solver. std::sync::Mutex will be poisoned as a result,
which and all further attempts to use solver (from other threads) will
panic as well.

This commit switches to parking_lot::Mutex which just unlocks on panic.
2019-06-01 10:57:44 +03:00
Aleksey Kladov
4dd7faed34 apply profile filter to top-level entries only 2019-06-01 10:41:47 +03:00
Aleksey Kladov
bf801953a3 rename 2019-06-01 10:31:40 +03:00
Aleksey Kladov
678a458543 move subs inside 2019-06-01 10:24:43 +03:00
Aleksey Kladov
78e17f65cf use sync queries for join lines and friends 2019-05-31 20:53:00 +03:00
Aleksey Kladov
c6537c3280 add sync requests 2019-05-31 20:50:16 +03:00
Aleksey Kladov
9697d8afad cleanup 2019-05-31 20:42:53 +03:00
Aleksey Kladov
15efd58274 cleanup 2019-05-31 20:30:14 +03:00
Aleksey Kladov
2d773a46c9 simplify 2019-05-31 20:23:56 +03:00
Aleksey Kladov
e1bda6aeda move completed requests to a separate file 2019-05-31 20:14:54 +03:00
Aleksey Kladov
838915c9a2 simplify 2019-05-31 19:24:33 +03:00
Aleksey Kladov
8bb02859e8 introduce constant 2019-05-31 19:20:22 +03:00
Aleksey Kladov
0e542936be minor 2019-05-31 19:17:46 +03:00
Laurențiu Nicola
be15541b03 Sort hover results in tests 2019-05-30 21:20:17 +03:00
Aleksey Kladov
b6a854e161 update ra_ide_api to use builtins 2019-05-30 16:10:07 +03:00
Aleksey Kladov
c6ee9d681c add tests for primitive types 2019-05-30 15:14:11 +03:00
Aleksey Kladov
97158f5c8a add built-in types to scopes 2019-05-30 15:03:58 +03:00
Aleksey Kladov
4e5b02966b add list of builtin types 2019-05-30 14:26:27 +03:00
Aleksey Kladov
e6545cc647 add ModuleDef::BuiltInType 2019-05-30 14:06:28 +03:00
Aleksey Kladov
54f77ad68d switch to upstream salsa 2019-05-30 13:05:09 +03:00
Aleksey Kladov
18ed351747 ⬆️ parking_lot 2019-05-30 12:02:30 +03:00
Aleksey Kladov
0ee5bd16c9 cancel salsa's validation
This small fix should improve rust-analyzer resopnsivness for
real-time operations like onEnter handling.

Turns out, salsa's validation can take hundreds of milliseconds, and,
in case no changes were made, it won't be triggering any queries.

Because we check for cancellation in queries, that means that
validation is not cancellable!

What this PR does is injecting check_canceled checks into validation,
by using salsa's event API, which wasn't meant to be used like this,
but, hey, it works!

Here's the onEnter handling before and after this change:

https://youtu.be/7-ffPzgvH7o
2019-05-30 10:06:02 +03:00
bors[bot]
8c3cd8f121 Merge #1346
1346: bump timeout for CI r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-29 19:18:57 +00:00
Aleksey Kladov
9304cb0263 bump timeout for CI 2019-05-29 22:14:06 +03:00
Aleksey Kladov
6bcc1b8b9e add cacellation checks to expensive queries 2019-05-29 22:13:03 +03:00
Laurențiu Nicola
b1e59cb095 Highlight primitive types 2019-05-29 21:54:22 +03:00
Aleksey Kladov
a9373c4220 less noisy status 2019-05-29 21:07:38 +03:00
Aleksey Kladov
5c410385fc optimization: cancel backlog in onEnter 2019-05-29 16:05:14 +03:00
Aleksey Kladov
2c9a1cb3dd add latest requests to status page 2019-05-29 15:47:46 +03:00
Aleksey Kladov
e45c350a3b log the actual time of requests 2019-05-29 14:59:01 +03:00
Aleksey Kladov
118a2113c1 trigger garbage collection *after* requests, not before 2019-05-29 14:37:04 +03:00
Aleksey Kladov
6a1e3e59cb more perf logging 2019-05-29 14:34:21 +03:00
Aleksey Kladov
a6f1b171bc silnce profiling in tests 2019-05-29 10:33:47 +03:00
Aleksey Kladov
38cb88307e flip Into to From 2019-05-29 10:31:07 +03:00
Aleksey Kladov
2e722ec54b show error offsets in tests 2019-05-29 10:31:07 +03:00
bors[bot]
7a1cae59ac Merge #1337
1337: Move syntax errors our of syntax tree r=matklad a=matklad

I am not really sure if it's a good idea, but `SyntaxError` do not really belong to a `SyntaxTree`. So let's just store them on the side?

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-29 06:40:39 +00:00
Laurențiu Nicola
9146a64386 Highlight type names correctly 2019-05-29 08:30:53 +03:00
Aleksey Kladov
80a1725147 fix todo 2019-05-28 18:50:53 +03:00
Aleksey Kladov
61e1474ab3 fix typos in mbe tests 2019-05-28 18:46:11 +03:00
Aleksey Kladov
c8bcfe6a05 fix syntax errors in tests 2019-05-28 18:07:39 +03:00
Aleksey Kladov
2e3f5af9d4 move mbe to the new API 2019-05-28 17:39:01 +03:00
Aleksey Kladov
0efbcdf435 remove old parsing methods 2019-05-28 17:34:28 +03:00
Aleksey Kladov
310bfe57bd update test data 2019-05-28 17:09:45 +03:00
Aleksey Kladov
bc2550b196 update tests 2019-05-28 16:59:22 +03:00
Aleksey Kladov
afeaea7051 drop error from SOurceFile constructor 2019-05-28 16:34:23 +03:00
Aleksey Kladov
1cece9f219 return errors from tree builder 2019-05-28 16:26:14 +03:00
Aleksey Kladov
90926b9479 drop errors from SyntaxNode 2019-05-28 16:15:17 +03:00
Aleksey Kladov
f52eda675e add Parse 2019-05-28 16:15:17 +03:00
bors[bot]
0545e4781d Merge #1336
1336: Refactor SubtreeSource r=matklad a=edwin0cheng

This PR simplify `SubtreeSource` by removing `SubtreeWalk` and `Querier` and only walk through the top level `TokenTree` when collecting token from source, by comparing two cursors directly.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-28 06:03:47 +00:00
Edwin Cheng
464a00814c Use cfg(test) instead of allow(unused) 2019-05-28 10:55:08 +08:00
Edwin Cheng
a3b9aecc9b Minor use module 2019-05-28 00:54:32 +08:00
Edwin Cheng
98aac6b751 Simpliy how collecting token from src 2019-05-28 00:38:55 +08:00
Edwin Cheng
c8c9230dd2 Add more helper func in Cursor 2019-05-27 23:51:52 +08:00
Edwin Cheng
d833ded3b4 Remove Queier and SubtreeWalk 2019-05-27 23:20:43 +08:00
bors[bot]
b2bf41b2ba Merge #1334
1334: check for cancellation during macro expansion r=matklad a=matklad

closes #1331

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-27 11:45:41 +00:00
Aleksey Kladov
a2845bb1f5 check cancellation when expanding macros 2019-05-27 14:41:14 +03:00
Aleksey Kladov
0d2f97e83e specifically profile cancellation 2019-05-27 14:27:05 +03:00
Aleksey Kladov
cf214ac4e7 enable profiling in tests 2019-05-27 14:20:11 +03:00
Pascal Hertleif
1e6ba19015 Make rainbows optional 2019-05-27 11:44:46 +02:00
Pascal Hertleif
4ac338b608
rename stray id field 2019-05-27 11:26:35 +02:00
Pascal Hertleif
5abcca516d
make it build again 2019-05-27 11:26:35 +02:00
Pascal Hertleif
2b200f6e1a
Disable broken struct field rainbowing 2019-05-27 11:26:35 +02:00
Pascal Hertleif
43d5a49653
More clever highlighting, incl draft for structs 2019-05-27 11:26:35 +02:00
Pascal Hertleif
ed89b0638b
Hash based on binding name and shadow counter 2019-05-27 11:26:35 +02:00
Pascal Hertleif
5bf3e949e8
Semantic highlighting spike
Very simple approach: For each identifier, set the hash of the range
where it's defined as its 'id' and use it in the VSCode extension to
generate unique colors.

Thus, the generated colors are per-file. They are also quite fragile,
and I'm not entirely sure why. Looks like we need to make sure the
same ranges aren't overwritten by a later request?
2019-05-27 11:26:33 +02:00
Aleksey Kladov
ce040aa907 add profile calls to real-time requests 2019-05-27 11:48:23 +03:00
bors[bot]
bdd779aa44 Merge #1277
1277: Improve macro item resolution r=matklad a=edwin0cheng

~This PR add a new namespace `Macros` in `per_ns.rs` to allow following use case:~
This PR improve macro item resolution to allow following use case:

```rust
//- /main.rs     
use foo::bar;
bar!();

//- /lib.rs  (crate foo)
#[macro_export]
macro_rules! bar{
() => {
    struct Foo { field: u32 } 
}
```


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-27 07:38:21 +00:00
Edwin Cheng
6d68d60d32 Formatting 2019-05-27 15:37:22 +08:00
bors[bot]
ce694ae118 Merge #1328
1328: Change TokenSource to iteration based r=matklad a=edwin0cheng

This PR change the `TokenSource` trait from random access to be an iteration based trait:
```rust

/// `TokenSource` abstracts the source of the tokens parser operates one.
///
/// Hopefully this will allow us to treat text and token trees in the same way!
pub trait TokenSource {
    fn current(&self) -> Token;

    /// Lookahead n token
    fn lookahead_nth(&self, n: usize) -> Token;

    /// bump cursor to next token
    fn bump(&mut self);

    /// Is the current token a specified keyword?
    fn is_keyword(&self, kw: &str) -> bool;
}

/// `TokenCursor` abstracts the cursor of `TokenSource` operates one.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Token {
    /// What is the current token?
    pub kind: SyntaxKind,

    /// Is the current token joined to the next one (`> >` vs `>>`).
    pub is_jointed_to_next: bool,
}
```

Note that the refactoring based on this new trait will be separated to incoming PRs

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-27 07:28:13 +00:00
Edwin Cheng
d6e6a98c03 Add Test for new item resolution 2019-05-26 20:11:18 +08:00
Edwin Cheng
b72074a715 Use ItemOrMacro in item resolution 2019-05-26 20:10:56 +08:00
Edwin Cheng
c0dc14ba5a Add Either dep 2019-05-26 20:10:05 +08:00
Edwin Cheng
d5fbce4458 Put back unexpaned_macros after resolve 2019-05-26 13:38:03 +08:00
Edwin Cheng
90764fc54b Remove duplicated code 2019-05-26 02:41:00 +08:00
Edwin Cheng
816147c4b5 Simplify token_tree_to_xxx 2019-05-25 21:55:46 +08:00
Edwin Cheng
fcb1eef323 Change TokenSource to iteration based 2019-05-25 20:41:03 +08:00
Aleksey Kladov
c6e905a79f Colorize Rust code as HTML 2019-05-25 13:42:34 +03:00
Aleksey Kladov
0270b4bc57 reformat 2019-05-24 01:48:44 +03:00
Aleksey Kladov
53ae63835d ⬆️ rustc 2019-05-24 01:46:23 +03:00
bors[bot]
de87fe293e Merge #1317
1317: profile highlighting r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-23 18:25:35 +00:00
Aleksey Kladov
f6d2c3f9d5 profile highlighting 2019-05-23 21:19:54 +03:00
bors[bot]
afb792acb7 Merge #1316
1316: Simplify code model r=matklad a=matklad

* remove references from types which are now id-based
* remove api/impl separation, as the impl is a tiny fraction of API anyway 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-23 18:16:46 +00:00
Aleksey Kladov
ef3169a33a rename code_model_api -> code_model 2019-05-23 21:14:19 +03:00
Aleksey Kladov
0e57d58dd0 kill code_model_impl 2019-05-23 21:13:22 +03:00
Aleksey Kladov
ce82fbfc44 remove more references 2019-05-23 21:08:10 +03:00
Aleksey Kladov
bde9cab66e remove references 2019-05-23 21:01:31 +03:00
Aleksey Kladov
7f22f90503 kill krate_impl 2019-05-23 20:30:09 +03:00
Aleksey Kladov
dbd02546b9 fix signature 2019-05-23 20:25:55 +03:00
bors[bot]
1dc9adc6e2 Merge #1290
1290: Add Union to code_model r=matklad a=matklad

@flodiebold I am conflicted about two possible implementation approaches:

* we can add a separate `struct Union` to code model
* we can add `fn is_union(&self)` to existing `Struct`

This PR goes with the former approach, because it seems like Unions are sufficiently different in semantics to warrant a separate types. Which is in contrast to Syntax Tree, where both structs and unions share the same node kind, because their syntax is the same. 

What would be the right thing to do here?

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-23 17:23:17 +00:00
Aleksey Kladov
5d54aa6781 add union to code_model 2019-05-23 20:18:47 +03:00
bors[bot]
ef00b5af1c Merge #1312
1312: Introduce TokenBuffer r=matklad a=edwin0cheng

As discussed in Zulip, this PR Introduce `TokenBuffer` , a safe version of  `syn` crate `TokenBuffer` which support cursor based traversal of `tt::TokenTree`. This is the basis of incoming refactoring of `TokenSource` iterator based API.

This PR do the following things:

* Add TokenBuffer in `ra_tt` crate.
* Try to use this new API to refactor the `SubtreeSource` to prove it usage.




Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-23 14:31:26 +00:00
Edwin Cheng
63b67134fd Use slice instead of Vec 2019-05-23 21:05:22 +08:00
Laurențiu Nicola
f1ec88cc56 Improve highlighting of name refs 2019-05-23 15:31:35 +03:00
bors[bot]
4466568525 Merge #1311
1311: Move NameRef classification logic out of reference_definition r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2019-05-23 09:39:22 +00:00
Laurențiu Nicola
444e52e519 Move NameRef classification logic out of reference_definition 2019-05-23 12:32:47 +03:00
Dylan Moonfire
cbd131acbe updated gen_lsp_server examples
- updated the documentation with an example that has no errors with current compiler
- added two example code to test compilation and show in use
2019-05-22 20:35:12 -05:00
Edwin Cheng
27ae626cfb Formatting 2019-05-23 09:31:36 +08:00
Edwin Cheng
dd50ca7c5e Refactor SubtreeSource 2019-05-23 02:23:56 +08:00
Edwin Cheng
4d7a567bc5 Introduce TokenBuffer 2019-05-23 02:09:26 +08:00
Aleksey Kladov
f15bb3c98a add profile calls to parsing/expansion routines 2019-05-22 11:31:07 +03:00
bors[bot]
67d5927b16 Merge #1281
1281: Move arm cond to match guard r=matklad a=unrealhoang

I did split the rename to another commit, yet Github UI still show entirely new file change. Please review using commits.

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-05-22 07:39:54 +00:00
Aleksey Kladov
6fed943bd2 better profilig 2019-05-22 00:00:58 +03:00
Florian Diebold
ced971ee9f Fix crash with int vars in canonicalization 2019-05-21 20:40:29 +02:00
Florian Diebold
f613c48d2e Use fuel branch for Chalk
This makes sure we don't take too long in trait solving.
2019-05-21 20:40:29 +02:00
Aleksey Kladov
ed943adb29 re-enable chalk 2019-05-21 20:57:36 +03:00
Aleksey Kladov
26463f189f publish gen_lsp_server 0.2 2019-05-21 18:57:33 +03:00
Unreal Hoang
08e954f0fd
add assist to move arm condition to match guard 2019-05-21 23:31:51 +09:00
bors[bot]
51e82fe6d2 Merge #1299
1299: Use ThemeColor and add support for light themes r=matklad a=lnicola

Part of #1294.

- switch to `ThemeColor`
- add light and high contrast theme definitions
- highlight control flow keywords and `unsafe`


Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2019-05-21 13:58:42 +00:00
Laurențiu Nicola
b08362f6d2 Address feedback 2019-05-21 16:28:10 +03:00
Aleksey Kladov
f63be06002 profile type inference 2019-05-21 16:26:13 +03:00
Aleksey Kladov
0f3e85002b profile implements query 2019-05-21 16:04:17 +03:00
Aleksey Kladov
908c9589a8 fix odrer-of-iteration bug in tests 2019-05-21 14:51:52 +03:00
Laurențiu Nicola
9ade271a67 Use ThemeColor and add support for light themes 2019-05-21 14:19:08 +03:00
Aleksey Kladov
0efb5364c3 sort hash maps for tests 2019-05-21 14:14:31 +03:00
bors[bot]
c59a3cdb03 Merge #1296
1296: ⬆️ insta r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-21 10:28:55 +00:00
Aleksey Kladov
507c97a18c ⬆️ insta 2019-05-21 13:21:54 +03:00
Aleksey Kladov
69341a0bbe add _query to query functions 2019-05-21 12:44:08 +03:00
Aleksey Kladov
765f93b8d8 add is_union to structs AST 2019-05-21 01:15:56 +03:00
Aleksey Kladov
4ca8331933 remove minor code duplication 2019-05-21 01:02:29 +03:00
bors[bot]
9383ae720b Merge #1289
1289: simplify r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-20 20:02:18 +00:00
Aleksey Kladov
9680ae865e simplify 2019-05-20 23:01:49 +03:00
bors[bot]
11742e3371 Merge #1287
1287: Add support of matching literal in mbe r=matklad a=edwin0cheng

This PR adds support of matching literal in mbe , which used in our `T` macro :

```rust
macro_rules! foo {
    ('(') => {
        fn foo() {}
    }
}
```

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-20 19:27:05 +00:00
Aleksey Kladov
87316db0b1 output the progress for real 2019-05-20 21:20:52 +03:00
Edwin Cheng
ad9d2012de Fix match literal 2019-05-20 18:29:02 +08:00
bors[bot]
3894eb77d8 Merge #1286
1286: Add infer for generic default type r=flodiebold a=edwin0cheng

This PR add infer support for generic default type:

```
struct Gen<T=u32> {
    val: T
}
```

* add the (unresolved) defaults from the definition to GenericParams
* add a query generic_defaults that resolves those defaults to types and returns a Substs
* add the missing type in `substs_from_path_segment`
* add tests

based on the idea in this [comment](https://github.com/rust-analyzer/rust-analyzer/issues/1099#issuecomment-484206279)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-20 09:52:15 +00:00
Edwin Cheng
3fc344b9f1 Use normal iteration instead of walk_mut 2019-05-20 17:48:58 +08:00
Edwin Cheng
d4dc879415 Add infer for generic default type 2019-05-19 21:08:16 +08:00
Edwin Cheng
e74d8f148b Add default type to GenericParam 2019-05-19 17:44:29 +08:00
Aleksey Kladov
fcffa6ba6b Assert that DB is unwind-safe, instead of proving
Unfortunately, that `: RefUnwindSafe` bound gives rustc a hard time,
so let's remove it for know.

See

* https://github.com/rust-analyzer/rust-analyzer/issues/1283
* https://github.com/rust-lang/rust/pull/60444
* https://github.com/rust-lang/rust/issues/58291

closes #1283
2019-05-18 13:05:42 +03:00
Unreal Hoang
99ad6143cd
rename 2019-05-16 12:53:52 +09:00
Aleksey Kladov
e29a58995b ⬆️ text_unit 2019-05-15 19:19:05 +03:00
Sergey Parilin
993abedd77 apply T! macro where it is possible 2019-05-15 15:35:47 +03:00
Sergey Parilin
d77175ce28 fixed macro for brackets 2019-05-15 12:34:48 +03:00
Aleksey Kladov
d4b1e958c5 show current function in analysis-stats progress bar 2019-05-14 09:58:41 +03:00
Aleksey Kladov
caa8663c08 allow expanding expressions 2019-05-14 09:03:43 +03:00
Aleksey Kladov
16c7405262 expand to syntax node 2019-05-14 09:03:43 +03:00
Aleksey Kladov
101b3abfd7 store macro kind in HirFileId 2019-05-14 09:03:43 +03:00
bors[bot]
ee0ab7c00b Merge #1272
1272: Error out non single root token tree conversion r=matklad a=edwin0cheng

This PR add a check to prevent non single root token tree conversion between token trees and syntax tree.

It should prevent the assert produced in #1267.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-14 05:41:23 +00:00
Edwin Cheng
10ecb11ff5 Error out non single root token tree conversion 2019-05-14 07:59:28 +08:00
bors[bot]
bebc5c7166 Merge #1271
1271: make AstId untyped r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-13 21:04:04 +00:00
Florian Diebold
c29a692137 Increase Chalk solver max_size back to 4
Reducing it to 2 was just a failed attempt to see whether that would help fix
some slow cases; in fact, it can create new slow cases by replacing concrete
types by variables.
2019-05-13 22:20:39 +02:00
Aleksey Kladov
549728bba8 make AstId untyped 2019-05-13 19:39:06 +03:00
bors[bot]
033a32f349 Merge #1257
1257: Implemented tkn! macro for syntax kinds r=matklad a=pasa

Implementation of #1248

Co-authored-by: Sergey Parilin <sergey.parilin@fxdd.com>
2019-05-13 13:49:14 +00:00
Sergey Parilin
57bb618fd3 Implemented T! macro for syntax kinds 2019-05-13 15:19:57 +03:00
Aleksey Kladov
9cba67b2ad simplify 2019-05-12 23:03:37 +03:00
Aleksey Kladov
98531dc785 simplify 2019-05-12 22:51:03 +03:00
Florian Diebold
bc59f83991 Use traits from prelude for method resolution 2019-05-12 20:25:26 +02:00
Florian Diebold
7fda874dd4 Blacklist some traits from being considered in where clauses
For Send/Sync/Sized, we don't handle auto traits correctly yet and because they
have a lot of impls, they can easily lead to slowdowns. In the case of
Fn/FnMut/FnOnce, we don't parse the special Fn notation correctly yet and don't
handle closures yet, so we are very unlikely to find an impl.
2019-05-12 20:23:57 +02:00
Florian Diebold
c8b85891b0 Fix impl blocks with unresolved target trait being treated as inherent impls 2019-05-12 20:21:45 +02:00
bors[bot]
02ba107bbf Merge #1265
1265: drop obsolete render test subcommand r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-12 18:01:28 +00:00
Aleksey Kladov
8ee2926aa2 drop obsolete render test subcommand 2019-05-12 21:00:04 +03:00
Aleksey Kladov
915489714b allow to specify path in analysis-stats 2019-05-12 20:54:44 +03:00
Florian Diebold
cbe75676b9 Add support for inline bounds
E.g. impl<T: Clone> Foo for T.
2019-05-11 16:56:36 +02:00
Florian Diebold
d6dc75f9f2 Handle auto traits & negative impls
We don't pass field types to Chalk yet though, so the auto trait inference won't
be correct.
2019-05-11 16:21:20 +02:00
Florian Diebold
7744cd41e2 Reduce Chalk max_size parameter, add test for slow case 2019-05-11 16:21:20 +02:00
Florian Diebold
d8cd0e36f5 Handle Chalk conversion for FnDef 2019-05-11 16:21:20 +02:00
Florian Diebold
58b68966bf Handle resolution errors in where clauses
This is slightly hacky, but maybe more elegant than alternative solutions: We
just use a hardcoded Chalk trait ID which we special-case to have no impls.
2019-05-11 16:21:20 +02:00
Florian Diebold
50bbf9eb09 Handle where clauses in trait solving 2019-05-11 16:21:20 +02:00
Aleksey Kladov
1667b5cf52 switch to once_cell from lazy_static 2019-05-07 20:54:33 +03:00
bors[bot]
70cd5ffbf5 Merge #1251
1251: Chalk integration improvements r=matklad a=flodiebold

A few improvements that came up while working on where clause support:
 - turn `implements` into a query again to improve performance
 - allow skipping to a specific function with `analysis-stats`, e.g. `ra_cli analysis-stats --only world_symbols`
 - deduplicate impls in impls_for_trait -- previously many impls e.g. from std where repeated many times, this should help performance as well...
 - add a `HirDisplay` implementation for TraitRef (not used here anywhere, but useful for debugging)

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-05-07 17:37:47 +00:00
Aleksey Kladov
313314e14b share literal validation logic with compiler 2019-05-07 19:41:59 +03:00
Florian Diebold
530b3047ed Deduplicate impls in impls_for_trait
This was duplicating impls in dependencies a lot...
2019-05-07 13:45:29 +02:00