1200 Commits

Author SHA1 Message Date
Chayim Refael Friedman
62e7d2851b Warn the user when a rename will change the meaning of the program
Specifically, when a rename of a local will change some code that refers it to refer another local, or some code that refer another local to refer to it.

We do it by introducing a dummy edit with an annotation. I'm not a fond of this approach, but I don't think LSP has a better way.
2025-03-06 21:07:10 +02:00
Chayim Refael Friedman
2fc0dc0f13 Pass the target crate in HirFormatter
This is required to format evaluated consts, because we need trait env, and it needs the crate (currently it uses the last crate in topological order, which is wrong, the next commit will fix that).
2025-03-06 21:00:05 +02:00
Lukas Wirth
27dc614627
Merge pull request #19274 from Veykril/push-pouwrwwrlrlt
Highlight unsafe operations as unsafe, not definitions
2025-03-05 12:57:25 +00:00
Lukas Wirth
9fc0ffe008 Use HIR unsafety information for unsafe syntax highlightng 2025-03-05 13:18:46 +01:00
Lukas Wirth
03f90b0afa
Merge pull request #19261 from Veykril/push-rnqlyrvqpols
Support tuple struct patterns for expand_rest_pattern assist
2025-03-03 11:51:07 +00:00
Lukas Wirth
4ad546f6a6 Support tuple struct patterns for expand_rest_pattern assist 2025-03-03 12:35:53 +01:00
Lukas Wirth
0f4e6104e0 Normalize some assist names 2025-03-02 09:09:12 +01:00
Lukas Wirth
7273d714af
Merge pull request #19259 from Veykril/push-skmvrmtorqso
Add flip or-pattern assist
2025-03-02 07:41:42 +00:00
Lukas Wirth
1ce1f087da
Merge pull request #19253 from ShoyuVanilla/migrate-convert-bool-then
internal: Migrate `convert_bool_then` to `SyntaxEditor`
2025-03-02 07:21:04 +00:00
Lukas Wirth
f7569a4426 Add flip or-pattern assist 2025-03-02 08:04:27 +01:00
Lukas Wirth
570c6adcd3 Remove syntax editing from parenthesis computation 2025-03-01 18:32:04 +01:00
Shoyu Vanilla
37822d5917 Migrate convert_bool_then to SyntaxEditor
Update assist docs
2025-03-01 13:12:15 +09:00
Lukas Wirth
e92dc3fd80 Have inline_local_variable use precedence calculation for parentheses 2025-02-28 11:03:33 +01:00
BenjaminBrienen
b19ef6b046 fix doc tests 2025-02-27 14:58:46 +01:00
BenjaminBrienen
bd7375a58f enable doctest 2025-02-27 14:58:46 +01:00
Giga Bowser
f155aef64d internal: Migrate remove_unused_param assist to SyntaxEditor 2025-02-25 11:52:13 -05:00
Giga Bowser
6dda2e81c6 internal: Migrate remove_parentheses assist to SyntaxEditor 2025-02-25 11:52:13 -05:00
Giga Bowser
daca6b88c4 internal: Migrate remove_mut assist to SyntaxEditor 2025-02-25 11:52:13 -05:00
Giga Bowser
6739652af7 minor: Add tabstop to impl body in generate_trait_impl assist 2025-02-24 13:58:34 -05:00
Shoyu Vanilla
a0b9931832 Add take() method to SyntaxEditor 2025-02-24 22:42:57 +09:00
Shoyu Vanilla
bf0c3944f8 Migrate apply_demorgan to SyntaxEditor 2025-02-24 22:41:53 +09:00
Shoyu Vanilla
f06f1b81bb Migrate some leftovers in add_missing_match_arms 2025-02-24 22:41:52 +09:00
Ali Bektas
9d5a97368a Add a check_assist_* overload and move tests under assists 2025-02-18 21:58:27 +01:00
Ali Bektas
fc10fe44de Fix 19090 2025-02-18 20:51:42 +01:00
Lukas Wirth
a3f937fc24
Merge pull request #19158 from PoignardAzur/expaned_pub_glob_imports
Implement expand_glob_reexport assist
2025-02-17 09:46:29 +00:00
Olivier FAURE
4fa6595f9a Re-generate doctests 2025-02-15 16:26:28 +01:00
Shoyu Vanilla
7d74f2b3e9 Temporarily ignore tests with comments 2025-02-16 00:12:03 +09:00
Olivier FAURE
e4f62b6999 Implement expand_glob_reexport assist 2025-02-15 16:07:33 +01:00
Olivier FAURE
4de24de6b7 Factor out business logic of expand_glob_import 2025-02-15 13:23:32 +01:00
Shoyu Vanilla
8b947d7a12 internal: Remove mutable syntax tree usages from add_missing_match_arms assist 2025-02-14 02:36:05 +09:00
Lukas Wirth
fc726ced6b
Merge pull request #18912 from vishruth-thimmaiah/fix_named_struct_assist
fix: upmap ranges in convert_tuple_struct_to_named_struct assist
2025-02-05 08:49:53 +00:00
Lukas Wirth
07a09c154e
Merge pull request #19015 from Wilfred/mdbook
manual: Convert to mdbook
2025-01-28 16:19:37 +00:00
Chayim Refael Friedman
028c47999d Remove duplicate method from hir::Type
I added it by mistake in #18927.

I chose to keep the method as not static, because it's more comfortable, and keep the name `add_reference()` and not `reference()`, because it is clearer and better matches `strip_reference[s]()`.
2025-01-27 18:40:01 +02:00
Lukas Wirth
b31f53e0d6 Fix flyimport not filtering via stability of import path 2025-01-25 12:18:54 +01:00
Wilfred Hughes
deda58e8f1 manual: Convert to mdbook
Split manual.adoc into markdown files, one for each chapter.

For the parts of the manual that are generated from source code doc
comments, update the comments to use markdown syntax and update the
code generators to write to `generated.md` files.

For the weekly release, stop copying the .adoc files to the
`rust-analyzer/rust-analyzer.github.io` at release time. Instead,
we'll sync the manual hourly from this repository.

See https://github.com/rust-analyzer/rust-analyzer.github.io/pull/226
for the sync. This PR should be merged first, and that PR needs to be
merged before the next weekly release.

This change is based on #15795, but rebased and updated. I've also
manually checked each page for markdown syntax issues and fixed any I
encountered.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Josh Rotenberg <joshrotenberg@gmail.com>
2025-01-24 13:23:22 -08:00
Wilfred Hughes
4c34352517 minor: Suggest better names when a type is a sequence
Previously, we'd suggest a type of `vec` for a value of type `Vec<T>`,
which is rarely what the user wants. We also had no suggestions for
values of type `&[T]`.

Instead, try to pluralise the inner type name, and fall back to
`items`.
2025-01-24 11:30:19 -08:00
Lukas Wirth
76585539f5 Cleanup Name string rendering 2025-01-21 10:05:32 +01:00
Vishruth-Thimmaiah
bbd09b573e
fix: upmap ranges in convert_tuple_struct_to_named_struct assist
fixes #18766
2025-01-20 19:46:53 +05:30
Lukas Wirth
b1def0ce47 Extract variable assist triggers less eagerly 2025-01-18 09:52:56 +01:00
Lukas Wirth
3e2848dc59 Add missing #[rust_analyzer::rust_fixture] annotations 2025-01-16 10:51:57 +01:00
Lukas Wirth
bf669dab84 Re-implement rust string highlighting via tool attribute 2025-01-10 13:49:35 +01:00
Lukas Wirth
d4fa92e80a Implement implicit sized bound inlay hints 2025-01-10 12:38:21 +01:00
Chayim Refael Friedman
52794d5194 Do not compute prettify_macro_expansion() unless the "Inline macro" assist has actually been invoked
And not just called to be listed.

This was a major performance hang when repeatedly switching back-and-forth between a large `include!`d file (but there are others)..
2025-01-10 00:56:00 +02:00
Giga Bowser
c552f72f6a minor: Use placeholders in unwrap_return_type 2025-01-08 18:12:06 -06:00
Giga Bowser
a5a79f5957 internal: Migrate unwrap_return_type assist to use SyntaxEditor
Also changes `make::expr_empty_block()` to return `ast::BlockExpr` instead of `ast::Expr`
2025-01-08 18:12:06 -06:00
Giga Bowser
651b43e551 internal: Migrate wrap_return_type assist to use SyntaxEditor 2025-01-08 15:19:10 -06:00
Giga Bowser
54d9b5a31a internal: Migrate if let <=> match assists to SyntaxEditor 2025-01-06 15:58:39 -06:00
Giga Bowser
eb2ce57a3e internal: Migrate replace_let_with_if_let assist to SyntaxEditor 2025-01-06 15:58:39 -06:00
Giga Bowser
551f1d00dd internal: make::expr_match should return ast::MatchExpr 2025-01-06 15:58:39 -06:00
Giga Bowser
32ff06d51c internal: Generally improve make::match_arm
`make::match_arm` should take a single `ast::Pat`, and callers can handle creating an `ast::OrPat` if need be. It should also take a proper `ast::MatchGuard`, instead of making one itself.
2025-01-06 15:58:39 -06:00