Commit Graph

19350 Commits

Author SHA1 Message Date
Jonas Schievink
375a0ff785 Use itertools 2021-09-30 16:37:12 +02:00
Jonas Schievink
b8437f71b6 Less hacky assert! expansion 2021-09-30 16:30:26 +02:00
Jonas Schievink
368c5f6023 Fix format string highlighting in panic! 2021-09-30 15:53:47 +02:00
bors[bot]
161a5e8724
Merge #10395
10395: Add pub(super) along with pub(crate) and pub as a completion keyword r=lnicola a=azdavis

I've gotten used to typing `pc` in front of items to get `pub(crate)`, but recently I needed `pub(super)`. So I tried typing `ps` and it didn't work. Now it should!

Co-authored-by: Ariel Davis <ariel.z.davis@icloud.com>
2021-09-30 06:07:50 +00:00
Ariel Davis
00a615b819 Add pub(super) along with pub(crate) and pub as a completion keyword 2021-09-29 21:55:15 -07:00
bors[bot]
b21f15a237
Merge #10389
10389: fix: use the right `HirFileId` when expanding macros in fn parameters r=Veykril a=SkiFire13

Fixes #10388

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
2021-09-29 19:20:12 +00:00
Giacomo Stevanato
034dd41ea8 Add regression test 2021-09-29 21:08:44 +02:00
Giacomo Stevanato
624ee23147 Use the right HirFileId for LowerCtx when expanding macros in fn parameter types 2021-09-29 21:06:37 +02:00
bors[bot]
9e3e98db8a
Merge #10384
10384: Add vscode native onEnterRules r=matklad,lnicola a=HKalbasi

This PR copy onEnterRules configurations [from vscode-rust](https://github.com/rust-lang/vscode-rust/blob/master/src/extension.ts#L287) based on discussion in #6254 

I understand that the ideal way is to use parser data for this, and probably all other things that language-config do. But since it can't be enabled (or at least it isn't enabled) by default in vscode, I think this is needed (until onEnter becomes official LSP and get vscode support).

People can still configure shortcut and use the parser based onEnter, so it wouldn't harm anyone.


Co-authored-by: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
2021-09-29 17:21:56 +00:00
bors[bot]
ee12b0f173
Merge #10181
10181: Begining of lsif r=HKalbasi a=HKalbasi

This PR adds a `lsif` command to cli, which can be used as `rust-analyzer lsif /path/to/project > dump.lsif`. It now generates a valid, but pretty useless lsif (only supports folding ranges). The propose of this PR is to discussing about the structure of lsif generator, before starting anything serious.

cc `@matklad` #8696 #3098


Co-authored-by: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
2021-09-29 13:13:03 +00:00
hamidreza kalbasi
5bd0f50111 remove glob import and cancellables 2021-09-29 16:25:10 +03:30
bors[bot]
1bd14e0530
Merge #10385
10385: Make `extern crate test;` work r=jonas-schievink a=jonas-schievink

This implements support for dependencies that are not added to the extern prelude of a crate, and add the `test` crate from the sysroot as such a dependency.

This does mean we now index `test` on startup, but I didn't notice much of a difference (and also, r-a can be used while it is still indexing).

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6714

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-28 19:48:03 +00:00
Jonas Schievink
0e6922f8a8 Implicitly depend on test 2021-09-28 21:39:41 +02:00
bors[bot]
629db286d1
Merge #10373
10373: fix: `into_iterator` not completed on `Vec<{unknown}>` r=iDawer a=iDawer

Fixes  #10297 

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-28 19:38:59 +00:00
Dawer
f222665ebe fix: replace errors in a type when doing autoderef 2021-09-29 00:26:58 +05:00
Jonas Schievink
0b76b29512 support non-extern-prelude dependencies 2021-09-28 21:23:46 +02:00
bors[bot]
cd9f27d424
Merge #10382
10382: fix: Fix inline_call breaking RecordExprField shorthands r=Veykril a=Veykril

Fixes #10349
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-28 17:23:11 +00:00
Lukas Wirth
774a8cf08b Fix inline_call breaking RecordExprField shorthands 2021-09-28 19:22:32 +02:00
hamidreza kalbasi
0dbaf64b12 add vscode native onEnterRules 2021-09-28 20:23:25 +03:30
bors[bot]
c6d95657ee
Merge #10305
10305: Move `GenericParams`'s handling of `impl Trait` into `fn_data_query` r=flodiebold a=SkiFire13

Fixes #10286

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
2021-09-28 16:30:07 +00:00
bors[bot]
dd21ad6a5e
Merge #10362
10362: feat: Convert a/mod.rs into a.rs r=Veykril a=longfangsong

This is the reverse operation of #10211.

![demo](https://user-images.githubusercontent.com/13777628/134837717-074c23e9-1ca2-4207-b780-8443b2241272.gif)

Close #10143.



Co-authored-by: longfangsong <longfangsong@icloud.com>
Co-authored-by: 龙方淞 <longfangsong@icloud.com>
2021-09-28 10:24:44 +00:00
longfangsong
7e3224f419 Address comments 2021-09-28 10:20:35 +08:00
龙方淞
51b1f7707b Update crates/vfs/src/vfs_path.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-28 10:20:35 +08:00
龙方淞
8f5e8e0a13 Update crates/ide_assists/src/handlers/move_from_mod_rs.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-28 10:20:35 +08:00
longfangsong
0049b5b0bc initial commit 2021-09-28 10:20:29 +08:00
bors[bot]
533ca584c3
Merge #10378
10378: fix: Implement most proc_macro span handling methods r=jonas-schievink a=jonas-schievink

This closes https://github.com/rust-analyzer/rust-analyzer/issues/10368 – some APIs are still missing, but they are either for unstable features or require https://github.com/rust-analyzer/rust-analyzer/issues/9403

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-27 18:00:08 +00:00
Jonas Schievink
577aedb8cf Implement most proc_macro span handling methods 2021-09-27 19:58:07 +02:00
bors[bot]
afa9e31b80
Merge #10377
10377: fix: fix proc macro crash on nightly r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10235

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-27 17:43:32 +00:00
Jonas Schievink
9641bc7369 Implement save_span / recover_proc_macro_span 2021-09-27 19:42:39 +02:00
bors[bot]
bcf04b19f8
Merge #10375
10375: minor: Use SmallVec<[_; 1]> in `descend_into_macros_impl` r=Veykril a=Veykril

A lot of descends don't actually descend in which case we don't wanna allocate
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-27 17:19:55 +00:00
Lukas Wirth
dedc2368b9 Use SmallVec<[_; 1]> in descend_into_macros_impl 2021-09-27 19:18:26 +02:00
bors[bot]
5d4bb05fff
Merge #10374
10374: fix: Make `stringify!` insert/collapse whitespace when needed r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10365

Unlike rustc, we don't insert newlines, but that should be fine.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-27 17:05:39 +00:00
Jonas Schievink
d05eae6ada Make stringify! prettify its input
This will insert whitespace if the invocation is inside another macro
2021-09-27 19:02:03 +02:00
Dawer
11aed78e2b fix: replace errors in receiver type when iterating method candidates 2021-09-27 21:46:00 +05:00
bors[bot]
f22eea9053
Merge #10372
10372: minor: Cleanup descend_into_macros_impl r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-27 16:45:40 +00:00
Lukas Wirth
75660ff94f Cleanup descend_into_macros_impl 2021-09-27 18:44:40 +02:00
bors[bot]
ffcaceb80f
Merge #10366
10366: feat: Enable attribute proc macros by default r=lnicola a=lnicola

Closes #9868

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-09-27 15:12:44 +00:00
Laurențiu Nicola
81891f7abe Enable attribute proc macros by default 2021-09-27 18:11:31 +03:00
Giacomo Stevanato
49ba313679 Update failing test 2021-09-27 16:59:25 +02:00
Giacomo Stevanato
7f76a73a38 Add regression test 2021-09-27 16:59:25 +02:00
Giacomo Stevanato
0d49da5e18 Move GenericParams's handling of impl Trait into GenericParams::generic_params_query 2021-09-27 16:59:25 +02:00
bors[bot]
5347c3ab59
Merge #10353
10353: Remove `GenericParams::new` r=SkiFire13 a=SkiFire13

Helps with #10305

I made the implementations of `HasChildSource<_>` and `ChildBySource` for `GenericDefId` use their own logic instead of relying on `GenericParams::new`. This in turn means that `GenericParams::new` is unused and can be removed. `SourceMap` becomes also unused because all the rest of the code does is insert into it, so it can be removed too. 

This also helps avoid creating a completly new `GenericParams` when `GenericDefId::child_source` and `GenericDefId::child_by_source_to` are called, and also creating a `SourceMap` in `item_tree::lower::Ctx::lower_generic_params`.

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
2021-09-27 13:34:52 +00:00
Giacomo Stevanato
72bb49467d Remove SourceMap 2021-09-27 15:23:50 +02:00
Giacomo Stevanato
fe2b1615de Remove GenericParams::new 2021-09-27 15:20:40 +02:00
Giacomo Stevanato
6e4bf22724 Make impls of HasChildSource and ChildBySource for GenericDefId not use GenericParams::new 2021-09-27 15:20:40 +02:00
bors[bot]
c4251319fd
Merge #10364
10364: internal: Rename `Dyn*` nodes to `Any*` nodes r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/pull/10304#issuecomment-927263396
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-27 10:55:36 +00:00
Lukas Wirth
b6ed91a6de Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
Lukas Wirth
a28c5d7311 Rename Dyn* nodes to Any* nodes 2021-09-27 12:45:36 +02:00
bors[bot]
009e6ceb1d
Merge #10360
10360: headsup: matklad rewrites blocks grammar again :) r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-26 16:19:05 +00:00
Aleksey Kladov
2bf81922f7 internal: more reasonable grammar for blocks
Consider these expples

        { 92 }
  async { 92 }
    'a: { 92 }
   #[a] { 92 }

Previously the tree for them were

  BLOCK_EXPR
    { ... }

  EFFECT_EXPR
    async
    BLOCK_EXPR
      { ... }

  EFFECT_EXPR
    'a:
    BLOCK_EXPR
      { ... }

  BLOCK_EXPR
    #[a]
    { ... }

As you see, it gets progressively worse :) The last two items are
especially odd. The last one even violates the balanced curleys
invariant we have (#10357) The new approach is to say that the stuff in
`{}` is stmt_list, and the block is stmt_list + optional modifiers

  BLOCK_EXPR
    STMT_LIST
      { ... }

  BLOCK_EXPR
    async
    STMT_LIST
      { ... }

  BLOCK_EXPR
    'a:
    STMT_LIST
      { ... }

  BLOCK_EXPR
    #[a]
    STMT_LIST
      { ... }
2021-09-26 19:16:09 +03:00