Commit Graph

715 Commits

Author SHA1 Message Date
Lukas Wirth
abe8f1ece4 Implement builtin#format_args, using rustc's format_args parser 2023-09-05 19:19:46 +02:00
Lukas Wirth
3431d586e5 Insert builtin#asm into asm! expansion 2023-09-05 14:00:49 +02:00
Lukas Wirth
15048304e3 Implement offset_of in hir-def and hir-ty 2023-09-05 12:27:52 +02:00
Lukas Wirth
9b8eb807a3 Parse builtin# syntax 2023-09-05 10:36:35 +02:00
bors
b771de3fdc Auto merge of #15179 - ponyii:fix/default-values-of-const-params-are-ignored, r=HKalbasi
the "add missing members" assists: implemented substitution of default values of const params

To achieve this, I've made `hir::ConstParamData` store the default values
2023-08-15 10:17:43 +00:00
bors
7ca45dcf04 Auto merge of #15410 - alibektas:15240/invalid-demorgan, r=Veykril
internal : rewrite DeMorgan assist

fixes #15239 , #15240 . This PR is a rewrite of the DeMorgan assist that essentially rids of all the string manipulation and modifies syntax trees to apply demorgan on a binary expr. The main reason for the rewrite is that I wanted to use `Expr::needs_parens_in` method to see if the expr on which the assist is applied would still need the parens it had once the parent expression's operator had equal precedence with that of the expression. I used `.clone_(subtree|for_update)` left and right and probably more than I should have, so I would also be happy to hear how I could have prevented redundant cloning.
2023-08-15 07:29:28 +00:00
Lukas Wirth
e5b23e3bc1 Derive block attributes from block item tree 2023-08-10 18:52:27 +02:00
ponyii
4ebdc6f052 syntax update: the default value of ConstParam turned from Expr into ConstArg 2023-08-08 21:57:54 +04:00
ponyii
52b4392724 the "add missing members" assists: implemented substitution of default values of const params 2023-08-08 21:57:54 +04:00
Ali Bektas
ef5c6daf6e Rewrite DeMorgan without str manipulation. 2023-08-08 15:49:27 +02:00
Lukas Wirth
cba39f8553 fix: Fix float parser hack creating empty NameRef tokens 2023-08-08 14:44:33 +02:00
bors
62dcf39ef0 Auto merge of #14723 - obsgolem:master, r=Veykril
Added remove unused imports assist

This resolves the most important part of #5131. I needed to make a couple of cosmetic changes to the search infrastructure to do this.

A few open questions:
* Should imports that don't resolve to anything be considered unused? I figured probably not, but it would be a trivial change to make if we want it.
* Is there a cleaner way to make the edits to the use list?
* Is there a cleaner way to get the list of uses that intersect the current selection?
* Is the performance acceptable? When testing this on itself, it takes a good couple seconds to perform the assist.
* Is there a way to hide the rustc diagnostics that overlap with this functionality?
2023-08-01 09:50:16 +00:00
Lukas Wirth
7c765d9f9e fix: Expand eager macros to delimited comma separated expression list 2023-07-30 17:31:26 +02:00
oxalica
59a3e42ac9
Fix unescaping of C string literals 2023-07-18 18:52:34 +08:00
oxalica
de1f766820
Fix highlighting of byte escape sequences
Currently non-UTF8 escape sequences in byte strings and any escape
sequences in byte literals are ignored.
2023-07-17 22:52:58 +08:00
bors
132ba2cf77 Auto merge of #15248 - Veykril:eager, r=Veykril
Fix eager token mapping panics
2023-07-13 07:39:30 +00:00
Lukas Wirth
6a7b905c86 Fix the eager token maps by re-mapping the textranges between the input and input expansion 2023-07-13 09:22:38 +02:00
DropDemBits
8c40fa33df
Add HasVisibilityEdit::set_visibility 2023-07-09 20:50:20 -04:00
Josiah Bills
7a87a35f1a Added remove_unused_imports assist. 2023-07-09 17:44:27 -04:00
DropDemBits
419f641d49
add AttrsOwnerEdit::add_attr 2023-07-07 20:06:09 -04:00
DropDemBits
c0172333c2
add attr-related make functions 2023-07-07 20:06:09 -04:00
bors
aa91eda902 Auto merge of #15152 - alibektas:14987, r=Veykril,lowr
assist : generate trait from impl

fixes #14987 . As the name suggests this assist is used to generate traits from inherent impls while adapting the original impl to fit to the newly generated trait. I made some decisions regarding when the assist should be applicable. These are surely open to discussion. I looking forward to any feedback.

![generate_trait_from_impl_v1](https://github.com/rust-lang/rust-analyzer/assets/20956650/05d4dda5-604a-4108-8b82-9b60bd45894a)
2023-07-05 16:56:37 +00:00
Ali Bektas
03423116ad Generate trait from impl v2 2023-07-04 17:33:45 +02:00
Ali Bektas
677151e4e1 Version 1 2023-06-27 18:03:36 +02:00
Josh Stone
380773b3e8 Upgrade to indexmap v2 2023-06-24 17:35:20 -07:00
oxalica
2cd7b0cfce Remove unused StmtList::push_front 2023-06-19 22:56:31 +08:00
oxalica
52f1ce17aa Correctly handle inlining of async fn 2023-06-19 17:14:17 +08:00
hkalbasi
f8594f78bb Use ConstArg instead of Expr for AstId of InTypeConstId 2023-06-11 00:39:28 +03:30
DropDemBits
dd5f05590e
Migrate extract_type_alias to mutable ast 2023-06-05 00:24:12 -04:00
bors
e33c0b4b5e Auto merge of #14842 - alibektas:internal/ast-make-improve, r=Veykril
Improve ast::make

Add `ty_alias` and make `impl_trait` , `fn` and `impl_` have more coverage.
2023-05-30 16:09:46 +00:00
Sebastian Ziebell
95f59668e6 Fix removal of generic param from list
This removes an existing generic param from the `GenericParamList`. It
also considers to remove the extra colon & whitespace to the previous
sibling.

* change order to get all param types first and mark them as mutable
  before the first edit happens
* add helper function to remove a generic parameter
* fix test output
2023-05-26 13:13:15 +02:00
Sebastian Ziebell
59f8827a6f Implement assist to replace named generic with impl
This adds a new assist named "replace named generic with impl" to move
the generic param type from the generic param list into the function
signature.

```rust
fn new<T: ToString>(input: T) -> Self {}
```

becomes

```rust
fn new(input: impl ToString) -> Self {}
```

The first step is to determine if the assist can be applied, there has
to be a match between generic trait param & function paramter types.

* replace function parameter type(s) with impl
* add new `impl_trait_type` function to generate the new trait bounds with `impl` keyword  for use in the
  function signature
2023-05-26 13:13:11 +02:00
bors
a512774fd9 Auto merge of #14752 - ponyii:fix/generate_derive_breaks_indentation, r=Veykril
fix: assists no longer break indentation

Fixes https://github.com/rust-lang/rust-analyzer/issues/14674

These are _ad hoc_ patches for a number of assists that can produce incorrectly indented code, namely:
- generate_derive
- add_missing_impl_members
- add_missing_default_members

Some general solution is required in future, as the same problem arises in many other assists, e.g.
- replace_derive_with...
- generate_default_from_enum...
- generate_default_from_new
- generate_delegate_methods
(the list is incomplete)
2023-05-24 18:58:07 +00:00
bors
2df56cadcb Auto merge of #14755 - poliorcetics:clippy-fixes, r=Veykril
Fix: a TODO and some clippy fixes

- fix(todo): implement IntoIterator for ArenaMap<IDX, V>
- chore: remove unused method
- fix: remove useless `return`s
- fix: various clippy lints
- fix: simplify boolean test to a single negation
2023-05-24 11:13:52 +00:00
alibektas
51ec2ced69 Improve ast::make
Add `ty_alias` and make `impl_trait` , `fn` and `impl_` have more coverage.
2023-05-23 03:12:57 +02:00
Lukas Wirth
4b577e2bc8 Support c string literals 2023-05-18 11:06:05 +02:00
Lukas Wirth
099b5b3b15 internal: Bump rustc_lexer 2023-05-18 10:17:40 +02:00
ponyii
e07d6382de add_missing_impl_members no longer breaks indentation 2023-05-10 16:35:48 +04:00
Alexis (Poliorcetics) Bourget
d7fdf141a4 fix: various clippy lints 2023-05-07 09:43:37 +02:00
Ryo Yoshida
fa2340a4df
Parse associated return type bounds 2023-05-06 20:31:11 +09:00
Ryo Yoshida
d7d8971203
Remove (..)-style return type notation 2023-05-06 20:30:17 +09:00
Laurențiu Nicola
7197a27028 Use triomphe Arc 2023-05-02 20:02:43 +03:00
bors
2feabc4dc4 Auto merge of #14622 - alibektas:make_ty_alias, r=alibektas
Add syntax::make::ty_alias

There was until now no function that returns TypeAlias. This commit introduces a func that is fully compliant with the Rust Reference. I had problems working with Ident so for now the function uses simple string manipulation until ast_from_text function is called. I am however open to any ideas that could replace ident param in such a way that it accepts syntax::ast::Ident
2023-04-22 11:43:42 +00:00
alibektas
e275f77b2c Comment clean-up. Use display where possible 2023-04-22 13:23:52 +02:00
alibektas
caa13b3f95 Small changes in str formatting 2023-04-21 22:09:11 +03:00
bors
af3b6a0893 Auto merge of #14621 - alibektas:make_impl_trait_fix, r=Veykril
Simple fix for make::impl_trait

This is my first PR in this project. I made this PR because I needed this function to work properly for the main PR I am working on  (#14386). This is a small amendment to what it was before. We still need to improve this in order for it to fully comply with its syntactic definition as  stated [here](https://doc.rust-lang.org/reference/items/implementations.html).
2023-04-21 18:25:42 +00:00
alibektas
7c9e4e10bc Add syntax::make::ty_alias
The function is fully compliant with the specifications from the Rust Reference.
2023-04-21 21:19:36 +03:00
alibektas
4601331ceb Simple fix for make::impl_trait 2023-04-21 20:46:57 +03:00
Josh Soref
bc7d84c3ce Spelling
* a rule
* access
* after
* amount
* annotations
* assignment
* assist
* associated
* attribute
* borrowed
* built-in type
* clarification
* command
* const
* constructor
* corresponding
* counterparts
* curlies
* dependencies
* deterministic
* diagnostic
* duplicates
* edge
* edited
* efficient
* elsewhere
* execution
* expression
* extensions
* extracted
* fill
* github
* helper
* heuristic
* incomplete
* indent end
* inlay
* invocation
* lifetime
* looking
* maybe
* move
* mutability
* mutable
* necessarily
* necessary
* negative
* nonexistent
* occurred
* offsets
* offsetted
* overridden
* parameters
* params
* params_and_where_preds_in_scope
* paredit
* parent
* parentheses
* prepended if
* punctuation
* receive
* receiver
* referring
* repeated
* representing
* semantically
* separately
* shouldnot
* siblings
* similar
* something's
* statement
* struct
* structure
* surprise
* the
* this
* transparent
* unimplemented
* unnamed
* unnecessary
* unneeded
* unreachable
* unterminated
* utilities
* variant
* variants
* visibility
* work around (v)
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-19 09:45:55 -04:00
Lukas Wirth
1456b53051 Bump smol-str 2023-04-11 14:39:19 +02:00