Commit graph

18140 commits

Author SHA1 Message Date
Jessie Chatham Spencer
37e0e8af10 Implement extern crate completion 2023-08-20 16:36:59 +00:00
Ralf Jung
883f16d805 fix RA build 2023-08-20 18:31:22 +02:00
Ralf Jung
59f9c95ec0 give some unwind-related terminators a more clear name 2023-08-20 15:52:38 +02:00
bors
c0f6ece3c4 Auto merge of #15434 - alibektas:deunwrap/generate_derive, r=lnicola
minor : Deunwrap generate_derive

#15398 subtask 1. Since the editing closure has arms, I did something *experimental* ( in this case just a clever term for bad code ) to bypass creating an `Option` but I am ready to change this.
2023-08-18 16:16:27 +00:00
Lukas Wirth
eb6244c5f9 Record import aliases in symbol index 2023-08-18 11:46:35 +02:00
Lukas Wirth
637f496a81 fix: Fix auto-import (and completions) importing #[doc(hidden)] items 2023-08-17 12:30:19 +02:00
bors
49716e681a Auto merge of #15472 - Veykril:import-ide-support, r=Veykril
internal: Record import origins in ItemScope and PerNS

This records the import items definitions come from in the module scope (as well as what an import resolves to in an ItemScope). It does ignore glob imports as thats a lot more work for little to no gain, glob imports act as if the importing items are "inlined" into the scope which suffices for almost all use cases I believe (to my knowledge, attributes on them have little effect).

There is still a lot of work needed to make this available to the IDE layer, but this lays out the ground work for havin IDE layer support.

cc https://github.com/rust-lang/rust-analyzer/issues/14079
2023-08-17 09:56:42 +00:00
Lukas Wirth
a17d73ad36 Thread imports through the resolver 2023-08-17 10:52:13 +02:00
Lukas Wirth
c4e9b5ac64 Add import info to item scope dumps 2023-08-17 09:33:15 +02:00
Lukas Wirth
af8048266c Prepare ItemScope for IDE import resolution 2023-08-16 11:33:42 +02:00
Lukas Wirth
53b292478d internal: Add offset param to token descending API 2023-08-16 10:07:18 +02:00
Wilfred Hughes
e2866404ef Format the existing command in logging 2023-08-15 16:07:06 -07:00
Wilfred Hughes
14078ed303 Rename CargoHandle to CommandHandle
This handle wraps an arbitrary command, which might be a rustc command
rather than cargo.
2023-08-15 16:06:25 -07:00
Ali Bektas
2a78173ff8 v2 2023-08-16 00:22:08 +02:00
bors
b14770934a Auto merge of #15463 - ponyii:fix/start-hovering-default-values-of-generic-const, r=HKalbasi
fix: start hovering default values of generic constants

It's just a kind of a postscriptum for [my last PR](https://github.com/rust-lang/rust-analyzer/pull/15179) adding default values of const generics to `hir::ConstParamData`. Here I patch other pieces of code which used to ignore const default values and which I managed to find (you're welcome to show me more)
2023-08-15 20:34:48 +00:00
Ali Bektas
eed1b3b652 v2 2023-08-15 19:37:23 +02:00
ponyii
fec5ff9890 start hovering default values of generic constants 2023-08-15 20:26:42 +04:00
Laurențiu Nicola
4c67becd44 Always collect memory usage info in analysis-stats 2023-08-15 18:22:37 +03: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
bors
c18ce9a08b Auto merge of #15429 - alibektas:deunwrap/generate_delegate_methods, r=Veykril
minor : Deunwrap generate_delegate_methods

#15398 subtask 8
2023-08-15 07:15:25 +00:00
bors
0b2a241b57 Auto merge of #15426 - alibektas:deunwrap/convert_to_guarded_return, r=Veykril
minor : Deunwrap convert_to_guarded_return

Closes subtask 12 of #15398
2023-08-15 07:00:03 +00:00
bors
f73cd39f7b Auto merge of #15383 - max-heller:issue-12568, r=Veykril
Suggest type completions for type arguments and constant completions for constant arguments

When determining completions for generic arguments, suggest only types or only constants if the corresponding generic parameter is a type parameter or constant parameter.

Closes #12568
2023-08-15 06:39:50 +00:00
bors
0fa822dfe1 Auto merge of #15418 - oxalica:fix/sig-from-macro, r=Veykril
Fix signature help of methods from macros

Currently the receiver type is copied from AST instead re-formatting through `HirDisplay`. Macro generated functions seem to have no spaces and their signature help are rendered like `fn foo(&'amutself)` instead of `fn foo(&'a mut self)`.
2023-08-15 06:25:13 +00:00
dirreke
d6b97e64fc Upgrade Object and related deps 2023-08-14 23:05:45 +08:00
dirreke
465aaed1cf fix the wrong number in const KNOWN_ARCH 2023-08-14 23:02:37 +08:00
Dirreke
93b6838158 add a csky-unknown-linux-gnuabiv2 target 2023-08-14 23:02:36 +08:00
bors
2fbe69d117 Auto merge of #15438 - Veykril:eager-parser-stuck, r=Veykril
fix: Fix parser being stuck in eager macro inputs

Fixes https://github.com/rust-lang/rust-analyzer/issues/15437
2023-08-12 14:30:38 +00:00
Lukas Wirth
9ac88d8d36 Fix parser being stuck in eager macro inputs 2023-08-12 08:27:27 +02:00
bors
6cf06c1675 Auto merge of #15445 - Veykril:worl-symbols-traits, r=Veykril
fix: Fix `only_types` config filtering out traits from world symbols

It is a bit confusing that this apparently did not filter every trait out though...

Closes https://github.com/rust-lang/rust-analyzer/issues/15444
Closes https://github.com/rust-lang/rust-analyzer/issues/15200
2023-08-12 04:55:17 +00:00
Lukas Wirth
d6d188fce2 fix: Fix only_types config filtering out traits from world symbols 2023-08-12 06:40:49 +02:00
bors
39ebc378c2 Auto merge of #15436 - Veykril:temp-alloc, r=Veykril
Preserve `resolve_obligations_as_possible` temporary allocation across calls

This saves ~20ms in the highlihting bench on my machine
```
  284ms - highlight
      150ms - infer:wait @ per_query_memory_usage
          150ms - infer_query
                0   - PerNs::filter_visibility (436 calls)
                0   - crate_def_map:wait (336 calls)
                2ms - deref_by_trait (909 calls)
                0   - generic_params_query (1 calls)
                0   - inherent_impls_in_block_query (1 calls)
              107ms - resolve_obligations_as_possible (17013 calls)
                0   - trait_solve::wait (1017 calls)
        0   - PerNs::filter_visibility (13 calls)
       17ms - Semantics::analyze_impl (19 calls)
        0   - SourceBinder::to_module_def (30 calls)
        0   - attrs_query (6 calls)
        0   - classify_lifetime (1 calls)
        0   - classify_lifetime_ref (4 calls)
       35ms - classify_name (28 calls)
       54ms - classify_name_ref (452 calls)
        0   - crate_def_map:wait (375 calls)
        7ms - descend_into_macros (776 calls)
        0   - generic_params_query (5 calls)
        0   - impl_data_with_diagnostics_query (1 calls)
       17ms - infer:wait (32 calls)
        0   - resolve_obligations_as_possible (1 calls)
        0   - source_file_to_def (1 calls)
        0   - trait_solve::wait (1 calls)
```
to
```

  256ms - highlight
      121ms - infer:wait @ per_query_memory_usage
          121ms - infer_query
                0   - PerNs::filter_visibility (436 calls)
                0   - crate_def_map:wait (336 calls)
                2ms - deref_by_trait (909 calls)
                0   - generic_params_query (1 calls)
                0   - inherent_impls_in_block_query (1 calls)
               81ms - resolve_obligations_as_possible (17013 calls)
                0   - trait_solve::wait (1017 calls)
        0   - PerNs::filter_visibility (13 calls)
       17ms - Semantics::analyze_impl (19 calls)
        0   - SourceBinder::to_module_def (30 calls)
        0   - attrs_query (6 calls)
        0   - classify_lifetime (1 calls)
        0   - classify_lifetime_ref (4 calls)
       35ms - classify_name (28 calls)
       56ms - classify_name_ref (452 calls)
        0   - crate_def_map:wait (375 calls)
        7ms - descend_into_macros (776 calls)
        0   - generic_params_query (5 calls)
        0   - impl_data_with_diagnostics_query (1 calls)
       16ms - infer:wait (32 calls)
        0   - resolve_obligations_as_possible (1 calls)
        0   - source_file_to_def (1 calls)
        0   - trait_solve::wait (1 calls)
```
2023-08-12 04:38:32 +00:00
Lukas Wirth
c1c8e787d2 Preserve resolve_obligations_as_possible temporary allocation across calls 2023-08-12 06:36:31 +02:00
bors
1fde334195 Auto merge of #15433 - alibektas:deunwrap/remove_unused_imports, r=lnicola
minor : Deunwrap remove_unused_imports

#15398 Subtask 3
2023-08-11 11:14:45 +00:00
bors
de28baf874 Auto merge of #15424 - lnicola:remove-remove-dbg-unwrap, r=lnicola
minor: Remove `unwrap` from `Remove dbg!`

Part of #15398.
2023-08-11 07:56:10 +00:00
Lukas Wirth
9adff006e8 Simplify 2023-08-10 20:10:19 +02:00
Lukas Wirth
bfad781a77 Memoize block_item_tree_query 2023-08-10 19:24:39 +02:00
Lukas Wirth
fde2d9b47c Deduplicate FileId field in ModuleOrigin 2023-08-10 19:04:46 +02:00
Lukas Wirth
e5b23e3bc1 Derive block attributes from block item tree 2023-08-10 18:52:27 +02:00
Ali Bektas
94b3481808 Deunwrap generate_derive 2023-08-10 01:46:51 +02:00
Ali Bektas
423b00a83a Deunwrap remove_unused_imports 2023-08-10 01:22:26 +02:00
Ali Bektas
a46eebbc9f Deunwrap wrap_return_type_in_result 2023-08-09 23:51:27 +02:00
Ali Bektas
c81a0681a2 Deunwrap generate_delegate_methods 2023-08-09 23:42:52 +02:00
bors
05b0612051 Auto merge of #15428 - Veykril:lsp-types-pin, r=Veykril
Fix pinned version of lsp-types

lsp-types published a new patch version that breaks semver with the proposed feature set (this is intended and documented), we unfortunately forgot to specify the patch version for the pinned version so this breaks us.
2023-08-09 18:07:44 +00:00
Lukas Wirth
7e04142f25 Fix pinned version of lsp-types 2023-08-09 20:06:08 +02:00
Ali Bektas
ebf27058cd minor : Deunwrap convert_to_guarded_return 2023-08-09 17:17:43 +02:00
bors
b78d69c795 Auto merge of #15422 - Veykril:import-sources, r=Veykril
internal: Record import source IDs

cc https://github.com/rust-lang/rust-analyzer/issues/14079
2023-08-09 15:09:15 +00:00
Lukas Wirth
63aba76735 Remove unnecessary ItemTreeId field in ImportSource 2023-08-09 17:06:52 +02:00
Laurențiu Nicola
b658f9a954 Remove unwrap from Remove dbg 2023-08-09 17:54:34 +03:00
bors
b6ee96c3b5 Auto merge of #15423 - alibektas:deunwrap/convert_named_struct_to_tuple_struct, r=lnicola
internal : Deunwrap convert_named_struct_to_tuple_struct

Replaces `unwrap`s with `?` for the mentioned assist.
2023-08-09 14:52:09 +00:00
Ali Bektas
4e4dda5f59 Deunwrap convert_named_struct_to_tuple_struct 2023-08-09 16:40:23 +02:00
Lukas Wirth
c516dd51e9 Simplify 2023-08-09 15:54:10 +02:00
Lukas Wirth
992b928a93 Record import source IDs 2023-08-09 15:20:42 +02:00
bors
4bed01c36e Auto merge of #15421 - Veykril:workspace-loading, r=Veykril
internal: More error context when failing to invoke the rust toolchain
2023-08-09 12:10:21 +00:00
Lukas Wirth
18b24f60d0 More error context when failing to invoke the rust toolchain 2023-08-09 14:09:37 +02:00
Seth Pellegrino
c9bc45f6fd feat: riscv-interrupt-{m,s} calling conventions
Similar to prior support added for the mips430, avr, and x86 targets
this change implements the rough equivalent of clang's
[`__attribute__((interrupt))`][clang-attr] for riscv targets, enabling
e.g.

```rust
static mut CNT: usize = 0;

pub extern "riscv-interrupt-m" fn isr_m() {
    unsafe {
        CNT += 1;
    }
}
```

to produce highly effective assembly like:

```asm
pub extern "riscv-interrupt-m" fn isr_m() {
420003a0:       1141                    addi    sp,sp,-16
    unsafe {
        CNT += 1;
420003a2:       c62a                    sw      a0,12(sp)
420003a4:       c42e                    sw      a1,8(sp)
420003a6:       3fc80537                lui     a0,0x3fc80
420003aa:       63c52583                lw      a1,1596(a0) # 3fc8063c <_ZN12esp_riscv_rt3CNT17hcec3e3a214887d53E.0>
420003ae:       0585                    addi    a1,a1,1
420003b0:       62b52e23                sw      a1,1596(a0)
    }
}
420003b4:       4532                    lw      a0,12(sp)
420003b6:       45a2                    lw      a1,8(sp)
420003b8:       0141                    addi    sp,sp,16
420003ba:       30200073                mret
```

(disassembly via `riscv64-unknown-elf-objdump -C -S --disassemble ./esp32c3-hal/target/riscv32imc-unknown-none-elf/release/examples/gpio_interrupt`)

This outcome is superior to hand-coded interrupt routines which, lacking
visibility into any non-assembly body of the interrupt handler, have to
be very conservative and save the [entire CPU state to the stack
frame][full-frame-save]. By instead asking LLVM to only save the
registers that it uses, we defer the decision to the tool with the best
context: it can more accurately account for the cost of spills if it
knows that every additional register used is already at the cost of an
implicit spill.

At the LLVM level, this is apparently [implemented by] marking every
register as "[callee-save]," matching the semantics of an interrupt
handler nicely (it has to leave the CPU state just as it found it after
its `{m|s}ret`).

This approach is not suitable for every interrupt handler, as it makes
no attempt to e.g. save the state in a user-accessible stack frame. For
a full discussion of those challenges and tradeoffs, please refer to
[the interrupt calling conventions RFC][rfc].

Inside rustc, this implementation differs from prior art because LLVM
does not expose the "all-saved" function flavor as a calling convention
directly, instead preferring to use an attribute that allows for
differentiating between "machine-mode" and "superivsor-mode" interrupts.

Finally, some effort has been made to guide those who may not yet be
aware of the differences between machine-mode and supervisor-mode
interrupts as to why no `riscv-interrupt` calling convention is exposed
through rustc, and similarly for why `riscv-interrupt-u` makes no
appearance (as it would complicate future LLVM upgrades).

[clang-attr]: https://clang.llvm.org/docs/AttributeReference.html#interrupt-risc-v
[full-frame-save]: 9281af2ecf/src/lib.rs (L440-L469)
[implemented by]: b7fb2a3fec/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (L61-L67)
[callee-save]: 973f1fe7a8/llvm/lib/Target/RISCV/RISCVCallingConv.td (L30-L37)
[rfc]: https://github.com/rust-lang/rfcs/pull/3246
2023-08-08 18:09:56 -07:00
Max Heller
fb98f522d2 fixme 2023-08-08 20:55:35 -04:00
Max Heller
400f618a5c convert TypeLocation::GenericArg to struct variant 2023-08-08 20:37:23 -04:00
Max Heller
0b57fa3931 test 2023-08-08 20:09:50 -04:00
Max Heller
a1d9e453b9 Apply suggestions from code review
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2023-08-08 20:05:24 -04:00
bors
fc2f90e0e5 Auto merge of #15419 - HKalbasi:mir, r=HKalbasi
Add mir lower support for tuple destructing assignment

And some other changes in mir eval
2023-08-08 21:02:57 +00:00
hkalbasi
021802c59c Support enum in memory map patch address 2023-08-09 00:27:23 +03:30
bors
ddbbd6a7e7 Auto merge of #15417 - lowr:patch/purge-generic-arg-data-in-expr, r=HKalbasi
internal: use `Cast::cast()` instead of explicit interning

I firmly believe that we should generally use `cast()` instead of interning `GenericArgData` to construct `GenericArg` because it's less verbose and more readable.
2023-08-08 19:27:18 +00:00
bors
e13fac379e Auto merge of #15262 - adamse:master, r=HKalbasi
add check.ignore to list cargo check diagnostics to ignore (dead_code, unused_imports, ...)

fixes #14798
2023-08-08 18:49:45 +00:00
oxalica
de86444756
Prefer hir::SelfParam and fix signature help of methods from macros 2023-08-09 02:42:08 +08:00
oxalica
6a2f83a8a2
Impl HirDisplay for SelfParam 2023-08-09 02:26:44 +08:00
ponyii
68e8379ec3 fixed a merge-caused error 2023-08-08 22:16:28 +04:00
ponyii
e4c45427dc refactoring 2023-08-08 21:57:55 +04:00
ponyii
61cabe029f the "add missing members" assists: supported bracketed default const values 2023-08-08 21:57:55 +04:00
ponyii
4e2be8e959 the "add missing members" assists: implemented the transformation of const param default values 2023-08-08 21:57:55 +04: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
oxalica
3bfe1d5d78
Display fully qualified associated types correctly
Currently they are formatted in the internal `Trait<Self = Type>::Assoc`
forms where `hir_ty::TypeRef` is formatted, like hover.
2023-08-09 00:04:55 +08:00
Ryo Yoshida
6aa03c5d15
Use Cast::cast() instead of interning GenericArgData 2023-08-09 00:47:29 +09:00
bors
af4ba46b40 Auto merge of #15405 - lowr:patch/doc-links-to-fields, r=Veykril
Support doc links that resolve to fields

Fixes #15331

Also removes `Resolver::resolve_module_path_in_trait_assoc_items()` and reimplements it in hir with other `Resolver` methods to decouple things a bit.
2023-08-08 14:13:27 +00:00
Ali Bektas
17f3055803 Rewrite DeMorgan v2 2023-08-08 15:54:58 +02:00
Ali Bektas
ef5c6daf6e Rewrite DeMorgan without str manipulation. 2023-08-08 15:49:27 +02:00
bors
783130bd26 Auto merge of #15250 - lowr:fix/extract-fn-no-control-flow-with-tail-expr, r=Veykril
fix: don't use control flow when extracted fn contains tail expr of original fn

Fixes #10113
Fixes #15061
2023-08-08 13:38:49 +00:00
bors
f98d654ddf Auto merge of #15350 - max-heller:issue-11756, r=Veykril
Handle `#[cfg]`s on generic parameters

Records attributes on generic parameters in the item tree and filters out generic parameters disabled by `#[cfg]`s in `generic_params_query`.

Closes #11756
2023-08-08 13:05:26 +00:00
Lukas Wirth
cba39f8553 fix: Fix float parser hack creating empty NameRef tokens 2023-08-08 14:44:33 +02:00
Adam Sandberg Ericsson
9cb1f45e6f add check.ignore to list cargo check diagnostics to ignore (dead_code, unused_imports, ...)
fixes #14798
2023-08-08 14:28:35 +02:00
hkalbasi
31c30933cf Support closure in clone shim 2023-08-08 01:49:34 +03:30
Matthias Krüger
3ea1928fb2 Rollup merge of #114562 - Trolldemorted:thiscall, r=oli-obk
stabilize abi_thiscall

Closes https://github.com/rust-lang/rust/issues/42202, stabilizing the use of the "thiscall" ABI.

FCP was substituted by a poll, and the poll has been accepted.
2023-08-07 16:47:57 +02:00
Benedikt Radtke
96b60ed278 stabilize abi_thiscall 2023-08-07 14:11:03 +02:00
Laurențiu Nicola
aa55ce9567 Merge commit 'baee6b338b0ea076cd7a9f18d47f175dd2ba0e5d' into sync-from-ra 2023-08-07 12:03:15 +03:00
hkalbasi
b96e4f2f4a Add mir lower support for tuple destructing assignment 2023-08-07 02:12:35 +03:30
Ryo Yoshida
582917453b
Don't provide generate_default_from_new when impl self ty is missing
Also don't provide the assist when the `Default` trait can't be found.
2023-08-07 03:23:41 +09:00
Max Heller
0c21d8538c FIXME 2023-08-06 12:04:33 -04:00
Max Heller
bb9d8229b8 cleanup 2023-08-06 12:04:29 -04:00
Ryo Yoshida
0c433c23b1
Support doc links that resolve to fields 2023-08-07 00:59:35 +09:00
hkalbasi
9b636e2326 Support libc::getenv in mir interpreter 2023-08-06 01:46:29 +03:30
bors
70fa270637 Auto merge of #15401 - Veykril:disabled-proc-macro, r=Veykril
internal: Turn unresolved proc macro expansions into missing expressions

Reduces the amount of type related errors one gets when proc macro expansion is disabled.
2023-08-05 18:01:46 +00:00
Lukas Wirth
042be329a7 Turn unresolved proc macro expansions into missing expressions 2023-08-05 20:00:37 +02:00
Laurențiu Nicola
622b18e579 Remove unwraps from Generate delegate trait 2023-08-05 19:23:56 +03:00
Max Heller
bed1114b8b handle omitted lifetime params 2023-08-05 09:07:29 -04:00
Max Heller
d48606fefe unroll test loop 2023-08-05 08:22:58 -04:00
Max Heller
5e6d646ccc remove unnecessary branch 2023-08-05 08:14:44 -04:00
Max Heller
ee39905370 update tests 2023-08-05 08:13:13 -04:00
Max Heller
50db877bfa optimization and #[cfg] filtering for function generic params 2023-08-05 08:00:39 -04:00
Wilfred Hughes
edabffbd5a SCIP: Qualify parameters by the containing function
SCIP requires symbols to be unique, but multiple functions may have a
parameter with the same name. Qualify parameters according to the
containing function.
2023-08-04 16:38:31 -07:00
hkalbasi
cc5664c5a2 Add rustc comment into while desugaring 2023-08-04 16:35:13 +03:30
hkalbasi
3115d6988f Improve mir interpreter performance by caching 2023-08-04 16:05:54 +03:30
bors
e37ec7262c Auto merge of #15373 - tadeokondrak:desugar-while-to-loop, r=HKalbasi
internal: Desugar while to loop and break

I was reading through rust-analyzer's code and was wondering why this wasn't desugared into a loop.
2023-08-04 07:26:18 +00:00
Alex Zepeda
c5d4f7339a proc-macro-test: Pass target to cargo invocation
When cross compiling macos → dragonfly the dist build fails in the
proc-maro-test-impl crate with the following error:

ld: unknown option: -z\nclang: error: linker command failed with
exit code 1 (use -v to see invocation)

This appears to be a wart stemming from using an Apple host for cross
compiling.  Passing the target along to cargo allows it to pick up
a linker that it understands and DTRT.
2023-08-02 17:57:13 -07:00
Max Heller
1b3e20fe68 handle more cases 2023-08-02 17:59:26 -04:00
Max Heller
f4038a6bf1 support AssocTypeArg and MethodCalls 2023-08-02 11:36:09 -04:00
bors
d398ad3326 Auto merge of #15380 - HKalbasi:mir, r=HKalbasi
Fix unsized struct problems in mir eval
2023-08-02 14:28:41 +00:00
hkalbasi
6990d0f26a Fix unsized struct problems in mir eval 2023-08-02 17:36:11 +03:30
bors
2f2cf21da5 Auto merge of #15348 - max-heller:issue-14692, r=lowr
Exclude non-identifier aliases from completion filtering text

When building `CompletionItem`s, this excludes aliases that aren't valid identifiers from the "lookup" text used to filter completions in the LSP client. Including them results in weird completion filtering behavior e.g. `Partial>` matching a completion for the `PartialOrd` trait because it has a doc alias of ">".

Closes #14692
2023-08-02 13:39:58 +00:00
Max Heller
3205ed7a41 simplify storing generic parameter attributes in item tree 2023-08-02 09:19:56 -04:00
Lukas Wirth
ecb6d07d57 Add currently unused UseId variants 2023-08-02 14:53:45 +02:00
Lukas Wirth
f86f6a89eb Change terminology, do not name use items and use trees as imports 2023-08-02 14:19:38 +02:00
bors
12cb6e7327 Auto merge of #15377 - Veykril:extern-crate-decl, r=Veykril
Add ExternCrateDecl to HIR

Adding these doesn't really require much design effort as they represent a single import, unlike use trees which are one item that represent 0 or more imports.

We only resolve to this definition when actually resolving on the name or alias of an `extern crate name as alias` item, not usages yet as that requires far more changes that won't lead anywhere without giving it more thought. Nevertheless the changes slightly improve IDE things, an example being hover on the decl showing the merged doc comments for example.

cc https://github.com/rust-lang/rust-analyzer/issues/14079
2023-08-02 10:27:30 +00:00
Lukas Wirth
6e2c3f610b Remove suspicious unwrap 2023-08-02 12:18:10 +02:00
Lukas Wirth
bcff166b3a Add ExternCrateDecl to HIR 2023-08-02 11:52:55 +02:00
bors
8e18b0f28c Auto merge of #15376 - Veykril:match-to-matches, r=Veykril
Allow match to matches assist to trigger on non-literal bool arms
2023-08-02 08:18:43 +00:00
Tadeo Kondrak
92a97c292a hir: Remove Expr::While
The previous commit desugared it to a loop.
2023-08-01 19:08:16 -06:00
Tadeo Kondrak
31bcba84f9 hir: Desugar while to loop and break 2023-08-01 19:04:36 -06:00
Max Heller
a743903cf0 remove unicode-ident dependency 2023-08-01 18:18:12 -04:00
Lukas Wirth
75607fc34c Simplify 2023-08-01 17:47:52 +02:00
bors
151c750dac Auto merge of #15367 - Veykril:eager-macro-inputs, r=Veykril
fix: Strip unused token ids from eager macro input token maps
2023-08-01 11:23:02 +00:00
Lukas Wirth
a5059da57a Update test fixture 2023-08-01 13:13:56 +02:00
Lukas Wirth
e14d84d0a6 Skip out on single-segment immediate macro resolution when there are errors 2023-08-01 12:38:53 +02:00
Lukas Wirth
3c1c319c88 Allow match to matches assist to trigger on non-literal bool arms 2023-08-01 12:10:38 +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
d999d34e39 Don't bail eager expansion when inner macros fail to resolve 2023-08-01 11:26:30 +02:00
bors
c71e1368fd Auto merge of #15269 - DropDemBits:structured-snippets-deferred-rendering, r=Veykril
internal: Defer structured snippet rendering to allow escaping snippet bits

Since we know exactly where snippets are, we can transparently escape snippet bits to the exact text edits that need it, and not have to do it for anything other text edits.

Also will eventually fix #11006 once all assists are migrated. This comes as a side-effect of text edits that don't have snippets get marked as having no insert formatting at all.
2023-08-01 09:18:46 +00:00
bors
f6bffa4dd3 Auto merge of #15345 - lowr:fix/add_missing_match_arms-upmap-failure, r=Veykril
Don't provide `add_missing_match_arms` assist when upmapping match arm list failed

Fixes #15310

We shouldn't provide the assist when we fail to find the original match arm list.

Note that this PR will temporarily make the assist not applicable when attribute macro operates on the match expression in question, just like the case in #15310, for most of the current stable toolchain users. This is because the sysroot-abi proc-macro-srv on the current stable [discards] spans for `Group` delimiters in some code paths, which the popular `proc-macro2` crate almost always calls, and it makes the identity of match arm list's brackets lost, leading to the upmapping failure. This has been fixed by #14960, which will land in the next stable, 1.71.

[discards]: 8ede3aae28/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/abi_sysroot/ra_server.rs (L231)
2023-08-01 08:58:43 +00:00
bors
efc5a813de Auto merge of #15050 - alibektas:14957, r=Veykril
bugfix :  skip doc(hidden) default members

fixes  #14957 . I have two questions :

1.  I am definitely looking for a more idiomatic way for the things I added in `crates/ide-assists/src/utils.rs`. See `FIXME` in that file.
2. Would it be actually better to change `DefaultMethods` to something like

```rust
enum DefaultMethods {
     Only( IgnoreHidden ( bool ) ) ,
     None
}
```

instead of adding a boolean to every function that calls `crates/ide-assists/src/utils.rs::filter_assoc_items`
2023-08-01 08:38:36 +00:00
Max Heller
b9ee4a5167 working for path segments 2023-07-31 21:21:40 -04:00
Lukas Wirth
c7b34e4873 fix: Strip unused token ids from eager macro input token maps 2023-07-31 17:12:17 +02:00
bors
8202b5aaa7 Auto merge of #15366 - Veykril:eager-macro-inputs, r=Veykril
fix: Remove another faulty unwrap (expect)

Like the other ones, this also results in a panic when writing out `include!`  due to the missing tt
2023-07-31 15:09:34 +00:00
Lukas Wirth
bf5624664d fix: Remove another faulty unwrap (expect) 2023-07-31 16:47:45 +02:00
bors
7736b656e2 Auto merge of #15361 - Veykril:eager-macro-inputs, r=Veykril
fix: Expand eager macros to delimited comma separated expression list

Prior to this, we were just parsing it as an expression which works fine for `()` and `[]` calls as those are tuple and array expressions respectively, but if tails for `{}` calls which with my recent changes reported errors for such eager macro invocations.
2023-07-31 14:24:29 +00:00
Max Heller
91581becac update tests 2023-07-30 16:01:59 -04:00
hkalbasi
a9d81ae89c Support Self in mir lowering 2023-07-30 23:05:10 +03:30
bors
cecbed98d8 Auto merge of #15360 - lowr:fix/mbe-transcribe-path-of-different-types, r=HKalbasi
Fixup path fragments upon MBE transcription

Fixes #14367

There are roughly two types of paths: paths in expression context, where a separator `::` between an identifier and its following generic argument list is mandatory, and paths in type context, where `::` can be omitted.

Unlike rustc, we need to transform the parsed fragments back into tokens during transcription. When the matched path fragment is a type-context path and is transcribed as an expression-context path, verbatim transcription would cause a syntax error.

This PR fixes up path fragments by inserting `::` to make sure they are syntactically correct in all contexts. Note that this works because expression-context paths are a strict superset of type-context paths.
2023-07-30 17:29:36 +00:00
Lukas Wirth
7c765d9f9e fix: Expand eager macros to delimited comma separated expression list 2023-07-30 17:31:26 +02:00
Max Heller
c4cff80269 use nodes from actual file 2023-07-30 11:12:49 -04:00
Ryo Yoshida
fd7435d463
Fixup path fragments upon MBE transcription 2023-07-30 23:36:42 +09:00
bors
712b53865f Auto merge of #15359 - Veykril:proc-macro-srv-spawn-err, r=Veykril
Write proc-macro server spawn errors to the status text
2023-07-30 12:39:13 +00:00
Lukas Wirth
bd6ec06237 Write proc-macro server spawn errors to the status text 2023-07-30 14:38:25 +02:00
Lukas Wirth
df725d6b6d fix: Do not create fn macro calls with non-fn expanders 2023-07-30 12:18:19 +02:00
Lukas Wirth
3db437cbd6 fix: Fix bad unwrap in eager_macro_recur 2023-07-30 11:41:21 +02:00
Max Heller
784379eb79 wip 2023-07-29 15:23:35 -04:00
Max Heller
4bb7702833 check_edit test 2023-07-29 11:39:59 -04:00
bors
f442c4aad6 Auto merge of #15353 - HKalbasi:mir, r=HKalbasi
Add manual implementation of clone for tuples in mir interpreter

And some other minor changes.

Clone for tuple is not implemented in the std and it is magically implemented by the compiler, so we need this.
2023-07-28 16:02:13 +00:00
hkalbasi
bd2a8ca507 Add manual implementation of clone for tuples in mir interpreter 2023-07-28 18:52:01 +03:30
Max Heller
bc2b70d678 formatting 2023-07-28 09:23:05 -04:00
Max Heller
047bc47ecd
Cleanup
Co-authored-by: LowR <low.ryoshida@gmail.com>
2023-07-28 09:22:22 -04:00