bors
ae659125a5
Auto merge of #13763 - rami3l:fix/gen-partial-eq-generic, r=Veykril
...
fix: add generic `TypeBoundList` in generated derivable impl
Potentially fixes #13727 .
Continuing with the work in #13732 , this fix tries to add correct type bounds in the generated `impl` block:
```diff
enum Either<T, U> {
Left(T),
Right(U),
}
- impl<T, U> PartialEq for Either<T, U> {
+ impl<T: PartialEq, U: PartialEq> 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,
_ => false,
}
}
}
```
2023-01-09 13:02:09 +00:00
bvanjoi
ae73628f6b
fix: keep whitespace in extract function handler
2023-01-04 22:10:17 +08:00
Daniel Eades
cc80c5bd07
remove unnecessary lazy evaluations
2023-01-02 15:02:54 +00:00
Daniel Eades
ed128872eb
remove needless borrows
2023-01-02 14:52:32 +00:00
Daniel Eades
77051679d7
use inline format args
2023-01-02 14:52:32 +00:00
Daniel Eades
b196e5b2f6
fixup
2022-12-31 09:26:58 +00:00
Daniel Eades
ba5067a6f0
suppress 'clippy::approx_constant' lint in test case
2022-12-30 11:28:06 +00:00
Maybe Waffle
346bf5fb5b
Implement do yeet
expression
2022-12-28 23:17:13 +00:00
Maybe Waffle
4a16afa264
Parse do yeet
expressions
2022-12-28 22:42:26 +00:00
Yuri Astrakhan
d3dbf9c194
Moar linting: needless_borrow, let_unit_value, ...
...
* There are a few needless borrows that don't seem to be needed. I even did a quick assembly comparison and posted a q to stackoveflow on it. See [here](https://stackoverflow.com/questions/74910196/advantages-of-pass-by-ref-val-with-impl-intoiteratoritem-impl-asrefstr )
* removed several `let _ = ...` when they don't look necessary (even a few ones that were not suggested by clippy (?))
* there were a few `then(|| ctor{})` that clippy suggested to replace with `then_some(ctor{})` -- seems reasonable?
* some unneeded assignment+return - keep the code a bit leaner
* a few `writeln!` instead of `write!`, or even consolidate write!
* a nice optimization to use `ch.is_ascii_digit` instead of `ch.is_digit(10)`
2022-12-25 05:07:47 -05:00
Yuri Astrakhan
e16c76e3c3
Inline all format arguments where possible
...
This makes code more readale and concise,
moving all format arguments like `format!("{}", foo)`
into the more compact `format!("{foo}")` form.
The change was automatically created with, so there are far less change
of an accidental typo.
```
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2022-12-24 14:36:10 -05:00
Maybe Waffle
babd4c7f7d
Don't panic in Expr::needs_parens_in
2022-12-20 15:16:26 +00:00
rami3l
cfa914958c
refactor: use generate_trait_impl_text_intransitive
for From
-like traits
2022-12-17 22:59:30 +08:00
rami3l
12b05d2416
fix: add generic TypeBoundList
in generated derivable impl
2022-12-14 19:18:05 +08:00
Maybe Waffle
7ed0871ff6
Fix "needs parens" check in remove_parentheses
assist
2022-12-13 00:06:00 +00:00
Maybe Waffle
8d42439a7d
Move precedence handling to crates/syntax
2022-12-08 18:46:30 +00:00
Laurențiu Nicola
a2a1d99545
⬆️ rust-analyzer
2022-11-23 17:24:03 +02:00
Michael Goulet
61c744d4fd
Rollup merge of #104211 - lnicola:rust-analyzer-2022-11-09, r=lnicola
...
⬆️ rust-analyzer
r? ``@ghost``
2022-11-09 21:53:38 -08:00
Laurențiu Nicola
79923c382a
⬆️ rust-analyzer
2022-11-09 21:49:10 +02:00
Dylan DPC
a65ca91b84
Rollup merge of #103919 - nnethercote:unescaping-cleanups, r=matklad
...
Unescaping cleanups
Some code improvements, and some error message improvements.
Best reviewed one commit at a time.
r? ````@matklad````
2022-11-09 19:21:22 +05:30
Nicholas Nethercote
7d2a1ee4fc
Remove unescape_byte_literal
.
...
It's easy to just use `unescape_literal` + `byte_from_char`.
2022-11-05 13:56:36 +11:00
Laurențiu Nicola
c60b1f6414
⬆️ rust-analyzer
2022-11-01 11:31:31 +02:00
Laurențiu Nicola
8807fc4cc3
⬆️ rust-analyzer
2022-10-26 17:40:41 +03:00
Laurențiu Nicola
a99a48e786
⬆️ rust-analyzer
2022-10-18 09:12:49 +03:00
Laurențiu Nicola
4f55ebbd4f
⬆️ rust-analyzer
2022-10-11 10:37:35 +03:00
Laurențiu Nicola
459bbb4222
⬆️ rust-analyzer
2022-09-13 15:38:11 +03:00
Laurențiu Nicola
65e1dc4d9c
⬆️ rust-analyzer
2022-09-06 21:20:49 +03:00
Laurențiu Nicola
31519bb394
⬆️ rust-analyzer
2022-08-23 10:05:52 +03:00
Laurențiu Nicola
8231fee466
⬆️ rust-analyzer
2022-08-16 11:24:50 +03:00
Laurențiu Nicola
22c8c9c401
⬆️ rust-analyzer
2022-08-09 07:23:57 +03:00
Laurențiu Nicola
9d2cb42a41
⬆️ rust-analyzer
2022-08-02 09:05:16 +03:00
Amos Wenger
74998e46e9
Fix .gitattributes for test_data
2022-07-24 14:05:35 +02:00
Amos Wenger
b351e115d6
Move cfg attrs up to the mod definitions to disable sourcegen
2022-07-24 10:38:34 +02:00
Amos Wenger
0bffdf2627
Disable all source-gen tests at compile time
2022-07-24 10:38:28 +02:00
Lukas Wirth
cb6703fe06
internal: Don't parse files unnecessarily in scope_for_offset
2022-07-23 00:50:59 +02:00
Amos Wenger
816f7fe12a
Run cargo fix --edition-idioms
2022-07-20 15:02:08 +02:00
Amos Wenger
23d25a3094
Enable extra warnings required by rust-lang/rust
2022-07-20 15:00:17 +02:00
Amos Wenger
1b416473a3
Upgrade to expect-test@1.4.0
...
cf. https://github.com/rust-analyzer/expect-test/issues/33
cf. https://github.com/rust-lang/rust/pull/99444#issuecomment-1188844202
2022-07-19 13:00:45 +02:00
Jonas Schievink
6c6ae965ba
Update remaining GitHub URLs
2022-07-08 15:44:49 +02:00
Laurențiu Nicola
6669f388a2
Bump indexmap
2022-07-03 10:09:35 +03:00
Laurențiu Nicola
c7c314d462
Bump quote
2022-07-03 10:09:35 +03:00
Lukas Wirth
531e152390
fix: Simplify macro statement expansion handling
2022-07-01 14:49:30 +02:00
Lukas Wirth
76ae5434fa
internal: Bump Dependencies
2022-06-10 17:30:02 +02:00
feniljain
1f4870ff1c
fix: f32 and f64 representation during lowering
2022-05-26 20:03:05 +05:30
Lukas Wirth
86d1d9067e
fix: Insert whitespace into trait-impl completions when coming from macros
2022-05-24 22:56:33 +02:00
Lukas Wirth
6a8b8a6039
internal: Refactor our record pat/expr handling in completion context
2022-05-24 13:24:36 +02:00
Lukas Wirth
ad537be194
fix: When reference searching macro inputs, don't search everything that was downmapped
2022-05-23 16:09:56 +02:00
Lukas Wirth
6b696fced8
feat: Add binding mode inlay hints
2022-05-14 14:58:35 +02:00
Jonas Schievink
9bd11459ba
Revert "Auto merge of #12149 - jonas-schievink:literally-just-a-literal, r=jonas-schievink"
...
This reverts commit cc9ae2b89e
, reversing
changes made to 7dfd1cb572
.
2022-05-13 15:08:14 +02:00
Jonas Schievink
2fe38d3b63
Indicate the number of float tokens in the first token
2022-05-05 16:28:59 +02:00
Jonas Schievink
1bc3305d95
Split float literal tokens at the .
2022-05-05 16:28:58 +02:00
Jonas Schievink
502c519e7d
Wrap float literals in their own node
2022-05-05 16:28:14 +02:00
Jonas Schievink
2d5d16f18c
Remove ast::Literal::token
2022-05-05 16:27:35 +02:00
Laurențiu Nicola
9856144b0b
Lower values of char and byte literals
2022-05-05 08:12:08 +03:00
Benjamin Coenen
6344eea242
improve the default constructor mode when filling fields
...
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-05-04 09:45:12 +02:00
Peh
1f011fa4a3
style: rename crates to kebab case
2022-05-01 10:48:58 +00:00
bors
1ad500beb6
Auto merge of #12057 - harpsword:fix_validata_visibility, r=jonas-schievink
...
fix visibility token validation in trait impl with proc-macro
fix #11828
2022-04-27 13:09:31 +00:00
harpsword
b1f858118b
fix visibility token validation in trait impl with proc-macro
2022-04-27 20:58:36 +08:00
Lukas Wirth
ea45e54458
Simplify
2022-04-23 02:21:27 +02:00
XFFXFF
bdecd9374e
update grammer to support associated const equality
2022-04-17 12:03:52 +08:00
Alex Touchet
940ec0967a
Update repo URL
2022-04-13 16:54:24 -07:00
Lukas Wirth
d8341c5b92
Parse for<'a> closure syntax
2022-04-10 17:50:14 +02:00
Jonas Schievink
872b7b9660
Wrap macros in expr position in MacroExpr
node
2022-04-05 17:43:34 +02:00
bors[bot]
65eaabc200
Merge #11887
...
11887: fix: Add missing fields diagnostic fix for patterns r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-03 13:42:15 +00:00
Lukas Wirth
dd3f7664fd
fix: Add missing fields diagnostic fix for patterns
2022-04-03 15:18:05 +02:00
bors[bot]
ba9aed19c7
Merge #11877
...
11877: fix: splitting path of a glob import wrongly adds `self` r=Veykril a=iDawer
Close #11703
`ast::UseTree::split_prefix` handles globs now.
Removed an extra branch for globs in `ide_db::imports::merge_imports::recursive_merge` (superseeded by split_prefix).
Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2022-04-02 22:12:59 +00:00
iDawer
c8c21aabff
fix: merge_imports::recursive_merge
exiting early
2022-04-02 14:18:42 +05:00
Lukas Wirth
0d1d1dc3d9
internal: Move rust.ungram into rust-analyzer/crates/syntax
2022-04-01 17:12:33 +02:00
iDawer
b4c608896c
fix: splitting path of a glob import wrongly adds self
...
`ast::UseTree::split_prefix` handles globs now.
Removed an extra branch for globs in `ide_db::imports::merge_imports::recursive_merge` (superseeded by split_prefix).
2022-04-01 19:12:50 +05:00
Lukas Wirth
8e91bb7660
minor: Bump dependencies
2022-03-22 17:42:24 +01:00
bors[bot]
b594f9c441
Merge #11690
...
11690: feat: Add an assist for inlining type aliases r=Veykril a=steven-joruk
I'm working towards implementing #10881 , but I'd like to get this in first with earlier feedback.
Is `inline_type_alias` a good enough name? I guess the follow up assist would be called `inline_type_alias_into_all_users` based on that.
![valid_inlines](https://user-images.githubusercontent.com/1277939/158020510-fed78b5c-4c7e-46d1-9151-3044a29b9990.gif )
![invalid_inlines](https://user-images.githubusercontent.com/1277939/158020516-8a2deb6d-c6ec-4adf-a15b-c514fc97dc43.gif )
Co-authored-by: Steven Joruk <steven@joruk.com>
2022-03-20 21:15:49 +00:00
Morgan Thomas
3fafbca32e
fix: "Extract to function" assist preserves break
and continue
labels
...
Adds a label / lifetime parameter to `ide_assists::handlers::extract_function::FlowKind::{Break, Continue}`, adds support for emitting labels to `syntax::ast::make::{expr_break, expr_continue}`, and implements the required machinery to let `extract_function` make use of them.
This does modify the external API of the `syntax` crate, but the changes there are simple, not used outside `ide_assists`, and, well, we should probably support emitting `break` and `continue` labels through `syntax` anyways, they're part of the language spec.
Closes #11413 .
2022-03-12 08:54:06 -08:00
Matthias Krüger
5a0078c9d1
more clippy fixes:
...
clippy::search_is_some
clippy::redundant_static_lifetimes
clippy::match_single_binding
clippy::match_ref_pats
clippy::map_entry
clippy::manual_map
clippy::iter_overeager_cloned
clippy::into_iter_on_ref
clippy::extra_unused_lifetimes
2022-03-12 16:50:49 +01:00
Matthias Krüger
451fcd3c79
fix clippy::redundant_closure
2022-03-12 16:50:49 +01:00
Matthias Krüger
1f70886b15
fix clippy::single_char_pattern
2022-03-12 16:50:49 +01:00
Steven Joruk
5b712bd821
feat: Add an assist for inlining type aliases
...
This intends to lead to a more useful assist to replace all users of an
alias with its definition.
2022-03-12 13:42:24 +00:00
Lukas Wirth
6c8c02f625
Don't parse source files to generate macro completion details
2022-03-10 22:21:58 +01:00
Lukas Wirth
e5bb661b7a
Highlight Self
as a keyword by default
2022-03-06 00:13:45 +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
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
Chayim Refael Friedman
54fe3dc0f1
Fix if
in #11561
2022-02-27 00:19:45 +00:00
Laurențiu Nicola
87c4a4104d
Fix body selection in while loops
2022-02-26 16:45:06 +02:00
Chayim Refael Friedman
2df7a1af17
Generate AST code after rust-analyzer/ungrammar#46
2022-02-25 01:25:42 +00: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
Lukas Wirth
f13c98034b
Make replace_derive_with_manual_impl work again
2022-02-22 10:20:44 +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
9881614db1
Upgrade ungrammar to 1.15.0
2022-02-21 08:34:36 +02:00
Chayim Refael Friedman
821b791b6d
Validate let
expressions
...
Emit an error if they're found in an invalid position.
2022-02-21 08:34:35 +02:00
Chayim Refael Friedman
a1b7169b48
Update tests
...
Unfortunately, we lost some recovery for expressions.
2022-02-21 08:34:35 +02:00
Chayim Refael Friedman
de8633f15f
Parse let
expressions in order to support let
chains
...
We still need to reject freestanding `let` expressions: see https://github.com/rust-analyzer/rust-analyzer/issues/11320#issuecomment-1018212465 .
2022-02-21 08:34:34 +02:00
Lukas Wirth
6940cca760
Move attribute path completions into attribute completion module
2022-02-03 15:50:14 +01:00
bors[bot]
34138379b5
Merge #11322
...
11322: Extract function also extracts comments r=Vannevelj a=Vannevelj
Fixes #9011
The difficulty I came across is that the original assist works from the concept of a `ast::StmtList`, a node, but that does not allow me to (easily) represent comments, which are tokens. To combat this, I do a whole bunch of roundtrips: from the `ast::StmtList` I retrieve the `NodeOrToken`s it encompasses.
I then cast all `Node` ones back to a `Stmt` so I can apply indentation to it, after which it is again parsed as a `NodeOrToken`.
Lastly, I add a new `make::` api that accepts `NodeOrToken` rather than `StmtList` so we can write the comment tokens.
Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-02-01 23:05:28 +00:00
Lukas Wirth
45ff51ba22
Make more precise range macro upmapping
2022-01-31 15:53:44 +01:00
Lukas Wirth
cc04cfc982
Reduce allocations in attribute collection
2022-01-30 22:18:32 +01:00
Jeroen Vannevel
4ab7c4d99b
removed prints
2022-01-22 12:08:32 +00:00
Jeroen Vannevel
96ab4c6e6c
hacky_block_expr_with_comments
2022-01-22 12:08:32 +00:00
Jeroen Vannevel
4896ffb65c
removing unwraps
2022-01-22 12:08:32 +00:00
Jeroen Vannevel
4f3dd5bc08
very rough but comments get extracted
2022-01-22 12:08:32 +00:00