Commit Graph

27677 Commits

Author SHA1 Message Date
Tetsuharu Ohzeki
b89a4038c9 proc-macro-api: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
5d1f2835af project-model: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
d00f1c1b16 ide-diagnostics: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
eba1b13295 hir: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
d580b2c7bc hir-ty: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
cb95ee3bc0 hir-def: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
99f5d7ca4c hir-def: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
a9a315fd73 base-db: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
8c2f301a41 ide: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
bors
bb0de88f24 Auto merge of #16519 - tetsuharuohzeki:more-lint, r=lnicola
Enable some minor lints that we should tackles (take2)

This enables these lints:

- borrowed_box
- derived_hash_with_manual_eq
- forget_non_drop
- needless_doctest_main
2024-02-09 15:17:29 +00:00
Tetsuharu Ohzeki
c6637f39c0 clippy: Enable borrowed_box rule 2024-02-10 00:14:17 +09:00
Tetsuharu Ohzeki
d45cabd029 clippy: Enable derived_hash_with_manual_eq rule 2024-02-10 00:14:17 +09:00
Tetsuharu Ohzeki
adddd14afb ide: Fix cargo test -p ide --doc 2024-02-10 00:14:17 +09:00
Tetsuharu Ohzeki
a3e60e7f7a clippy: Enable needless_doctest_main rule 2024-02-10 00:14:17 +09:00
Tetsuharu Ohzeki
3365e50180 clippy: Enable forget_non_drop rule 2024-02-09 23:10:43 +09:00
bors
cdc3e83c2c Auto merge of #16518 - tetsuharuohzeki:enable-some-minor-lints, r=Veykril
Enable some minor lints that we should tackles

This enables these lint rules that are commented as we should tackle at some points.

- non_canonical_clone_impl
- non_canonical_partial_ord_impl
- self_named_constructors
2024-02-09 13:54:36 +00:00
bors
65a644190d Auto merge of #16424 - dfireBird:let-stmt-guarded-return-assist, r=Veykril
implement convert to guarded return assist for `let` statement with type that implements `std::ops::Try`

I've tried to implement the assist that #16390 talked about

If there are any improvements that I can make in implementation, please suggest them.

![Peek 2024-02-05 19-01](https://github.com/rust-lang/rust-analyzer/assets/40687700/d6af3222-4f23-4ade-a930-8a78cc75e821)
2024-02-09 13:42:20 +00:00
Tetsuharu Ohzeki
1e4171bc6e clippy: Enable non_canonical_partial_ord_impl rule 2024-02-09 22:42:16 +09:00
Tetsuharu Ohzeki
2601d19bac clippy: Enable non_canonical_clone_impl rule 2024-02-09 22:37:42 +09:00
Tetsuharu Ohzeki
7669619f9a clippy: Enable self_named_constructors rule 2024-02-09 22:31:21 +09:00
bors
d24bb7e289 Auto merge of #16517 - davidbarsky:david/fix-panic-in-generation-function, r=Veykril
internal: fix crash inside `filter_unnecessary_bounds` for a missing generic param

`@Wilfred` reported a crash here shortly after reporting https://github.com/rust-lang/rust-analyzer/issues/16516, which makes us think that the blast radius of ambiguities in Chalk can be larger than expected. This PR tries to be a bit more defensive as a result.

(The 20th frame is the salient frame in the backtrace below.)

<details>
<summary>Backtrace of the crash</summary>

```
request handler panicked: no entry found for key
backtrace:
   0: stdx::panic_context::PanicContext::init::{{closure}}::{{closure}}::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:32:43
   1: stdx::panic_context::with_backtrace::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:61:32
   2: std:🧵:local::LocalKey<T>::try_with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
   3: std:🧵:local::LocalKey<T>::with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
   4: stdx::panic_context::with_backtrace
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:61:5
   5: stdx::panic_context::PanicContext::init::{{closure}}::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:31:21
   6: stdx::panic_context::with_ctx::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:53:20
   7: std:🧵:local::LocalKey<T>::try_with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
   8: std:🧵:local::LocalKey<T>::with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
   9: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
  10: std::panicking::rust_panic_with_hook
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
  11: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
  12: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
  13: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
  14: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
  15: core::panicking::panic_display
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:178:5
  16: core::panicking::panic_str
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:152:5
  17: core::option::expect_failed
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/option.rs:1985:5
  18: core::option::Option<T>::expect
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/option.rs:894:21
  19: <std::collections:#️⃣:map::HashMap<K,V,S> as core::ops::index::Index<&Q>>::index
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/collections/hash/map.rs:1341:23
  20: ide_assists::handlers::generate_function::filter_unnecessary_bounds::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:911:71
  21: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:305:13
  22: core::option::Option<T>::map
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/option.rs:1072:29
  23: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/iter/adapters/map.rs:103:26
  24: ide_assists::handlers::generate_function::Graph::compute_reachable_nodes
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:1158:20
  25: ide_assists::handlers::generate_function::filter_unnecessary_bounds
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:912:21
  26: ide_assists::handlers::generate_function::fn_generic_params
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:640:5
  27: ide_assists::handlers::generate_function::FunctionBuilder::from_call
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:283:13
  28: ide_assists::handlers::generate_function::gen_fn
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:78:28
  29: ide_assists::handlers::generate_function::generate_function
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:55:5
  30: ide_assists::assists::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/lib.rs:99:9
  31: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/slice/iter/macros.rs:254:21
  32: ide_assists::assists
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/lib.rs:98:5
  33: ide::Analysis::assists_with_fixes::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide/src/lib.rs:667:27
  34: ide::Analysis::with_db::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide/src/lib.rs:764:29
  35: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  36: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  37: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  38: salsa::Cancelled::catch
             at /var/twsvcscm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rust-analyzer-salsa-0.17.0-pre.5/src/lib.rs:631:15
  39: ide::Analysis::with_db
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide/src/lib.rs:764:9
  40: ide::Analysis::assists_with_fixes
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide/src/lib.rs:656:9
  41: rust_analyzer::handlers::request::handle_code_action
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/rust-analyzer/src/handlers/request.rs:1149:19
  42: rust_analyzer::dispatch::RequestDispatcher::on_with_thread_intent::{{closure}}::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/rust-analyzer/src/dispatch.rs:198:54
  43: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  44: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  45: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  46: rust_analyzer::dispatch::RequestDispatcher::on_with_thread_intent::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/rust-analyzer/src/dispatch.rs:198:26
  47: rust_analyzer::task_pool::TaskPool<T>::spawn::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/rust-analyzer/src/task_pool.rs:26:33
  48: stdx:🧵:pool::Pool::spawn::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/thread/pool.rs:82:13
  49: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  50: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  51: stdx:🧵:pool::Pool:🆕:{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/thread/pool.rs:61:29
  52: stdx:🧵:Builder::spawn::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/thread.rs:66:13
  53: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
  54: std:🧵:Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/mod.rs:529:17
  55: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panic/unwind_safe.rs:272:9
  56: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  57: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  58: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  59: std:🧵:Builder::spawn_unchecked_::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/mod.rs:528:30
  60: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  61: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  62: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  63: std::sys::unix:🧵:Thread:🆕:thread_start
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/unix/thread.rs:108:17
  64: start_thread
  65: clone3
  ```
  </details>
2024-02-09 11:19:28 +00:00
David Barsky
2d09d69fbe internal: fix crash inside filter_unnecessary_bounds for a missing generic param 2024-02-08 20:58:48 -05:00
bors
57fda121d8 Auto merge of #16467 - DropDemBits:structured-snippet-migrate-6, r=DropDemBits
internal: Migrate assists to the structured snippet API, part 6/7

Continuing from #16082

Migrates the following assists:

- `extract_function`
- `generate_getter_or_setter`
- `generate_impl`
- `generate_new`
- `replace_derive_with_manual_impl`

Would've been the final PR in the structured snippet migration series, but I didn't notice that `generate_trait_from_impl` started to use `{insert,replace}_snippet` when I first started the migration 😅. This appears to be a pretty self-contained change, so I'll leave that for a separate future PR.

This also removes the last usages of `render_snippet`, which was a follow up goal of #11638. 🎉
2024-02-09 00:54:31 +00:00
DropDemBits
05b8ccc378
Fix clippy lints 2024-02-08 19:39:04 -05:00
DropDemBits
1161082051
Remove unused code in utils
All usages of `render_snippet` and `Cursor` have been removed as part of the migration
2024-02-08 19:13:10 -05:00
DropDemBits
8eebf1701b
Migrate replace_derive_with_manual_impl to mutable ast 2024-02-08 19:13:10 -05:00
DropDemBits
18ea09feca
Migrate generate_new to mutable ast 2024-02-08 19:13:10 -05:00
DropDemBits
e28f5514e1
Add AssocItemList::add_item_at_start
Needed to recreate the behavior of `generate_new` addding the `new` method at the start of the impl
2024-02-08 19:13:10 -05:00
DropDemBits
e0117154cf
Migrate generate_impl to mutable ast 2024-02-08 19:13:10 -05:00
DropDemBits
ab2233e562
Migrate generate_getter_or_setter to mutable ast 2024-02-08 19:13:09 -05:00
DropDemBits
f1293a8fc4
Add newline to body when where clause is present 2024-02-08 19:13:09 -05:00
DropDemBits
0519414c19
Make ReferenceConversion methods return ast types 2024-02-08 19:13:09 -05:00
DropDemBits
039b3d0abb
Add make::ext::expr_self
Shortcut version of `make::expr_path(make::path_unqualified(make::path_segment_self()))`
2024-02-08 19:09:33 -05:00
DropDemBits
0e39257e5b
Migrate extract_function to mutable ast 2024-02-08 19:09:33 -05:00
DropDemBits
3924a0ef7c
Add ast versions of generate{_trait}_impl_text{_intransitive} 2024-02-08 19:09:33 -05:00
DropDemBits
8c0661b2de
Use GenericArgList for make::impl{_trait}
`make::impl_` no longer merges generic params and args in order to be in line
with `make::impl_`, which doesn't do it either.
2024-02-08 19:09:32 -05:00
bors
13707845f7 Auto merge of #15863 - davidbarsky:davidbarsky/start-of-monorepo-mode, r=Veykril
feature: Create `UnindexedProject` notification to be sent to the client

(Note that this branch contains commits from https://github.com/rust-lang/rust-analyzer/pull/15830, which I'll rebase atop of as needed.)

Based on the discussion in https://github.com/rust-lang/rust-analyzer/issues/15837, I've added a notification and off-by-default toggle to send that notification from `handle_did_open_text_document`. I'm happy to rename/tweak this as needed.

I've been using this for a little bit, and it does seem to cause a little bit more indexing/work in rust-analyzer, but it's something that I'll profile as needed, I think.
2024-02-08 19:36:09 +00:00
David Barsky
6330b028b3 feature: Add a UnindexedProject notification and a corresponding setting. 2024-02-08 14:23:00 -05:00
bors
e418c90e97 Auto merge of #16460 - davidsemakula:trailing-return-diagnostic, r=Veykril
feat: Add diagnostic with fix to replace trailing `return <val>;` with `<val>`

Works for functions and closures.
Ignores desugared return expressions (e.g. from desugared try operators).

Fixes: #10970
Completes: #11020
2024-02-08 16:54:41 +00:00
davidsemakula
602acfcb70 fix conflicting "unnecessary else" and "trailing return" diagnostics tests 2024-02-08 19:32:53 +03:00
davidsemakula
a250c2dde0 refactor remove trailing return diagnostic 2024-02-08 19:32:53 +03:00
davidsemakula
98e6f43a2f remove trailing return in trailing match expression 2024-02-08 19:32:53 +03:00
davidsemakula
cad222ff1b remove trailing return in trailing if expression 2024-02-08 19:32:53 +03:00
davidsemakula
2987fac76f diagnostic to remove trailing return 2024-02-08 19:32:53 +03:00
bors
e07183461f Auto merge of #16487 - ShoyuVanilla:deref-generate-getter, r=Veykril
Remove unnecessary `.as_ref()` in generate getter assist

Resolves #12389
2024-02-08 15:15:52 +00:00
bors
5812b693c3 Auto merge of #16484 - Austaras:master, r=Veykril
fix: preserve where clause when builtin derive

Closes #16432.
2024-02-08 15:03:55 +00:00
austaras
dad0fdb13f fix: preserve where clause when builtin derive 2024-02-08 22:44:39 +08:00
bors
0e5766b0d8 Auto merge of #16477 - davidsemakula:trait-incorrect-case-diagnostic, r=Veykril
feat: Add incorrect case diagnostics for traits and their associated items

Updates incorrect case diagnostic to:
- Check traits and their associated items
- Ignore trait implementations except for patterns in associated function bodies

Also cleans up `hir-ty::diagnostics::decl_check` a bit (mostly to make it a bit more DRY and easier to maintain)

Also fixes: #8675 and fixes: #8225
2024-02-08 14:40:16 +00:00
bors
e9d3565cd1 Auto merge of #16502 - davidsemakula:unnecessary-else-diagnostic, r=Veykril
feat: Add "unnecessary else" diagnostic and fix

Fixes #9457
2024-02-08 14:25:00 +00:00
bors
82674e21be Auto merge of #16454 - Veykril:break-return-postfix, r=Veykril
feat: Add break and return postfix keyword completions
2024-02-08 14:09:04 +00:00