Commit Graph

501 Commits

Author SHA1 Message Date
Lukas Wirth
f9c8646d89 fix symbol index collection not collecting legacy macros 2022-03-09 01:44:20 +01:00
Lukas Wirth
c37fe779c6 Add data queries for macros 2022-03-09 00:41:54 +01:00
Lukas Wirth
eba90936c1 Move ide crates to new hir::Macro 2022-03-08 23:52:26 +01:00
Lukas Wirth
ab21cf2f4f internal: Re-arrange ide_db modules 2022-03-06 19:04:04 +01:00
Lukas Wirth
c1f91c93b2 minor: Simplify 2022-03-06 17:56:02 +01:00
Lukas Wirth
97076c074d internal: Simplify and optimize syntax_highlighting 2022-03-06 03:49:54 +01:00
Lukas Wirth
5c0aee013e Fix highlighting of Self 2022-03-05 23:34:37 +01:00
Lukas Wirth
c0d6471143 fix: Recognize Self as a proper keyword 2022-03-05 23:20:06 +01:00
bors[bot]
8f504dc873
Merge #11598
11598: feat: Parse destructuring assignment r=Veykril a=ChayimFriedman2

Part of #11532.

Lowering is not as easy and may not even be feasible right now as it requires generating identifiers: `(a, b) = (b, a)` is desugared into
```rust
{
    let (<gensym_a>, <gensym_b>) = (b, a);
    a = <gensym_a>;
    b = <gensym_b>;
}
```

rustc uses hygiene to implement that, but we don't support hygiene yet.

However, I think parsing was the main problem as lowering will just affect type inference, and while `{unknown}` is not nice it's much better than a syntax error.

I'm still looking for the best way to do lowering, though.

Fixes #11454.

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2022-03-05 11:31:29 +00:00
Lukas Wirth
32bf7af83e Support locals with multiple declaration sites 2022-03-04 19:49:08 +01:00
hkalbasi
4fa8749c44 Preserve order of generic args 2022-03-04 11:46:14 +03:30
Chayim Refael Friedman
d9f0731bd2 Parse destructuring assignment
The only patterns we should parse are `..` in structs and `_`: the rest are either not supported or already valid expressions.
2022-03-02 01:51:25 +00:00
Lukas Wirth
47ce4436e4 Make hir::Local::name infallible 2022-02-26 16:36:44 +01: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
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
Lukas Wirth
de0941301e Simplify 2022-02-23 16:29:33 +01:00
Lukas Wirth
8db88df758 simplify and document 2022-02-22 10:45:29 +01:00
Lukas Wirth
f13c98034b Make replace_derive_with_manual_impl work again 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]
979b5b32bc
Merge #11455
11455: Handle proc-macro functions as the proc-macro they resolve to r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-21 16:56:37 +00:00
Lukas Wirth
0d3cd90d08 Move fn to proc-macro conversion to name classification 2022-02-21 17:56:11 +01:00
Chayim Refael Friedman
f70512cc17 Change single_let() and is_pattern_cond() to free functions 2022-02-21 08:34:36 +02:00
Chayim Refael Friedman
13ac5c3491 Fix various IDE features
As a side benefit, we got `let` guard support for `move_guard` for free.
2022-02-21 08:34:35 +02:00
DropDemBits
a1a23d343a
Apply review fixes 2022-02-14 20:41:01 -05:00
DropDemBits
86c1251afb
fix: Don't drop glob with nested self 2022-02-14 19:45:31 -05:00
DropDemBits
df2eb3c7cb
fix: Don't drop tree when the other has self 2022-02-14 19:37:01 -05:00
Tianyi Song
aa8c982c3a Address PR comments 2022-02-13 18:14:39 +08:00
Lukas Wirth
cef8a17ea5 Handle proc-macro functions as the proc-macro they resolve to 2022-02-11 22:06:03 +01:00
Tianyi Song
e62e926a8a Use text range of name after macro expansion 2022-02-11 14:17:12 +08:00
TheDoctor314
10e7e18dc6 Fix renaming super keyword 2022-02-08 21:56:39 +05:30
Lukas Wirth
661d721e20 Add completion module tailored towards use trees 2022-02-03 15:51:57 +01:00
Lukas Wirth
d7a544e69a fix: Complete functions and methods from block level impls 2022-02-01 23:29:40 +01:00
bors[bot]
0808ade4e4
Merge #11182
11182: fix: don't panic on seeing an unexpected offset r=Veykril a=dimbleby

Intended as a fix, or at least a sticking plaster, for #11081.

I have arranged that [offset()](1ba9a924d7/crates/ide_db/src/line_index.rs (L105-L107)) returns `Option<TextSize>` instead of going out of bounds; other changes are the result of following the compiler after doing this.

Perhaps there's still an issue here - I suppose the server and client have gotten out of sync and that probably shouldn't happen in the first place?  I see that https://github.com/rust-analyzer/rust-analyzer/issues/10138#issuecomment-913727554 suggests what sounds like a more substantial fix which I think might be aimed in this direction.  So perhaps that one should be left open to cover such things?

Meanwhile, I hope that not-crashing is a good improvement: and I can confirm that it works out just fine in the repro I have at #11081.

Co-authored-by: David Hotham <david.hotham@metaswitch.com>
2022-01-31 11:16:22 +00:00
Schuyler Cohen
11cb203daf Remove spurious format 2022-01-19 13:37:25 -06:00
Wesley Norris
ba82cc7722 Add test for comments not directly next to items 2022-01-17 18:44:43 -05:00
Wesley Norris
7d10752299 Add a test for multi-single-line comments as well 2022-01-17 17:12:32 -05:00
Wesley Norris
1c866573cb fix: insert auto-imports after header comments
Fixes #8607.

This commit changes the auto-import functionality and causes it to add
imports after any leading comments, which are commonly license headers.
This does not affect comments on items as they're considered part of the
item itself and not separate.
2022-01-17 17:06:10 -05:00
Lukas Wirth
91279db2b4 Move format specifier lexing from syntax to ide_db 2022-01-15 13:14:59 +01:00
Lukas Wirth
82fccb971e feat: Add very simplistic ident completion for format_args! macro input 2022-01-15 12:23:26 +01:00
Jonas Schievink
18e80e6892 Remove ModuleId from hir reexports 2022-01-12 20:21:13 +01:00
Jonas Schievink
09219e10f1 Mostly restore hir API boundary 2022-01-12 19:56:47 +01:00
bors[bot]
c17db9fa53
Merge #11107
11107: Fix generic type substitution in impl trait with assoc type r=pnevyk a=pnevyk

Fixes #11045 

The path transform now detects if a type parameter that is being substituted has an associated type. In that case it is necessary (or safe in general case) to fully qualify the substitution with a trait which the associated type belongs to.

This PR also fixes the previous wrong behavior of the substitution that could create an invalid tree `PATH_TYPE -> PATH_TYPE -> ...`.

Co-authored-by: Petr Nevyhoštěný <petr.nevyhosteny@gmail.com>
2022-01-08 09:05:09 +00:00
Petr Nevyhoštěný
a710b87b1b Fix generic type substitution in impl trait with assoc const 2022-01-07 16:41:39 +01:00
Jonas Platte
c90c88b083
Always put a space after impl in macro pretty-printing
… regardless of whether the next symbol is punctuation or not.
2022-01-06 11:33:08 +01:00
Jonas Platte
b8f4667aa9
Always put a space after dyn in macro pretty-printing
… regardless of whether the next symbol is punctuation or not.
Fixes issue 11100.
2022-01-05 18:06:50 +01:00
Lukas Wirth
c5a9985fc5 Remove lossy Definition::from_token/Definition::from_node methods 2022-01-04 18:29:53 +01:00
Lukas Wirth
19f1ff5c70 give resolve_derive_ident a more robust api 2022-01-03 16:00:45 +01:00