Commit Graph

23800 Commits

Author SHA1 Message Date
bors
5bd9373c5b Auto merge of #13766 - rust-lang:fix-config-patch, r=Veykril
Fix wrong config patching logic for addCallParenthesis
2022-12-14 13:50:29 +00:00
Noritada Kobayashi
37b404d6c6 minor: Set the experimental AsciiDoc document attribute to generated draft changelog
The keyboard macro (`kbd:[...]`) requires this attribute.

This default change will prevent issues like
https://github.com/rust-analyzer/rust-analyzer.github.io/pull/191 .
2022-12-14 18:49:26 +09:00
Noritada Kobayashi
c78d759ab3 Add a link to the original changelog from release notes on GitHub Releases 2022-12-14 14:14:55 +09:00
Noritada Kobayashi
fd5be91d94 Integrate inline macro support with the main AsciiDoc-to-Markdown conversion process 2022-12-14 13:33:20 +09:00
Noritada Kobayashi
a77336b1aa Implement inline macro handling for AsciiDoc-to-Markdown conversion 2022-12-14 02:12:24 +09:00
Jonas Schievink
9e0aaf4cf3 Parse ..= X patterns 2022-12-13 17:32:25 +01:00
Florian Diebold
ef4a9f0ac2 Fix wrong config patching logic for addCallParenthesis 2022-12-13 16:39:00 +01:00
Noritada Kobayashi
c7c6c6b814 Make curl fail on errors in xtask publish-release-notes 2022-12-13 13:05:11 +09:00
Maybe Waffle
7ed0871ff6 Fix "needs parens" check in remove_parentheses assist 2022-12-13 00:06:00 +00:00
bors
4596847a88 Auto merge of #13746 - feniljain:fix_extract_function, r=jonas-schievink
fix: make make_body respect comments in extract_function

Possible fix for #13621

### Points to help in review:

- Earlier we were only considering statements in a block expr and hence comments were being ignored, now we handle tokens hence making it aware of comments and then preserving them using `hacky_block_expr_with_comments`

Seems like I am not able to attach output video, github is glitching for it :(
2022-12-12 14:51:03 +00:00
bors
15ff8a5a9f Auto merge of #13715 - feniljain:fix_completions, r=jonas-schievink
fix: breaking snippets on typed incomplete suggestions

Possible fix for #7929

Fix the case where if a user types `&&42.o`, snippet completion was still applying &&Ok(42). Note this was fixed previously on `&&42.` but this still remained a problem for this case

Previous relevant PR: #13517

### Points to help in review:

- The main problem why everything broke on adding an extra `o` was, earlier `dot_receiver` was `42.` which was a `LITERAL` but now `42.o` becomes a `FIELD_EXPR`

- Till now `include_references` was just checking for parent of `LITERAL` and if it was a `REF_EXPR`, but now we consider `FIELD_EXPR` and traverse all of them, finally to reach `REF_EXPR`. If `REF_EXPR` is not found we  just return the original `initial_element`

- We are constructing a new node during `include_references` because if we rely on `dot_receiver` solely we would get `&&42.o` to be replaced with, but we want `&&42` to be replaced with

### Output Video:

https://user-images.githubusercontent.com/49019259/205420166-efbdef78-5b3a-4aef-ab4b-d892dac056a0.mov

Hope everything I wrote makes sense 😅

Also interestingly previous PR's number was `13517` and this PR's number is `13715`, nicee
2022-12-12 14:37:45 +00:00
bors
e7dff7491a Auto merge of #13726 - feniljain:fix_assists, r=jonas-schievink
feat: allow unwrap block in let initializers

Possible fix for #13679

### Points to help in review:

- I just added a parent case for let statements and it seems everything else was in place already, so turned out to be a small fix
2022-12-12 14:06:45 +00:00
bors
3a7215b92e Auto merge of #13732 - rami3l:fix/gen-partial-eq, r=jonas-schievink
fix: add fallback case in generated `PartialEq` impl

Partially fixes #13727.

When generating `PartialEq` implementations for enums, the original code can already generate the following fallback case:

```rs
_ => std::mem::discriminant(self) == std::mem::discriminant(other),
```

However, it has been suppressed in the following example for no good reason:

```rs
enum Either<T, U> {
    Left(T),
    Right(U),
}

impl<T, U> PartialEq for Either<T, U> {
    fn eq(&self, other: &Self) -> bool {
        match (self, other) {
            (Self::Left(l0), Self::Left(r0)) => l0 == r0,
            (Self::Right(l0), Self::Right(r0)) => l0 == r0,
            // _ => std::mem::discriminant(self) == std::mem::discriminant(other),
            // ^ this completes the match arms!
        }
    }
}
```

This PR has removed that suppression logic.

~~Of course, the PR could have suppressed the fallback case generation for single-variant enums instead, but I believe that this case is quite rare and should be caught by `#[warn(unreachable_patterns)]` anyway.~~

After this fix, when the enum has >1 variants, the following fallback arm will be generated :

* `_ => false,` if we've already gone through every case where the variants of `self` and `other` match;
* The original one (as stated above) in other cases.

---

Note: The code example is still wrong after the fix due to incorrect trait bounds.
2022-12-12 13:52:49 +00:00
bors
16c70fe69b Auto merge of #13762 - jonas-schievink:underscore-expr-first, r=jonas-schievink
fix: Fix parsing of `_ = x` in closure body

Fixes https://github.com/rust-lang/rust-analyzer/issues/13757
2022-12-12 12:12:02 +00:00
Jonas Schievink
ed48bd8b9d Fix parsing of _ = x in closure body 2022-12-12 12:57:29 +01:00
Noritada Kobayashi
86621a7cc0 Correct complex list item support in AsciiDoc-to-Markdown conversion
Support for following cases are added:

- newlines between list items
- list item with multiline principal text with or without indent
- list item immediately after a list continuation paragraph without
  empty lines in between
2022-12-12 13:09:18 +09:00
Noritada Kobayashi
97ec0ea698 Update the release process documentation to run xtask publish-release-notes 2022-12-12 02:09:31 +09:00
Noritada Kobayashi
f06a29f6e1 Implement xtask publish-release-notes to publish release notes on GitHub Releases 2022-12-11 23:49:28 +09:00
Noritada Kobayashi
0eb537fa31 Add support for list nesting in AsciiDoc-to-Markdown conversion
Support for following list item types are also added:

  - `-`-prefixed unordered list items
  - `.`-prefixed ordered list items
2022-12-11 14:58:49 +09:00
bors
21e61bee8b Auto merge of #13756 - flodiebold:simplify-assoc-item-subst, r=flodiebold
Make assoc_resolutions always have a Substitution
2022-12-10 16:06:54 +00:00
Florian Diebold
d3cb032f7e Make assoc_resolutions always have a Substitution 2022-12-10 17:05:33 +01:00
bors
a3ea20a142 Auto merge of #13725 - bvanjoi:resolve-const-triat-impls, r=flodiebold
feat: resolve const for trait impls

Fixed #13694
2022-12-10 13:58:28 +00:00
bvanjoi
7012b50db5 feat: resolve const for trait impls(close #13694) 2022-12-10 20:06:25 +08:00
bors
632f804797 Auto merge of #13750 - lowr:fix/rpit-in-projection, r=flodiebold
fix: normalize projection after discarding free `BoundVar`s in RPIT

Fixes #13307

When we lower the return type of a function, it may contain free `BoundVar`s in `OpaqueType`'s substitution, which would cause panic during canonicalization as part of projection normalization. Those `BoundVar`s are irrelevant in this context and will be discarded, and we should defer projection normalization until then.
2022-12-10 11:30:14 +00:00
bors
518e39bfe6 Auto merge of #13742 - lowr:fix/assoc-type-shorthand-with-gats, r=flodiebold
fix: only shift `BoundVar`s that come from outside lowering context

Fixes #13734

There are some free functions `TyLoweringContext` methods call, which do not know anything about current binders in scope. We need to shift in the `BoundVar`s in substitutions that we get from them (#4952), but not those we get from `TyLoweringContext` methods.
2022-12-10 11:17:18 +00:00
Noritada Kobayashi
240fc255ef Add image/video media support in AsciiDoc-to-Markdown conversion 2022-12-10 18:22:57 +09:00
bors
14492043db Auto merge of #13749 - WaffleLapkin:remove_some_redudant_adjustment_hints, r=Veykril
fix: Don't show duplicated adjustment hints for blocks, ifs and matches

Before:
![2022-12-09_21-10](https://user-images.githubusercontent.com/38225716/206761100-5511d91b-2543-4166-aa2c-abdb8bad3613.png)
After:
![2022-12-09_21-22](https://user-images.githubusercontent.com/38225716/206761113-c58dbb5a-8616-4287-a3b4-69c13703294d.png)

----

I want to improve adjustment hints, this is the first step :)
2022-12-09 19:36:05 +00:00
Ryo Yoshida
34b11d9981
fix: normalize projection after discarding free BoundVars in RPIT 2022-12-10 04:23:23 +09:00
Maybe Waffle
7c9a85bc43 fix: Don't show duplicated adjustment hints for blocks, ifs and matches 2022-12-09 18:45:01 +00:00
bors
a0296c2b39 Auto merge of #13745 - Veykril:ty-hint-variant-field, r=Veykril
Show type info on hover of enum variant fields

Small addition to https://github.com/rust-lang/rust-analyzer/pull/13490
2022-12-09 16:59:02 +00:00
Noritada Kobayashi
1efcb6ad9a Import the initial implementation of AsciiDoc-to-Markdown conversion 2022-12-09 23:45:45 +09:00
feniljain
d7183fb5d0 fix: make make_body respect comments in extract_function 2022-12-09 18:30:30 +05:30
bors
34e654cd7b Auto merge of #13733 - WaffleLapkin:remove_parens, r=Veykril
feat: Add "Remove redundant parentheses" assist

![Peek 2022-12-08 22-22](https://user-images.githubusercontent.com/38225716/206542898-d6c97468-d615-4c5b-8650-f89b9c0321a0.gif)

Can be quite handy when refactoring :)
2022-12-09 11:42:09 +00:00
bors
83e2639cd1 Auto merge of #13722 - MariaSolOs:add-json-contrib, r=Veykril
Add VS Code schema validation for `rust-project.json`

Now that https://github.com/SchemaStore/schemastore/pull/2628 has been merged, adding the `jsonValidation` contribution to the VS Code extension for better editor support when modifying `rust-project.json` files.

Related issue: #13714
2022-12-09 11:29:10 +00:00
Lukas Wirth
e80674e6b3 Show type info on hover of enum variant fields 2022-12-09 10:09:55 +01:00
Maybe Waffle
ba6f0befc8 Simplify remove_parentheses's implementation 2022-12-08 18:54:08 +00:00
Maybe Waffle
8d42439a7d Move precedence handling to crates/syntax 2022-12-08 18:46:30 +00:00
Maybe Waffle
2870b01ec0 Explicitly say that the assist removes *redundant* parentheses 2022-12-08 18:22:57 +00:00
Ryo Yoshida
19e3085481
Only shift BoundVars that come from outside TyLoweringContext 2022-12-08 21:17:13 +09:00
Ryo Yoshida
46e1486a90
Disallow access to free BoundVars outside TyLoweringContext 2022-12-08 20:52:03 +09:00
bors
6e8a54d0f6 Auto merge of #13490 - HKalbasi:layout, r=jonas-schievink
Compute data layout of types

cc #4091

Things that aren't working:
* Closures
* Generators (so no support for `Future` I think)
* Opaque types
* Type alias and associated types which may need normalization

Things that show wrong result:
* ~Enums with explicit discriminant~
* SIMD types
* ~`NonZero*` and similar standard library items which control layout with special attributes~

At the user level, I didn't put much work, since I wasn't confident about what is the best way to present this information. Currently it shows size and align for ADTs, and size, align, offset for struct fields, in the hover, similar to clangd. I used it some days and I feel I liked it, but we may consider it too noisy and move it to an assist or command.
2022-12-07 15:22:03 +00:00
rami3l
57fb18e3bd fix: refine fallback case in generated PartialEq impl 2022-12-07 10:25:17 +08:00
hkalbasi
948a8f030b Add a fixme comment in current_target_data_layout 2022-12-07 02:29:50 +03:30
hkalbasi
05906da0ec use rustc crates instead of copy paste 2022-12-07 01:59:38 +03:30
Maybe Waffle
ab061945a1 Consider expression precedense in remove_parentheses assist 2022-12-06 19:11:24 +00:00
Maybe Waffle
5f79279b48 Add remove_parentheses assist 2022-12-06 16:18:25 +00:00
rami3l
fed74c8b71 fix: add fallback case in generated PartialEq impl 2022-12-06 21:54:53 +08:00
bors
df07c8fafa Auto merge of #13730 - lowr:feat/builtin-macro-helper-attr, r=Veykril
Support builtin derive macro helper attributes

Closes #13244

It's a bit wasteful for `Macro2Data` to have `helpers` field currently just for `Default` derive macro, but I tend to think it's okay for the time being given how rare macro2's are used.
2022-12-06 08:16:14 +00:00
Ryo Yoshida
051c6598be
Resolve macro2's derive helpers in IDE layer
Macro2's generally don't have derive helpers, but currently builtin
derive macros are declared with macro2 syntax, which can have derive
helpers.
2022-12-06 16:01:20 +09:00
Ryo Yoshida
cf54b8c3a4
Parse and collect derive helpers for builtin derive macros 2022-12-06 16:00:46 +09:00