Commit graph

21061 commits

Author SHA1 Message Date
Laurențiu Nicola 3bb0635780 Update url to make webrender build 2022-02-26 11:56:57 +02:00
bors[bot] a2cc1d6b7b
Merge #11538
11538: feat: Make private editable completions configurable, disable by default r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10253
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9885

This does disable these completions by default, as it seems that people find this behaviour surprising(due to other IDEs usually not doing this).

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-25 21:17:24 +00:00
Lukas Wirth 2a7793d912 feat: Make private editable completions configurable, disable by default 2022-02-25 22:16:40 +01:00
bors[bot] 7096a0a14e
Merge #11554
11554: fix: fix type mismatches with `unreachable!` macro in Rust 1.59 r=jonas-schievink a=jonas-schievink

should fix https://github.com/rust-analyzer/rust-analyzer/issues/11551

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-02-25 18:14:04 +00:00
Jonas Schievink aec4bcf3f2 Implement the new built-in unreachable! macro 2022-02-25 19:13:04 +01:00
bors[bot] e1541bda94
Merge #11552
11552: fix: properly display `$crate` in hovers r=jonas-schievink a=jonas-schievink

We used to print it as `{extern_crate}`, this PR resolves it to the crate's name, or falls back to `$crate` if the crate has no name.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-02-25 17:41:05 +00:00
Jonas Schievink a247fffdf6 Resolve $crate in HirDisplay of Path 2022-02-25 18:38:51 +01:00
bors[bot] ab896e38e1
Merge #11550
11550: Refactor autoderef/method resolution r=flodiebold a=flodiebold

- don't return the receiver type from method resolution; instead just
 return the autorefs/autoderefs that happened and repeat them. This
 ensures all the effects like trait obligations and whatever we learned
 about type variables from derefing them are actually applied. Also, it
 allows us to get rid of `decanonicalize_ty`, which was just wrong in
 principle.

 - Autoderef itself now directly works with an inference table. Sadly
 this has the effect of making it harder to use as an iterator, often
 requiring manual `while let` loops. (rustc works around this by using
 inner mutability in the inference context, so that things like unifying
 types don't require a unique reference.)

 - We now record the adjustments (autoref/deref) for method receivers
 and index expressions, which we didn't before.

 - Removed the redundant crate parameter from method resolution, since
 the trait_env contains the crate as well.

 - in the HIR API, the methods now take a scope to determine the trait env.
 `Type` carries a trait env, but I think that's probably a bad decision
 because it's easy to create it with the wrong env, e.g. by using
 `Adt::ty`. This mostly didn't matter so far because
 `iterate_method_candidates` took a crate parameter and ignored
 `self.krate`, but the trait env would still have been wrong in those
 cases, which I think would give some wrong results in some edge cases.

Fixes #10058.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-02-25 16:11:22 +00:00
Florian Diebold 6fc3d3aa4c Avoid autoderef coercions leaking if they don't apply 2022-02-25 15:46:02 +01:00
bors[bot] c8257488c1
Merge #11549
11549: feat: support concat_bytes r=jonas-schievink a=ihciah

Support `concat_bytes`.
Solve #11544.

Co-authored-by: ihciah <ihciah@gmail.com>
2022-02-25 13:34:18 +00:00
Florian Diebold 187e6bacac Fix unreachable pub 2022-02-25 12:09:49 +01:00
bors[bot] 1d5df5ea94
Merge #11548
11548: Add CSV output to analysis-stats r=flodiebold a=flodiebold

For easy diffing, to find changes in unknown types / type mismatches.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-02-25 10:57:24 +00:00
Florian Diebold 6fb5abbc03 Refactor autoderef and method resolution
- don't return the receiver type from method resolution; instead just
 return the autorefs/autoderefs that happened and repeat them. This
 ensures all the effects like trait obligations and whatever we learned
 about type variables from derefing them are actually applied. Also, it
 allows us to get rid of `decanonicalize_ty`, which was just wrong in
 principle.

 - Autoderef itself now directly works with an inference table. Sadly
 this has the effect of making it harder to use as an iterator, often
 requiring manual `while let` loops. (rustc works around this by using
 inner mutability in the inference context, so that things like unifying
 types don't require a unique reference.)

 - We now record the adjustments (autoref/deref) for method receivers
 and index expressions, which we didn't before.

 - Removed the redundant crate parameter from method resolution, since
 the trait_env contains the crate as well.

 - in the HIR API, the methods now take a scope to determine the trait env.
 `Type` carries a trait env, but I think that's probably a bad decision
 because it's easy to create it with the wrong env, e.g. by using
 `Adt::ty`. This mostly didn't matter so far because
 `iterate_method_candidates` took a crate parameter and ignored
 `self.krate`, but the trait env would still have been wrong in those
 cases, which I think would give some wrong results in some edge cases.

Fixes #10058.
2022-02-25 11:47:14 +01:00
Florian Diebold 6858694001 Add some tests 2022-02-25 11:47:14 +01:00
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