Commit graph

10166 commits

Author SHA1 Message Date
Kirill Bulatov
e74c55bb4a Refactor the import location 2021-03-08 23:59:20 +02:00
Kirill Bulatov
89d410cef5 Do not propose already imported imports 2021-03-08 23:59:20 +02:00
Kirill Bulatov
9482353fa8 Properly handle turbofishes in qualifiers 2021-03-08 23:59:20 +02:00
Kirill Bulatov
d386481fac Fix some tests 2021-03-08 23:59:20 +02:00
Kirill Bulatov
582cee2cdf Return more data about located imports 2021-03-08 23:59:18 +02:00
Kirill Bulatov
309421c117 Draft the qualifier import resolution 2021-03-08 23:58:48 +02:00
Kirill Bulatov
c395c3311d Filter out path items by the qualifier 2021-03-08 23:58:33 +02:00
Kirill Bulatov
f08c0cdd2a Simplify 2021-03-08 23:58:33 +02:00
Kirill Bulatov
7584260b9a Find the code to change 2021-03-08 23:58:33 +02:00
Kirill Bulatov
005bc49d74 Test and initial refactoring 2021-03-08 23:58:32 +02:00
Laurențiu Nicola
fc9eed4836 Use upstream cov-mark 2021-03-08 22:19:44 +02:00
Aleksey Kladov
9faf8dd69a Hygiene is an internal implementation detail of the compiler 2021-03-08 22:14:52 +03:00
Aleksey Kladov
e346a9c5e1 Remove useless code_model indirection 2021-03-08 22:08:30 +03:00
Aleksey Kladov
c0943f84fd Cleanup the error message 2021-03-08 21:45:43 +03:00
Aleksey Kladov
1eb61203b7 Make code generation just work
Contributors don't need to learn about `cargo xtask codegen` if `cargo
test` just does the right thing.
2021-03-08 21:45:37 +03:00
Aleksey Kladov
abb6b8f14c Use the same name in xtask and test utils 2021-03-08 21:45:06 +03:00
Aleksey Kladov
b6ba0dec0c Generalize file ensuring infrastructure 2021-03-08 21:45:06 +03:00
Aleksey Kladov
da73c93c7f Don't punish every crate with serde-json 2021-03-08 20:37:20 +03:00
bors[bot]
d57c9f7980
Merge #7891
7891: Improve handling of rustc_private r=matklad a=DJMcNab

This PR changes how `rust-analyzer` handles `rustc_private`. In particular, packages now must opt-in to using `rustc_private` in `Cargo.toml`, by adding:
```toml
[package.metadata.rust-analyzer]
rustc_private=true
```

This means that depending on crates which also use `rustc_private` will be significantly improved, since their dependencies on the `rustc_private` crates will be resolved properly.

A similar approach could be used in #6714 to allow annotating that your package uses the `test` crate, although I have not yet handled that in this PR.

Additionally, we now only index the crates which are transitive dependencies of `rustc_driver` in the `rustcSource` directory. This should not cause any change in behaviour when using `rustcSource: "discover"`, as the source used then will only be a partial clone. However, if `rustcSource` pointing at a local checkout of rustc, this should significantly improve the memory usage and lower indexing time. This is because we avoids indexing all crates in `src/tools/`, which includes `rust-analyzer` itself.

Furthermore, we also prefer named dependencies over dependencies from `rustcSource`. This ensures that feature resolution for crates which are depended on by both `rustc` and your crate uses the correct set for analysing your crate.

See also [introductory zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229086673)

I have tested this in [priroda](https://github.com/oli-obk/priroda/), and it provides a significant improvement to the development experience (once I give `miri` the required data in `Cargo.toml`)

Todo:
- [ ] Documentation

This is ready to review, and I will add documentation if this would be accepted (or if I get time to do so anyway)

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2021-03-08 16:51:20 +00:00
Daniel McNab
20007fd3a8 Document rustc_private in metadata 2021-03-08 16:47:40 +00:00
Daniel McNab
d0a51d710e Never run cargo check on the rustc source 2021-03-08 16:42:18 +00:00
Daniel McNab
d5d406fa78 Only show directory name 2021-03-08 16:41:40 +00:00
Daniel McNab
bbecea03fd Revert "Support disabling rustc build scripts"
This reverts commit ddce6bb282.
2021-03-08 16:37:52 +00:00
kjeremy
e13ac349b5 Cargo update
Chalk changes just a version # bump. There are no actual commits.
2021-03-08 10:39:11 -05:00
Aleksey Kladov
c7b5d6be4c Make code completion "just work" in more cases 2021-03-08 14:57:56 +03:00
Kirill Bulatov
128a6a4ec0 Do not process indexed values more than once 2021-03-08 12:06:15 +02:00
Kirill Bulatov
8f17f3d594 Deduplicate search_dependencies results 2021-03-08 11:48:51 +02:00
Daniel McNab
ddce6bb282 Support disabling rustc build scripts 2021-03-08 09:05:19 +00:00
Daniel McNab
877f745551 Fix the comment
It's worse than I thought...
2021-03-07 13:13:54 +00:00
Daniel McNab
419b5a1bee Extract the large nested block into a function
Also add some more detailed comments
Extract into function deleted the previous comments
2021-03-07 12:59:15 +00:00
Daniel McNab
9246df669a Require opt in to rustc_private
This gives the advantage that

A future extension would be to check for `feature(rustc_private)` instead
2021-03-07 12:24:20 +00:00
Daniel McNab
71a254c1a1 Don't double analyse the same crate 2021-03-07 11:17:14 +00:00
Daniel McNab
b46605cfcd Update crate graph to only use subcrates of rustc_driver 2021-03-07 10:18:01 +00:00
bors[bot]
d54e1157b6
Merge #7889
7889: Make group imports configurable r=lnicola a=asv1



Co-authored-by: asv <asv7c2@gmail.com>
2021-03-07 08:24:02 +00:00
asv
96fc01a30b Make group imports configurable 2021-03-07 10:15:17 +02:00
bors[bot]
708ec9821f
Merge #7895
7895: ⬆️ xflags r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-07 08:13:27 +00:00
Aleksey Kladov
0296cd590e ⬆️ xflags 2021-03-07 11:12:59 +03:00
bors[bot]
f0b7c02f16
Merge #7892
7892: Fix TokenStream::from_str for input consisting of a single group with delimiter r=edwin0cheng a=kevinmehall

TokenStream holds a `tt::Subtree` but assumes its `delimiter` is always `None`. In particular, the iterator implementation iterates over the inner `token_trees` and ignores the `delimiter`.

However, `TokenStream::from_str` violated this assumption when the input consists of a single group by producing a Subtree with an outer delimiter, which was ignored as seen by a procedural macro.

`tt::Subtree` is just `pub delimiter: Option<Delimiter>, pub token_trees: Vec<TokenTree>`, so a Subtree that is statically guaranteed not to have a delimiter is just `Vec<TokenTree>`.

Fixes #7810
Fixes #7875

Co-authored-by: Kevin Mehall <km@kevinmehall.net>
2021-03-07 00:32:56 +00:00
Jonas Schievink
6750c11df3 Rename a few crate_def_maps to def_map
These could all be block `DefMap`s instead of crate-level `DefMap`s
2021-03-07 00:20:13 +01:00
bors[bot]
c44575b485
Merge #7896
7896: Only replace quotes in replace_string_with_char assist r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-06 20:22:36 +00:00
Lukas Wirth
1a276f8959 Only replace quotes in replace_string_with_char assist 2021-03-06 21:21:18 +01:00
bors[bot]
5480bed936
Merge #7800
7800: [WIP] 7708: Initial implementation of generate Default assist. r=Veykril a=chetankhilosiya

The Generate Default impl from new function.

Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
2021-03-06 20:01:50 +00:00
Chetan Khilosiya
d40a4fc92c 7708: rust ideomatic code fixes. 2021-03-07 01:26:05 +05:30
bors[bot]
856c2850cd
Merge #7865
7865: preserve escape sequences when replacing string with char r=Veykril a=jDomantas

Currently it replaces escape sequence with the actual value, which is very wrong for `"\n"`.

Co-authored-by: Domantas Jadenkus <djadenkus@gmail.com>
2021-03-06 19:54:36 +00:00
Kevin Mehall
aea9749390 Move TokenStream::to_string helpers inside the method 2021-03-06 12:30:43 -07:00
Chetan Khilosiya
e4b6541c7a 7708: handle both FamousDefs fixture and plain code.
Also fix typo in example.
2021-03-07 00:51:48 +05:30
Chetan Khilosiya
9a84daf47d 7708: Added the updated implementation of is_default_implemented.
The implementation uses hir create to find the implemented trait.
2021-03-07 00:49:03 +05:30
Chetan Khilosiya
b8e6d6a606 7708: Added the logic to check is default impl is already present.
Also added test cases for code present within module.
2021-03-07 00:49:03 +05:30
Chetan Khilosiya
a59a97ae04 7708: Updated generate default fn logic. 2021-03-07 00:49:03 +05:30
Chetan Khilosiya
54b4727fa3 7708: Added the work for review comments.
Also added 1 test case to test multiple struct blocks are present.
2021-03-07 00:49:03 +05:30