Commit graph

18733 commits

Author SHA1 Message Date
Lukas Wirth
3c8dd9e89e Expose whether a channel has been dropped in lsp-server errors 2024-01-01 14:10:46 +01:00
Lukas Wirth
06be1b1f34 minor: Render more crate information in status command 2024-01-01 13:32:04 +01:00
Lukas Wirth
0c3fbba3b9 fix: Fix SyntaxContextID using incorrect self IDs 2024-01-01 12:54:30 +01:00
Rose Hudson
5878651e7e add unresolved-assoc-item diagnostic 2023-12-31 17:36:40 +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
austaras
1b7968a2cb fix: try obligation of IndexMut when infer 2023-12-31 07:19:16 +08: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
Tetsuharu Ohzeki
efc87092b3 Use Cargo's [workspace.lints.*] to config clippy 2023-12-29 23:51:32 +09:00
cui fliter
638df27f99 Fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-12-29 11:50:24 +08: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
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
Lukas Wirth
f48ecb6e09 Try to support pre and post-change metavars 2023-12-19 20:45:12 +01:00
Lukas Wirth
8753ca5360 fix: Update metavariable expression implementation 2023-12-19 11:55:00 +01:00
bors
7204ee1262 Auto merge of #16163 - Veykril:goto-impl-fix, r=Veykril
fix: Deduplicate annotations

Fixes https://github.com/rust-lang/rust-analyzer/issues/16157
2023-12-19 07:50:23 +00:00
Lukas Wirth
002e611d09 fix: Deduplicate annotations 2023-12-19 08:49:00 +01:00
bors
dbd0b035e6 Auto merge of #16155 - Waqar144:work/fix-16142, r=lnicola
fix: Dont assume ascii in remove_markdown

Fixes #16142
2023-12-19 07:22:46 +00:00
bors
1c4c2200eb Auto merge of #16160 - Waqar144:work/use-reserve, r=Veykril
minor: Use reserve when removing markdown from text

After markdown syntax removal the length of the text is roughly the same so we can reserve memory beforehand
2023-12-19 07:11:20 +00:00
bors
484525f8d7 Auto merge of #16158 - saiintbrisson:fix/mbe/desugar-comment-to-raw-string, r=Veykril
fix(mbe): desugar doc correctly for mbe

Fixes #16110.

The way rust desugars doc comments when expanding macros is rendering it as raw strings delimited with hashes. Rust-analyzer wasn't aware of this, so the desugared doc comments wouldn't match correctly when on the LHS of macro declarations.

This PR fixes this by porting the code used by rustc:
59096cdad0/compiler/rustc_ast/src/tokenstream.rs (L662-L671)
2023-12-19 07:00:35 +00:00
Waqar Ahmed
13177e314d minor: Use reserve when removing markdown from text
After markdown syntax removal the length of the text is roughly the
same so we can reserve memory beforehand
2023-12-19 11:22:02 +05:00
Waqar Ahmed
9f4d26901b minor: use a single push_str instead of 2 push 2023-12-19 11:17:09 +05:00
Luiz Carvalho
6f58e98f2c
fix(mbe): update test 2023-12-19 01:03:00 -03:00
Luiz Carvalho
117a28a065
fix(mbe): desugar doc correctly for mbe
Fixes #16110.

The way rust desugars doc comments when expanding macros
is rendering it as raw strings delimited with hashes.
Rust-analyzer wasn't aware of this, so the desugared doc
comments wouldn't match correctly when on the LHS of macro
declarations.

This PR fixes this by porting the code used by rustc: 4cfdbd328b/compiler/rustc_ast/src/tokenstream.rs (L6837)
2023-12-19 00:55:56 -03:00
Waqar Ahmed
5318e89b8a fix: Dont assume ascii in remove_markdown
Fixes #16142
2023-12-19 01:27:36 +05:00
bors
0ed815faca Auto merge of #16151 - lnicola:minimal-2024-edition, r=davidbarsky
internal: Add minimal support for the 2024 edition

CC #16146
2023-12-18 17:33:20 +00:00
Laurențiu Nicola
fec0e04fc2 Add minimal support for the 2024 edition 2023-12-18 17:10:20 +02:00
bors
f6635211ce Auto merge of #16152 - Austaras:alias, r=Veykril
fix: resolve alias before resolve variant

Closes #15943 (again)
2023-12-18 15:08:36 +00:00
austaras
bd61888b8d fix: resolve alias before resolve variant 2023-12-18 22:31:58 +08:00
bors
ae2c3223b0 Auto merge of #16150 - Veykril:text-fixture, r=Veykril
internal: Move out `WithFixture` into dev-dep only crate
2023-12-18 14:26:51 +00:00
Lukas Wirth
f49a2fed3f internal: Move out WithFixture into dev-dep only crate 2023-12-18 15:24:08 +01:00
bors
bd03f92579 Auto merge of #16147 - lnicola:no-ap-sourcegen, r=lnicola
minor: Don't auto-publish sourcegen

Closes #16029
2023-12-18 14:03:38 +00:00
Laurențiu Nicola
66fa1c965e Don't auto-publish sourcegen 2023-12-18 15:54:01 +02:00
Lukas Wirth
ec6162308e Move the SpanMap definition into the span crate 2023-12-18 14:50:48 +01:00
Lukas Wirth
66e29be1bd internal: Split out a span crate 2023-12-18 14:08:33 +01:00
bors
cfc959d73a Auto merge of #16143 - Veykril:base-db-no-proc-macros, r=lnicola
internal: Move proc-macro knowledge out of base-db into hir-expand

It does not make much sense to me to have that live in base-db, additionally, it kind of conflicts with moving span things out into a separate crate
2023-12-18 12:18:24 +00:00
Laurențiu Nicola
e628f1715e Merge branch 'master' into sync-from-rust 2023-12-18 14:02:12 +02:00
Lukas Wirth
35620306a6 internal: Move proc-macro knowledge out of base-db 2023-12-18 12:37:18 +01:00
Laurențiu Nicola
e37cf75791 Merge commit '21b06c1beb9bb59369ffd652f5d617bcf6952e05' into sync-from-ra 2023-12-18 09:21:55 +02:00
Jimmy Miller
b67b352ac7 Make functions in impl have a container name
fixes #16015
2023-12-17 13:44:47 -05:00
bors
cac74d98f6 Auto merge of #118830 - GuillaumeGomez:env-tracked_env, r=Nilstrieb
Add support for `--env` on `tracked_env::var`

Follow-up of https://github.com/rust-lang/rust/pull/118368.
Part of Part of https://github.com/rust-lang/rust/issues/80792.

It adds support of the `--env` option for proc-macros through `tracked_env::var`.

r? `@Nilstrieb`
2023-12-17 04:23:08 +00:00
unexge
3b8801c3ac Go to definition for macros in #[macro_use(...)] 2023-12-16 18:00:29 +00:00
unexge
0e4902467f Add missing docs string 2023-12-16 17:10:11 +00:00
unexge
b986d8ac92 Complete exported macros in #[macro_use($0)] 2023-12-16 16:19:58 +00:00
bors
21b06c1beb Auto merge of #16131 - HKalbasi:rustc-tests-fixup, r=HKalbasi
Fix false positive type mismatch in const reference patterns
2023-12-15 15:42:00 +00:00
hkalbasi
4f722165b6 Fix false positive type mismatch in const reference patterns 2023-12-15 19:09:07 +03:30
bors
a7764198b1 Auto merge of #16123 - Veykril:simplify, r=Veykril
internal: Remove `ModuleId` from `TypeOwnerId`

It only exists due to the IDE layer, but we can encode this temporary hack more cleanly
2023-12-15 13:10:17 +00:00
Lukas Wirth
4c45d23948 fix: Syntax fixup now removes subtrees with fake spans 2023-12-15 13:52:49 +01:00
hkalbasi
7b9595a5ab Run rust-analyzer on rustc tests in metrics 2023-12-15 02:10:25 +03:30
Lukas Wirth
9083017c9d Remove ModuleId from TypeOwnerId 2023-12-14 14:11:57 +01:00
bors
35e2f13b5c Auto merge of #16121 - Veykril:assert-messages, r=Veykril
minor: Add messages to some asserts for better debugging

cc https://github.com/rust-lang/rust-analyzer/issues/16118
2023-12-14 09:27:14 +00:00
Lukas Wirth
070cd4e8b0 minor: Add messages to some asserts for better debugging 2023-12-14 10:24:41 +01:00
bors
dd07f1f2fb Auto merge of #15887 - jinohkang-theori:fix/ide-assists/convert_tuple_struct_to_named_struct/handle_refs_inside_macro_invocations, r=Veykril
Fix incorrectly replacing references in macro invocation in "Convert to named struct" assist

Fixes #15630.

Complements #13647 (same assist but missed this one), #14920 (inverse action assist).
2023-12-13 21:30:18 +00:00
hkalbasi
6a40400c13 Update builtin attrs from rustc 2023-12-13 21:18:24 +03:30
roife
38b5dcb53c fix: self type replacement with macros 2023-12-14 00:42:33 +08:00
roife
3449222ab1 fix: self type replacement in inline-function 2023-12-13 23:13:55 +08:00
bors
94af6c63b7 Auto merge of #16061 - Veykril:vec-completion, r=Veykril
fix: Fix fragment parser replacing matches with dummies on incomplete parses

Notably, this caused some completions in the `vec!` macro to no longer work. Fixes https://github.com/rust-lang/rust-analyzer/issues/15016
2023-12-13 09:59:13 +00:00
roife
5070534d32 fix: testcases in generate_delegate_trait 2023-12-13 11:42:45 +08:00
roife
59aa791fe6 fix: rewrite code_action generate_delegate_trait 2023-12-13 11:22:42 +08:00
Lukas Wirth
7cc6b0f2e9 Partially revert #16101 2023-12-12 22:53:40 +01:00
Lukas Wirth
c209b5f97c fix: Fix syntax bridge assigning invalid span to lifetime tokens 2023-12-12 22:05:21 +01:00
bors
dd42c1457d Auto merge of #16101 - Veykril:search-depedencies-fix, r=Veykril
fix: Fix `import_map::search_dependencies` getting confused by assoc and non assoc items with the same name

No test case as creating one is kind of tricky... Ideally the code should be restructured such that this collision wouldn't matter in the first place, its kind of a mess.

Fixes https://github.com/rust-lang/rust-analyzer/issues/16074
Fixes https://github.com/rust-lang/rust-analyzer/issues/16080
Fixes https://github.com/rust-lang/rust-analyzer/issues/15845
2023-12-12 14:51:25 +00:00
Lukas Wirth
ca995d765d fix: Fix import_map::search_dependencies getting confused by assoc and non assoc items with the same name 2023-12-12 15:45:42 +01:00
bors
d4accf8e96 Auto merge of #16099 - Veykril:flyimport, r=Veykril
internal: Improve import asset perf a bit

And bump the query limit from 40 to 100
2023-12-12 14:37:38 +00:00
Lukas Wirth
1604ad1a6d Bump DEFAULT_QUERY_SEARCH_LIMIT from 40 to 100 2023-12-12 15:36:22 +01:00