Commit Graph

14396 Commits

Author SHA1 Message Date
cynecx
3e9847f747 Use fully qualified Itertools::intersperse call to silence nightly warnings about a potential name collision due to recent libstd api additions 2021-01-02 20:58:53 +01:00
cynecx
59fe884ef5 Fix warnings on rust-nightly 2021-01-02 20:48:39 +01:00
bors[bot]
a88d4f8c72
Merge #7133
7133: Proper handling $crate and local_inner_macros r=jonas-schievink a=edwin0cheng

This PR introduces `HygineFrames` to store the macro definition/call site hierarchy in hyginee and when resolving `local_inner_macros` and `$crate`, we use the token to look up the corresponding frame and return the correct value.

See also: https://rustc-dev-guide.rust-lang.org/macro-expansion.html#hygiene-and-hierarchies

fixe #6890 and  #6788

r? @jonas-schievink 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-01-02 17:42:45 +00:00
bors[bot]
510abef5da
Merge #7130
7130: Add extract_assignment assist r=Jesse-Bakker a=Jesse-Bakker

Add extract-assignment assist (#7006).

Assist is for now only implemented on if/match-statements where the assigment is the last statement in every block,
as for other cases, one would have to check whether the assignment has effects on the rest of the block and
extract a temporary variable for it in the block.



Co-authored-by: Jesse Bakker <github@jessebakker.com>
2021-01-02 16:23:06 +00:00
Jesse Bakker
bfe6a8e71a Add support for MatchExpr to extract_assigment assist 2021-01-02 17:10:46 +01:00
Jesse Bakker
31204e3590 Add extract-assignment assist 2021-01-02 16:59:01 +01:00
Edwin Cheng
3545289603 Use arena instead of vec 2021-01-02 22:48:22 +08:00
bors[bot]
3b347eaa4e
Merge #7134
7134: Fix infer error of macro invocation in array expr r=edwin0cheng a=edwin0cheng

Fixed following infer error:

```rust
macro_rules! bar { () => {0u32} }
fn test() {
    let a = [bar!()];   // a : [unknown]
}
```

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-01-02 14:16:26 +00:00
Edwin Cheng
63e330f402 Fix infer error of macro invocation in array expr 2021-01-02 22:06:59 +08:00
Edwin Cheng
fe5340d970 Introduce HygieneFrames for proper token hyginee 2021-01-02 20:39:57 +08:00
Lukas Wirth
68336fdb61 Implement HasAttrs for Type-, Const- and LifetimeParam 2021-01-02 12:11:46 +01:00
Nick Spain
40cd6cdf67 Fix ConstParam HasSource impl and implement TryToNav not Nav 2021-01-02 22:11:25 +11:00
Nick Spain
887028fcf5 Remove old_source now we've fully migrated
Fixes #6913
2021-01-02 21:53:52 +11:00
Nick Spain
5c659c21dd Handle case where detail doesn't exist without giving up on completion
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-01-02 21:53:52 +11:00
Nick Spain
3a1f8e897b Remove source_old from adding const and function impls 2021-01-02 21:53:52 +11:00
Nick Spain
7bfec89cf9 Make the result of Const, FunctionRender and TypeAliasRender constructors optional
They use source() which now returns an Option so they need to too.
2021-01-02 21:53:52 +11:00
Nick Spain
3f1b3df65b Move impls of ToNav that use source() to TryToNav 2021-01-02 21:53:52 +11:00
Nick Spain
6800c606ec Handle missing source in target_data_for_def 2021-01-02 21:53:52 +11:00
Nick Spain
0a9b735240 Handle missing source in filter_assoc_items 2021-01-02 21:53:52 +11:00
Nick Spain
1c009c9f12 Go back to use of source_old() in offset_target_and_file_id as it's not as simple as I thought 2021-01-02 21:53:52 +11:00
Nick Spain
71c9a884d1 Fix type error with .and_then 2021-01-02 21:53:52 +11:00
Nick Spain
68b4efd536 Handle not finding range in Definition::search_scope
The `LifetimeParam` and `Local` variants use `source()` to find their
range. Now that `source()` returns an `Option` we need to handle the
`None` case.
2021-01-02 21:53:52 +11:00
Nick Spain
c936e4b86f source_old -> source for cases that can be handled by simple bubbling 2021-01-02 21:53:52 +11:00
Nick Spain
562e2ee28a Only log path and syntax range when processing function if source exists 2021-01-02 21:53:52 +11:00
Nick Spain
14d0db0759 HasSource::source_old -> HasSource::source for places where proc-macros were special cased
In #6901 some special case handling for proc-macros was introduced to
prevent panicing as they have no AST. Now the new HasSource::source
method is used that returns an option.

Generally this was a pretty trivial change, the only thing of much
interest is that `hir::MacroDef` now implements `TryToNav` not `ToNav`
as this allows us to handle `HasSource::source` now returning an option.
2021-01-02 21:53:52 +11:00
Nick Spain
ea4708c444 Mark HasSource::source_old as deprecated but allow at all call sites 2021-01-02 21:53:51 +11:00
Nick Spain
2de2b1eca3 Implement new HasSource::source for all implementors of HasSource 2021-01-02 21:53:51 +11:00
Nick Spain
27cadcd531 HasSource::source -> HasSource::source_old
To start migrating HasSource::source to return an Option.
2021-01-02 21:53:51 +11:00
bors[bot]
aa3ce16f26
Merge #7132
7132: Stop using beta toolchain in xtask dist r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-01-02 07:52:30 +00:00
Laurențiu Nicola
08e609bef0 Stop using beta toolchain in xtask dist 2021-01-02 09:51:41 +02:00
Lukas Wirth
ec448ca4b3 Impl HasAttrs for GenericParam 2021-01-02 00:44:59 +01:00
bors[bot]
b4a7caedb0
Merge #7125
7125: Don't emit arg count diagnostics for method calls with unknown receiver r=flodiebold a=flodiebold

Fixes #7098.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-01-01 19:50:02 +00:00
Florian Diebold
29acd39800 Don't emit arg count diagnostics for method calls with unknown receiver
Fixes #7098.
2021-01-01 20:49:18 +01:00
Phil Ellison
609a069757 Remove some unnecessary code copied from the Syntax Tree command 2021-01-01 19:35:10 +00:00
Phil Ellison
db53db8046 Address review suggestion, fix tidy tests 2021-01-01 19:25:18 +00:00
Luke Taylor
10c9efc24b Expand doc on dealing with "proc macro not expanded"
Added the error message to the doc for the UnresolvedProcMacro
diagnostic, explaining that either enabling the procMacro setting
or disabling this diagnostic should make the warnings go away.
2021-01-01 18:47:54 +00:00
bors[bot]
c92c9fdc52
Merge #7123
7123: Add support for Rust 2021. r=lnicola a=m-ou-se

This adds `2021` in all places where rust-analyzer already knew about `2015` and `2018`.

The only edition-specific behaviour I could find in the source code was gated on a direct comparison with `Edition2015`, so `Edition2021` should (correctly) behave the same as `Edition2018`:

56a7bf7ede/crates/hir_def/src/nameres/path_resolution.rs (L132)

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-01-01 16:33:45 +00:00
Mara Bos
273d2f9123 Formatting. 2021-01-01 17:31:32 +01:00
Mara Bos
4833972067 Add support for Rust 2021. 2021-01-01 17:22:23 +01:00
bors[bot]
56a7bf7ede
Merge #7121
7121: Show lifetimes and labels on hover r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-01 14:20:51 +00:00
Lukas Wirth
bbc0b41c37 Show lifetimes and labels on hover 2021-01-01 15:19:47 +01:00
bors[bot]
0e5fe47153
Merge #7080
7080: Implement ConstParams for HIR r=Veykril a=Veykril

r? @flodiebold 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-01 13:45:10 +00:00
Lukas Wirth
18bf2e5af5 Add ConstParams to the ide layer 2021-01-01 14:43:16 +01:00
bors[bot]
51d29fe554
Merge #7116
7116: Fix deep syntax tree bug generated by proc-macro r=jonas-schievink a=edwin0cheng

This PR fixed a bug from `semver-parser` and `pest_derive` crates which generate a very deep syntax tree such that serde reject to de-serialize. To fix this bug, we disabled recursion limit in `serde` (by calling [`Deserializer::disable_recursion_limit`](https://docs.rs/serde_json/1.0.61/serde_json/struct.Deserializer.html#method.disable_recursion_limit))

I have a feeling that we still need some way to protect against bad proc-macro generating huge syntax node, but I have no  idea right now.

r? @jonas-schievink 

Fixes #7103 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-01-01 11:06:27 +00:00
Lukas Wirth
0acdb73076 Add ConstParams to the HIR 2021-01-01 10:06:42 +01:00
bors[bot]
ff0c976979
Merge #7117
7117: Use stable instead of beta on macos-11 release runner r=lnicola a=lnicola

Because beta was promoted to stable yesterday.

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-01-01 07:45:19 +00:00
Laurențiu Nicola
407a4f1120 Use stable instead of beta on macos-11 release runner 2021-01-01 09:44:01 +02:00
Edwin Cheng
ae92baba6a Remove serde_stacker which depends on cc 2021-01-01 15:26:55 +08:00
Edwin Cheng
a65025604d Fix deep syntax tree bug generated by proc-macro 2021-01-01 15:09:27 +08:00
bors[bot]
f687d738be
Merge #7102
7102: Fix completion of Default struct update syntax r=Veykril a=nick96

Previously the inserted text was always `..Default::default()` which ends up as `...Default::default()`
if `.` was typed. Now  checks if the current token is `.` and inserts `.Default::default()`
if it is, so `..Default::default()` is correctly completed.

I think there's probably a better way to implement this context aware completion because I've seen it in other parts of rust-analyzer as a user but I'm not sure how to do it.

Fixes #6969

Co-authored-by: Nick Spain <nicholas.spain@stileeducation.com>
2021-01-01 00:32:59 +00:00