Commit Graph

21097 Commits

Author SHA1 Message Date
ihciah
494fab202a
feat: support concat_bytes 2022-02-25 18:46:11 +08:00
Florian Diebold
f807ccd6c0 Add CSV output to analysis-stats
For easy diffing.
2022-02-25 11:45:44 +01:00
bors[bot]
f6901c952e
Merge #11462
11462: 11422 highlight continue and break r=Veykril a=HansAuger

Closes #11422 

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2022-02-24 20:59:27 +00:00
Moritz Vetter
71d158b6ba refactor(11422): make number unsigned, nest enums into each other 2022-02-24 21:29:45 +01:00
Moritz Vetter
8848186213 fix(11422): have two different funuctions - one for iterating breaks, one for iteraating breaks and continues 2022-02-24 19:00:08 +01:00
Moritz Vetter
3da08071ce add logic to highlight continue and break keywords according to expectations 2022-02-24 18:58:14 +01:00
Moritz Vetter
cad0cf6950 refactor helper function to work with function taking expression enum instead of break expression 2022-02-24 18:58:14 +01:00
Moritz Vetter
1c074499f3 add some breaking tests (TDD - style) 2022-02-24 18:58:14 +01:00
bors[bot]
90f7899903
Merge #11531
11531: fix: Make fill_match_arms assist handle doc(hidden) and non_exhaustive r=Veykril a=OleStrohm

Fixes #11499
Fixes #11500
This keeps track of the relevant attributes and adds in a wildcard pat at the end of the match when necessary.

I decided to do them in the same PR since they both needed the ability to add a wildcard arm, and so their changes would overlap if done separately, but I'll split them up if that seems better.

This is my first PR to rust-analyzer, so all feedback is greatly appreciated!

Co-authored-by: Ole Strohm <strohm99@gmail.com>
2022-02-24 12:57:51 +00:00
bors[bot]
6b55d2f10a
Merge #11540
11540: fix: Resolve private fields in type inference r=flodiebold a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10253#issuecomment-920962927
(the same issue probably exists for method calls, but I think fixing that might be trickier)

Visibility checks were introduced in https://github.com/rust-analyzer/rust-analyzer/issues/7841 for autoderef to work properly, so now we just record the first field we find unconditionally, and then overwrite it if autoderef manages to find another field in a later cycle.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-24 11:25:18 +00:00
bors[bot]
6fa525fb80
Merge #11545
11545: add `is_slice` method to `hir::Type` r=flodiebold a=nerdypepper

would like to have this on `hir::Type` for a small project i am working on, unless there is another way to check if `hir::Type` is a slice primitive?

Co-authored-by: Akshay <nerdy@peppe.rs>
2022-02-24 10:14:36 +00:00
Akshay
a5ab6a2f75 add is_slice method to hir::Type 2022-02-24 15:20:12 +05:30
Ole Strohm
f1ba7465c6 Ignore doc(hidden) for crate-local enums 2022-02-23 18:08:18 +00:00
Lukas Wirth
41b6b372a7 fix: Resolve private fields in type inference 2022-02-23 16:45:58 +01:00
Lukas Wirth
de0941301e Simplify 2022-02-23 16:29:33 +01:00
bors[bot]
1f5f4ccfb1
Merge #11539
11539: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-23 15:05:22 +00:00
Lukas Wirth
ffeec9dec9 Simplify 2022-02-23 15:55:06 +01:00
bors[bot]
789f2b9cb6
Merge #11537
11537: internal: Reduce visibility of proc-macros to pub(crate) r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-23 11:01:06 +00:00
Lukas Wirth
d3d054f574 Reduce visibility of proc-macros to pub(crate) 2022-02-23 12:00:04 +01:00
bors[bot]
af097f2192
Merge #11536
11536: internal: Resolve functions as proc-macros via `FileAstId` r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/11528
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-23 10:32:15 +00:00
Lukas Wirth
e759db361e Resolve functions as proc-macros via FileAstId 2022-02-23 11:21:46 +01:00
bors[bot]
217f356541
Merge #11535
11535: Add Kakoune and Helix configuration r=lnicola a=woshilapin

Follow-up of https://github.com/rust-analyzer/rust-analyzer.github.io/pull/181
Fixes https://github.com/rust-analyzer/rust-analyzer.github.io/pull/180

cc `@lnicola` 

Co-authored-by: Jean SIMARD <woshilapin@tuziwo.info>
2022-02-23 07:59:13 +00:00
Jean SIMARD
8025b6449c
Add Kakoune and Helix configuration
Follow-up of rust-analyzer/rust-analyser.github.io#181
Fixes rust-analyzer/rust-analyser.github.io#180
2022-02-23 08:55:56 +01:00
bors[bot]
c79ef5f5ca
Merge #11534
11534: minor: Improve instructions for running pre-release versions r=lnicola a=lnicola

Closes #11468

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-02-23 04:39:42 +00:00
Laurențiu Nicola
6e7b17374c Remove reference to updates.channel from settings 2022-02-23 06:38:01 +02:00
Laurențiu Nicola
b97ab63cbe Rephrase nightly instructions in the manual 2022-02-23 06:37:16 +02:00
Ole Strohm
5cdbfa5b70 Added test 2022-02-22 22:48:44 +00:00
Ole Strohm
94a221ae8d Dedup code 2022-02-22 22:41:03 +00:00
bors[bot]
0b53744f2d
Merge #11461
11461: Extract struct from enum variant filters generics r=jo-goro a=jo-goro

Fixes #11452.

This PR updates extract_struct_from_enum_variant. Extracting a struct `A` form an enum like
```rust
enum X<'a, 'b> {
    A { a: &'a () },
    B { b: &'b () },
}
```
will now be correctly generated as
```rust
struct A<'a> { a: &'a () }

enum X<'a, 'b> {
    A(A<'a>),
    B { b: &'b () },
}
```
instead of the previous
```rust
struct A<'a, 'b>{ a: &'a () } // <- should not have 'b

enum X<'a, 'b> {
    A(A<'a, 'b>),
    B { b: &'b () },
}
```

This also works for generic type parameters and const generics.

Bounds are also copied, however I have not yet implemented a filter for unneeded bounds. Extracting `B` from the following enum
```rust
enum X<'a, 'b: 'a> {
    A { a: &'a () },
    B { b: &'b () },
}
```
will be generated as 
```rust
struct B<'b: 'a> { b: &'b () } // <- should be `struct B<'b> { b: &'b () }`

enum X<'a, 'b: 'a> {
    A { a: &'a () },
    B(B<'b>),
}
```

Extracting bounds with where clauses is also still not implemented.

Co-authored-by: Jonas Goronczy <goronczy.jonas@gmail.com>
2022-02-22 18:46:12 +00:00
Jonas Goronczy
0db0dec999 Replaced fold with for loop 2022-02-22 19:38:34 +01:00
bors[bot]
033f91e75d
Merge #11472
11472: fix: visibility in impl items and pub(crate) to pub in extract_module r=feniljain a=feniljain

Should fix #11007 and #11443

Makes following changes:

- Removes visiblity modifiers from trait items
- Respect user given visibility
- Updated tests for the same

Co-authored-by: vi_mi <fkjainco@gmail.com>
Co-authored-by: vi_mi <49019259+feniljain@users.noreply.github.com>
2022-02-22 18:12:27 +00:00
vi_mi
7abd7b80f3
chore: reposition comment
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-22 19:46:50 +05:30
Ole Strohm
43a4c45ede fix: Make match_arms assist handle doc(hidden) and non_exhaustive 2022-02-22 13:59:30 +00:00
vi_mi
192b6f5a78 fix: visibility in impl items and pub(crate) to pub in extract_module 2022-02-22 18:35:45 +05:30
bors[bot]
7ce06d4b17
Merge #11530
11530: fix: Fix expand_macro always expanding the first listed derive r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-22 11:33:32 +00:00
Lukas Wirth
2e124d15fb fix: Fix expand_macro always expanding the first listed derive 2022-02-22 12:32:27 +01:00
bors[bot]
bd2b6c40bc
Merge #11513
11513: internal: Expand the derive attribute into a pseudo expansion r=Veykril a=Veykril

Quoting my comment:

> We generate a very specific expansion here, as we do not actually expand the `#[derive]` attribute
> itself in name res, but we do want to expand it to something for the IDE layer, so that the input
> derive attributes can be downmapped, and resolved as proper paths.
> This is basically a hack, that simplifies the hacks we need in a lot of ide layer places to
> somewhat inconsistently resolve derive attributes.
> 
> As such, we expand `#[derive(Foo, bar::Bar)]` into
> ```
>  #[Foo]
>  #[bar::Bar]
>  ();
> ```
> which allows fallback path resolution in hir::Semantics to properly identify our derives.
> Since we do not expand the attribute in nameres though, we keep the original item.
> 
> The ideal expansion here would be for the `#[derive]` to re-emit the annotated item and somehow
> use the input paths in its output as well.
> But that would bring two problems with it, for one every derive would duplicate the item token tree
> wasting a lot of memory, and it would also require some way to use a path in a way that makes it
> always resolve as a derive without nameres recollecting them.
> So this hacky approach is a lot more friendly for us, though it does require a bit of support in
> [`hir::Semantics`] to make this work.



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-22 10:12:30 +00:00
Lukas Wirth
b494795a42 update references::derive test output 2022-02-22 10:52:35 +01:00
Lukas Wirth
8db88df758 simplify and document 2022-02-22 10:45:29 +01:00
Lukas Wirth
94e59c9c56 Simplify 2022-02-22 10:20:45 +01:00
Lukas Wirth
1bbef5af85 Fix syntax highlighting not highlighting derives anymore 2022-02-22 10:20:44 +01:00
Lukas Wirth
f13c98034b Make replace_derive_with_manual_impl work again 2022-02-22 10:20:44 +01:00
Lukas Wirth
be3168dabe Fix expand_macro not working for derive attributes 2022-02-22 10:20:44 +01:00
Lukas Wirth
7b89d5ede2 internal: Expand the derive attribute into a pseudo expansion 2022-02-22 10:20:40 +01:00
bors[bot]
1fe3b2edd6
Merge #11527
11527: internal: Split unresolve proc-macro error out of mbe r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-22 09:08:22 +00:00
Lukas Wirth
1505b6a9b4 internal: Split unresolve proc-macro error out of mbe 2022-02-22 10:08:00 +01:00
bors[bot]
071186f8e2
Merge #11525
11525: fix(assist): Drop generic args in path before insert use in `replace_qualified_name_with_use` r=Veykril a=tysg

Fixes #11505. also removed an unnecessary `clone_for_update` call.

Co-authored-by: Tianyi Song <42670338+tysg@users.noreply.github.com>
2022-02-22 08:56:34 +00:00
bors[bot]
81af96d77a
Merge #11524
11524: doc: state that only the latest stable toolchain is supported r=lnicola a=jtroo

This closes #11226. The content seemed to make more sense in the
installation section as opposed to the Troubleshooting section.

Co-authored-by: Jan Tache <j.andreitabs@gmail.com>
2022-02-22 08:38:57 +00:00
Tianyi Song
1c3d6725e2 Drop generic args in path before insert use 2022-02-22 15:41:26 +08:00
Jan Tache
90916b726e Change Rust Analyzer->rust-analyzer to match style 2022-02-21 23:01:05 -08:00