Commit graph

26832 commits

Author SHA1 Message Date
bors
9db515503f Auto merge of #16224 - Veykril:syntax-ctx, r=Veykril
fix: Fix SyntaxContextID using incorrect self IDs

Follow up to https://github.com/rust-lang/rust-analyzer/issues/16200, there was another logical bug there.
2024-01-01 11:56:12 +00:00
Lukas Wirth
0c3fbba3b9 fix: Fix SyntaxContextID using incorrect self IDs 2024-01-01 12:54:30 +01:00
bors
cf52c4b2b3 Auto merge of #16221 - holly-hacker:fix-16200, r=lnicola
fix: Fix out-of-bounds panic in some macros due to unhandled self_ref

Fixes #16200

I don't fully understand these changes, I just applied and tested the changes suggested in #16200 and they seem to fix the issue on both the repro and my original project.
2023-12-31 14:50:02 +00:00
HoLLy
c13330971d Fix out-of-bounds panic in some macros due to unhandled self_ref 2023-12-31 12:51:43 +01:00
bors
e872f5085c Auto merge of #16217 - hurryabit:simplify-apply-change, r=lnicola
internal: Simplify implementation of apply_document_changes

While reading through the code base, I stumbled across a piece of code that I found hard to read despite its simple purpose. This is my attempt at making the code easier to understand for future readers.

I won't be offended if this is too minor and not worth your time.
2023-12-30 19:43:04 +00:00
Martin Huschenbett
b9933fdaaa minor: Simplify implementation of apply_document_changes
While reading through the code base, I stumbled across a piece of code that I found hard to read despite its simple purpose. This is my attempt at making the code easier to understand for future readers.

I won't be offended if this is too minor and not worth your time.
2023-12-30 19:21:35 +01:00
bors
e1e4626ff5 Auto merge of #16206 - cuishuang:master, r=lnicola
Fix some comments
2023-12-29 18:09:02 +00:00
cui fliter
638df27f99 Fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-12-29 11:50:24 +08:00
bors
3ab1666370 Auto merge of #16096 - LuisFerLCC:master, r=lnicola
fix: update VSCode rust-panic problem matcher

Corrected the `rust-panic` task problem matcher for the VSCode Extension to match the new panic message pattern.

From:
```
thread 'main' panicked at 'PANIC_MESSAGE', src/main.rs:L:C
```
To:
```
thread 'main' panicked at src/main.rs:L:C:
PANIC_MESSAGE
```
2023-12-27 13:51:54 +00:00
bors
85fb463fc5 Auto merge of #16190 - Young-Flash:test_case_negative_impl, r=lnicola
add test case for negative impl

add a small test case to ensure that we don't emit `trait_impl_redundant_assoc_item` diagnostic for negative impl trait
2023-12-24 12:36:39 +00:00
Young-Flash
cc73c00d81 add test case for negative impl 2023-12-24 20:07:33 +08:00
bors
a24ede2066 Auto merge of #16185 - Young-Flash:fix_auto_remove_brace, r=lnicola
fix: remove wrong comma after remove unnecessary braces

![remove_comma](https://github.com/rust-lang/rust-analyzer/assets/71162630/56ef8cfc-a024-4c4a-82de-a8cca513b32e)

follow up https://github.com/rust-lang/rust-analyzer/pull/16066, close https://github.com/rust-lang/rust-analyzer/issues/16181
2023-12-23 13:53:19 +00:00
Young-Flash
6c9d2ad1d5 test: add test case for remove comma 2023-12-22 21:04:53 +08:00
Young-Flash
2426d421b4 fix: remove wrong comma after remove unnecessary braces 2023-12-22 21:02:13 +08:00
bors
afbb8f31ff Auto merge of #16184 - Veykril:completion-panic, r=Veykril
fix: Fix completions analysis not caching all nodes in Semantics

Fixes https://github.com/rust-lang/rust-analyzer/issues/16161
2023-12-22 12:13:46 +00:00
bors
3643c379d5 Auto merge of #16183 - Veykril:expander, r=Veykril
internal: Cleanup Expander a bit
2023-12-22 12:02:31 +00:00
Lukas Wirth
91046e9e45 fix: Fix completions analysis not caching all nodes in Semantics 2023-12-22 13:01:48 +01:00
Lukas Wirth
9d24764624 internal: Cleanup Expander a bit 2023-12-22 13:01:13 +01:00
bors
d2dacc0393 Auto merge of #16182 - Veykril:world-symbols-focus-range, r=Veykril
internal: Update world symbols request definiton, prefer focus range for macros

Prior to this, the symbol search would always jump to the defining macro call, not it jumps to the name in the macro call input if possible. This is a large improvement for assoc items in an attribute impl or trait.
2023-12-22 10:54:01 +00:00
bors
23a1280106 Auto merge of #16137 - unexge:complete-macros-in-macro-use, r=Veykril
Complete exported macros in `#[macro_use($0)]`

Closes https://github.com/rust-lang/rust-analyzer/issues/15657.

Originally added a test case for incomplete input:
```rust
#[test]
fn completes_incomplete_syntax() {
    check(
        r#"
//- /dep.rs crate:dep
#[macro_export]
macro_rules! foo {
    () => {};
}

//- /main.rs crate:main deps:dep
#[macro_use($0
extern crate dep;
"#,
        expect![[r#"
                ma foo
            "#]],
    )
}
```

but couldn't make it pass and removed it 😅 Our current recovering logic doesn't work for token trees and for this code:
```rust
#[macro_use(
extern crate lazy_static;

fn main() {}
```

we ended up with this syntax tree:
```
SOURCE_FILE@0..53
  ATTR@0..52
    POUND@0..1 "#"
    L_BRACK@1..2 "["
    META@2..52
      PATH@2..11
        PATH_SEGMENT@2..11
          NAME_REF@2..11
            IDENT@2..11 "macro_use"
      TOKEN_TREE@11..52
        L_PAREN@11..12 "("
        WHITESPACE@12..13 "\n"
        EXTERN_KW@13..19 "extern"
        WHITESPACE@19..20 " "
        CRATE_KW@20..25 "crate"
        WHITESPACE@25..26 " "
        IDENT@26..37 "lazy_static"
        SEMICOLON@37..38 ";"
        WHITESPACE@38..40 "\n\n"
        FN_KW@40..42 "fn"
        WHITESPACE@42..43 " "
        IDENT@43..47 "main"
        TOKEN_TREE@47..49
          L_PAREN@47..48 "("
          R_PAREN@48..49 ")"
        WHITESPACE@49..50 " "
        TOKEN_TREE@50..52
          L_CURLY@50..51 "{"
          R_CURLY@51..52 "}"
  WHITESPACE@52..53 "\n"
```

Maybe we can try to parse the token tree in `crates/ide-completion/src/context/analysis.rs` but I'm not sure what's the best way forward.
2023-12-22 10:42:38 +00:00
Lukas Wirth
2a5b60b186 internal: Update world symbols request definiton, prefer focus range for macros 2023-12-22 11:42:08 +01:00
bors
20e09c6968 Auto merge of #16088 - Veykril:proc-macro-srv-2, r=Veykril
feat: Implement a rust-analyzer span backed proc-macro server mode

This implements the basic span APIs. Basically anything that doesn't require talking back to the client for information access.

This also commits our syntax fixup marker to use an `ErasedAstFileId` of `!0-1` aka `0xffff_fffe`, instead of using a dummy FileId as a marker, as we need that for the `SourceFile` API to be implementable. The reason as to why the server needs to know about this at all is to prevent it from creating invalid fixup spans which could make r-a panic.
2023-12-22 09:49:05 +00:00
Lukas Wirth
5761b50ed8 More general server config message for proc-macro-api 2023-12-22 10:35:10 +01:00
Lukas Wirth
9e8e124269 Special case fixup spans in server::Span impl, they are immutable 2023-12-22 10:13:00 +01:00
Lukas Wirth
2e52aa1615 Clean up 2023-12-21 17:24:00 +01:00
Lukas Wirth
ca957f4f82 Fix proc-macro-test-impl building without any proc-macros 2023-12-21 17:24:00 +01:00
Lukas Wirth
9197b541c2 Fix dead code warnings 2023-12-21 17:23:56 +01:00
Lukas Wirth
96051bc0d8 Fix workspace layout 2023-12-21 17:23:36 +01:00
Lukas Wirth
874df3bffa Add eager-expand comment 2023-12-21 17:23:36 +01:00
Lukas Wirth
c89fd01739 Move proc-macro-test into proc-macro-srv 2023-12-21 17:23:33 +01:00
Lukas Wirth
f427f56812 Implement other non-db reliant server::Span functions 2023-12-21 17:23:04 +01:00
Lukas Wirth
428a34a9b4 Implement server::Span::Join 2023-12-21 17:23:04 +01:00
Lukas Wirth
6be83b8204 Fix IDE layer not resolving assoc type paths in path qualifiers 2023-12-21 17:23:03 +01:00
Lukas Wirth
a892237ed4 Add rust-analyzer-span server feature equivalent to the ID server 2023-12-21 17:22:59 +01:00
bors
3ce35931db Auto merge of #16178 - Veykril:builtin-fn-callsite, r=Veykril
fix: Fix span marking for builtin fn macros
2023-12-21 15:22:23 +00:00
Lukas Wirth
5bdb479131 fix: Fix span marking for builtin fn macros 2023-12-21 16:20:27 +01:00
bors
9ee71b43ca Auto merge of #16175 - Veykril:dummy-spans, r=Veykril
fix: Correctly set and mark the proc-macro spans

This slows down analysis by 2-3s on self for me unfortunately (~2.5% slowdown)

Noisy diff due to two simple refactoring in the first 2 commits. Relevant changes are [7d762d1](7d762d18ed) and [1e1113c](1e1113cf5f) which introduce def site spans and correct marking for proc-macros respectively.
2023-12-21 10:00:13 +00:00
Lukas Wirth
1e1113cf5f Correctly set and mark the proc-macro spans 2023-12-21 10:51:54 +01:00
Lukas Wirth
7d762d18ed Record macro def site spans 2023-12-21 09:54:47 +01:00
Lukas Wirth
51a9e7831a Rename some things and turn macro to macro def into a query 2023-12-21 09:18:25 +01:00
Lukas Wirth
071fe4e4e9 Move Intern and Lookup traits to hir-expand 2023-12-20 21:24:20 +01:00
bors
337e2abb67 Auto merge of #16167 - Veykril:dummy-spans, r=Veykril
fix: Fully remove dummy spans

Fixes https://github.com/rust-lang/rust-analyzer/issues/16008

Some of these spans are certainly wrong, but since we discard invisible delimiters currently it doesn't really matter.
2023-12-20 13:33:36 +00:00
bors
65ed198819 Auto merge of #16066 - Young-Flash:auto_remove_brace, r=lnicola
fix: auto remove unnecessary braces after remove unused imports

before
![before](https://github.com/rust-lang/rust-analyzer/assets/71162630/8d44f955-f84f-4a92-b13f-5a2dee2ded36)

after
![after](https://github.com/rust-lang/rust-analyzer/assets/71162630/1eab23c8-39bd-4711-97c1-d483ce400a18)
2023-12-20 13:22:00 +00:00
Lukas Wirth
f211a40f1f Remove SyntaxContext trait 2023-12-20 14:02:40 +01:00
Lukas Wirth
7b804552a5 Remove Delimiter::DUMMY_INVISIBLE 2023-12-20 14:00:14 +01:00
Lukas Wirth
2c6ce480e3 Remove Delimier::dummy_invisible 2023-12-20 13:06:46 +01:00
Lukas Wirth
4ec81230db Remove usages of Span::DUMMY 2023-12-20 12:53:46 +01:00
Young-Flash
4cd939ad08 chore: add test case for nested use tree 2023-12-20 19:44:57 +08:00
Young-Flash
bc2dee7429 feat: auto remove unnecessary braces after remove unused imports 2023-12-20 19:44:53 +08:00
bors
7bdf48ce37 Auto merge of #16165 - Veykril:meta-vars, r=Veykril
fix: Update metavariable expression implementation

Fixes https://github.com/rust-lang/rust-analyzer/issues/16154
This duplicates behavior of that before and after PR https://github.com/rust-lang/rust/pull/117050 based on the toolchain version. There are some 1.76 nightlies that are still broken (any before that PR basically) but fetching and storing the commit makes little sense to me (opposed to the toolchain version).
2023-12-20 10:30:58 +00:00