Commit Graph

164 Commits

Author SHA1 Message Date
Lukas Wirth
853f8a21f7 Fix cfg completions not working 2023-09-08 10:49:15 +02:00
Lukas Wirth
c0e402637e Emit builtin#format_args in builtin format_args expander 2023-09-06 18:08:20 +02:00
Lukas Wirth
b1575528c0 Move doc comment handling into ide-db 2023-09-02 16:27:26 +02:00
Laurențiu Nicola
30d8aa1bec Merge commit '9b3d03408c66749d56466bb09baf2a7177deb6ce' into sync-from-ra 2023-08-21 12:44:09 +03: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
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
Laurențiu Nicola
aa55ce9567 Merge commit 'baee6b338b0ea076cd7a9f18d47f175dd2ba0e5d' into sync-from-ra 2023-08-07 12:03:15 +03:00
Laurențiu Nicola
4704881b64 Merge commit '37f84c101bca43b11027f30ab0c2852f9325bc3d' into sync-from-ra 2023-07-17 16:49:15 +03:00
Laurențiu Nicola
9326cf7f0c Merge commit 'cd3bf9fe51676b520c546460e6d8919b8c8ff99f' into sync-from-ra 2023-06-19 09:14:04 +03:00
Laurențiu Nicola
c48062fe2a Merge commit 'aa9bc8612514d216f84eec218dfd19ab83f3598a' into sync-from-ra 2023-06-05 12:04:23 +03:00
Laurențiu Nicola
dbf04a5ee2 ⬆️ rust-analyzer 2023-03-20 08:31:01 +02:00
bors
544b4cfe4d Auto merge of #109069 - lnicola:rust-analyzer-2023-03-13, r=lnicola
⬆️ `rust-analyzer`

r? `@ghost`
2023-03-13 16:54:43 +00:00
Laurențiu Nicola
b2f6fd4f96 ⬆️ rust-analyzer 2023-03-13 10:42:24 +02:00
clubby789
c6da2f9d96 Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
Laurențiu Nicola
7e711da2f0 ⬆️ rust-analyzer 2023-02-20 10:14:12 +02:00
Laurențiu Nicola
bc45c7659a ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
arcnmx
25242fe93f ⬆️ rust-analyzer
Merge commit '368e0bb32f1178cf162c2ce5f7e10b7ae211eb26'
2023-01-09 10:36:22 -08:00
Laurențiu Nicola
a2a1d99545 ⬆️ rust-analyzer 2022-11-23 17:24:03 +02:00
Laurențiu Nicola
79923c382a ⬆️ rust-analyzer 2022-11-09 21:49:10 +02: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
f5fde4df43 ⬆️ rust-analyzer 2022-09-20 17:39:17 +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
3e358a6827 ⬆️ rust-analyzer 2022-08-30 14:51:24 +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
9d2cb42a41 ⬆️ rust-analyzer 2022-08-02 09:05:16 +03:00
Amos Wenger
a1f1b95d00 Merge commit 'e36a20c24f35a4cee82bbdc600289104c9237c22' into ra-sync-and-pms-component 2022-07-26 11:53:50 +02:00
Dorian Scheidt
13c83f90ac fix: Don't add braces to 'if' completion in match guard position
When the cursor is in a match arm, but before the fat arrow (=>) token, don't
add braces when autocompleting "if".

fixes #12823
2022-07-23 12:25:02 -05:00
Amos Wenger
7e285e1ef5 Run cargo fmt 2022-07-20 15:06:15 +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
bors
f3e9b38e26 Auto merge of #12646 - lowr:fix/11897, r=lowr
fix: escape receiver texts in completion

This PR fixes #11897 by escaping '\\' and '$' in the text of the receiver position expression. See [here](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax) for the specification of the snippet syntax (especially [this section](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#grammar) discusses escaping).

Although not all occurrences of '\\' and '$' have to be replaced, I chose to replace all as that's simpler and easier to understand. There *are* more clever ways to implement it, but I thought they were premature optimization for the time being (maybe I should put FIXME notes?).
2022-07-20 10:51:31 +00:00
Ryo Yoshida
cfc52adc65
Add comments 2022-07-20 19:11:14 +09:00
bors
0e7135615f Auto merge of #12800 - hi-rustin:rustin-patch-issue-12717, r=hi-rustin
Find original as node before compute ref match

part of https://github.com/rust-lang/rust-analyzer/issues/12717
2022-07-20 00:17:09 +00: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
hi-rustin
15016bc09f Find original as node before compute ref match
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-18 23:24:19 +08:00
iDawer
a0fd58bbbe Check for local IDs belong to same definition 2022-07-17 11:43:08 +05:00
bors
96481b7786 Auto merge of #12773 - Veykril:self-compl, r=Veykril
fix: Improve self param completion applicability

Fixes https://github.com/rust-lang/rust-analyzer/issues/9522
2022-07-16 10:28:52 +00:00
Lukas Wirth
b96f8f18b0 fix: Improve self param completion applicability 2022-07-16 12:28:41 +02:00
Lukas Wirth
7ff6c36716 fix: Don't show qualified path completions for private items 2022-07-15 13:30:43 +02:00
bors
5af3ef527c Auto merge of #12735 - feniljain:fix-completions, r=feniljain
fix(completion): `super::` completion at crate root and module depth aware

- should close #12439
- Suggest super according to the depth in tree
2022-07-14 11:53:29 +00:00
feniljain
4cbde4ed8f fix(completion): super:: completion at crate root and module depth
aware
2022-07-14 17:07:43 +05:30
TonalidadeHidrica
e3bde579c4 Fix obsolete completion.snippets config 2022-07-11 17:00:40 +09:00
TonalidadeHidrica
eaebead296 Fix config keys regarding imports in docs 2022-07-11 15:43:25 +09:00
Jonas Schievink
6c6ae965ba Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
Hongxu Xu
3248601a03 fix default type param value position 2022-07-07 07:28:55 +08:00
Hongxu Xu
0360ed53cf check arg_idx >= n_params only if arg_idx >= n_required_params 2022-07-07 00:54:46 +08:00