Commit graph

17408 commits

Author SHA1 Message Date
bors
2f8cd66fb4 Auto merge of #14810 - Veykril:inline-module, r=Veykril
internal: Inline handlers module
2023-05-15 10:19:21 +00:00
bors
9eb26a9375 Auto merge of #14809 - lowr:patch/macro_use-filter, r=Veykril
Support `#[macro_use(name, ...)]`

This PR adds support for another form of the `macro_use` attribute: `#[macro_use(name, ...)]` ([reference]).

Note that this form of the attribute is only applicable to extern crate decls, not to mod decls.

[reference]: https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute
2023-05-15 10:04:05 +00:00
Lukas Wirth
9e80c8571d internal: Inline handlers module 2023-05-15 11:59:09 +02:00
bors
1e6bd6cb0d Auto merge of #14794 - Veykril:inlay-kind-refac, r=Veykril
Restructure InlayHint, no longer derive properties from its kind

Closes https://github.com/rust-lang/rust-analyzer/issues/14595
2023-05-15 09:49:17 +00:00
bors
b198815e7f Auto merge of #14775 - hecatia-elegua:doc-alias-methods, r=Veykril
feat: add #[doc(alias(..))]-based method completions

![Screenshot showing a completion when you type a doc alias instead of a real name](https://github.com/rust-lang/rust-analyzer/assets/108802164/e7c69bb9-3da6-4d8f-a09b-fece1bdd1c0e)
2023-05-15 09:32:10 +00:00
bors
bc03418127 Auto merge of #14746 - lowr:patch/associated-return-types, r=Veykril
Parse associated return type bounds

This PR implements parser support for associated return type bounds: `T: Foo<bar(): Send>`. This PR does not implement associated return types (`T::bar(): Send`) because it's not implemented even in rustc, and also removes `(..)`-style return type notation because it has been removed in rust-lang/rust#110203 (effectively reverting #14465).

I don't plan to proactively follow this unstable feature unless an RFC is accepted and my main motivation here is to remove no-longer-valid syntax `(..)` from our parser, nevertheless adding minimal parser support so anyone interested (as can be seen in #14465) can experiment it without rust-analyzer's syntax errors.
2023-05-15 09:16:51 +00:00
hkalbasi
206a0b5bc6 Add timer for new items 2023-05-14 22:34:58 +03:30
hkalbasi
431dd32f8a Unsized temporary is not an implementation error 2023-05-14 21:05:33 +03:30
Ryo Yoshida
1bc7f8a4c6
Support #[macro_use(name, ...)] 2023-05-15 00:05:44 +09:00
hkalbasi
51e8b8ff14 Add metrics for unevaluated constants, failed mir bodies, and failed data layouts 2023-05-14 17:12:28 +03:30
bors
cbd14e9840 Auto merge of #14801 - Veykril:process-changes-fix, r=Veykril
fix: Fix process-changes duplicating change events

Should fix https://github.com/rust-lang/rust-analyzer/issues/14791
2023-05-13 19:21:30 +00:00
Lukas Wirth
cace5bb35d fix: Fix process-changes duplicating change events 2023-05-13 21:21:03 +02:00
bors
daa03b0b0b Auto merge of #14800 - lowr:patch/macro-subns-and-prelude, r=Veykril
Expand more single ident macro calls upon item collection

Addresses https://github.com/rust-lang/rust-analyzer/pull/14781#issuecomment-1546201022

I believe this (almost) brings the number of unresolved names back to pre-#14781:

|r-a version|`analysis-stats compiler/rustc` (rust-lang/rust@69fef92ab2) |
|---|---|
|pre-#14781 (b069eb720b) | exprs: 2747778, ??ty: 122236 (4%), ?ty: 107826 (3%), !ty: 728 |
| #14781 (a7944a93a1) | exprs: 2713080, ??ty: 139651 (5%), ?ty: 114444 (4%), !ty: 730 |
| with this fix | exprs: 2747871, ??ty: 122237 (4%), ?ty: 108171 (3%), !ty: 676 |

(I haven't investigated on the increase in some numbers but hopefully not too much of a problem)

This is only a temporary solution. The core problem is that we haven't fully implemented the textual scope of legacy macros. For example, we *have been* failing to resolve `foo` in the following snippet, even before #14781 or after this patch. As noted in a FIXME, we need a way to resolve names in textual scope without eager expansion during item collection.

```rust
//- /main.rs crate:main deps:lib
lib::mk_foo!();
const A: i32 = foo!();
             //^^^^^^ unresolved-macro-call

//- /lib.rs crate:lib
#[macro_export]
macro_rules! mk_foo {
    () => {
        macro_rules! foo { () => { 42 } }
    }
}
```
2023-05-13 18:47:42 +00:00
Ryo Yoshida
e9ddb62c65
Expand more single ident macro calls upon their collection 2023-05-14 03:11:10 +09:00
mataha
9fff960636
Remove root from patched UNC windows path drives 2023-05-13 18:38:12 +02:00
bors
db8f39ce19 Auto merge of #14797 - Veykril:symbol-query, r=Veykril
fix: Fix perf regression from symbol index refactor

Should fix the regressions introduced by https://github.com/rust-lang/rust-analyzer/pull/14715 by partially rolling back the PR
2023-05-13 15:41:54 +00:00
Lukas Wirth
2e03b198ca fix: Fix perf regression from symbol index refactor 2023-05-13 17:41:09 +02:00
bors
a7944a93a1 Auto merge of #14735 - Veykril:forbid-relative-json, r=Veykril
internal: Forbid canonicalization of paths and normalize all rust-project.json paths

Closes https://github.com/rust-lang/rust-analyzer/issues/14728
cc https://github.com/rust-lang/rust-analyzer/pull/14430

- Removes canonicalization (and forbids it from being used in a sense, clippy could help here again with its lint in the future)
- Normalizes all paths in rust-project.json which we weren't doing in some cases
2023-05-13 10:01:03 +00:00
Lukas Wirth
f47caa666e Add AbsPath::absolutize 2023-05-13 11:51:28 +02:00
Lukas Wirth
8e116855f5 Add macro modifier for highlighting tokens in macro calls 2023-05-13 11:43:39 +02:00
Lukas Wirth
edd60f7b0d Simplify bind pat filtering 2023-05-13 11:02:57 +02:00
Lukas Wirth
730286b523 Restructure InlayHint, no longer derive properties from its kind 2023-05-13 10:42:26 +02:00
hkalbasi
7da80d4f67 Use double reference in debug derive 2023-05-12 12:36:57 +03:30
bors
9b3387454d Auto merge of #14781 - lowr:patch/macro-subns-and-prelude, r=Veykril
Introduce macro sub-namespaces and `macro_use` prelude

This PR implements two mechanisms needed for correct macro name resolution: macro sub-namespace and `macro_use` prelude.

- [macro sub-namespaces][subns-ref]

  Macros have two sub-namespaces: one for function-like macro and the other for those in attributes (including custom derive macros). When we're resolving a macro name for function-like macro, we should ignore non-function-like macros, and vice versa.

  This helps resolve single-segment macro names because we can (and should, as rustc does) fallback to names in preludes when the name in the current module scope is in different sub-namespace.

- [`macro_use` prelude][prelude-ref]

  `#[macro_use]`'d extern crate declarations (including the standard library) bring their macros into scope, but they should not be prioritized over local macros (those defined in place and those explicitly imported).

  We have been bringing them into legacy (textual) macro scope, which has the highest precedence in name resolution. This PR introduces the `macro_use` prelude in crate-level `DefMap`s, whose precedence is lower than local macros but higher than the standard library prelude.

The first 3 commits are drive-by fixes/refactors.

Fixes #8828 (prelude)
Fixes #12505 (prelude)
Fixes #12734 (prelude)
Fixes #13683 (prelude)
Fixes #13821 (prelude)
Fixes #13974 (prelude)
Fixes #14254 (namespace)

[subns-ref]: https://doc.rust-lang.org/reference/names/namespaces.html#sub-namespaces
[prelude-ref]: https://doc.rust-lang.org/reference/names/preludes.html#macro_use-prelude
2023-05-11 14:26:59 +00:00
Ryo Yoshida
f2a35deb50
Consider macro sub-namespace during name resolution 2023-05-11 21:13:12 +09:00
Ryo Yoshida
3203ea896d
Add macro_use prelude to DefMap 2023-05-11 21:13:11 +09:00
Ryo Yoshida
96113b7b8e
Remove prelude fallback path for Rust <1.52.0
We've already removed non-sysroot proc macro server, which effectively
removed support for Rust <1.64.0, so this removal of fallback path
shouldn't be problem at this point.
2023-05-11 21:13:10 +09:00
Ryo Yoshida
34a9129333
fix: column!() and line!() built-in macros return u32 2023-05-11 21:13:05 +09:00
Ryo Yoshida
a0a7860141
Refactor 2023-05-11 18:17:16 +09:00
Lukas Wirth
91d5a689c7 Add config for disabling non standard lsp highlight tokens 2023-05-11 10:01:38 +02:00
Lukas Wirth
4b42acf617 Add basic support for augmentsSyntaxTokens 2023-05-10 20:48:51 +02:00
hecatia-elegua
2a182f3f1f Add doc(alias)-based method completion 2023-05-10 12:51:08 +02:00
hecatia-elegua
d4b668a3bb Prepare tidy.rs 2023-05-10 12:47:05 +02:00
bors
aaed89ac04 Auto merge of #14763 - lnicola:dep-tree-fixes, r=lnicola
Fix manual formatting and remove duplicate command
2023-05-08 18:28:58 +00:00
Laurențiu Nicola
10637cf3e8 Fix formatting 2023-05-08 21:27:43 +03:00
Laurențiu Nicola
b632c7d322 Fix broken table 2023-05-08 21:27:35 +03:00
bors
d3ce333ec8 Auto merge of #14742 - Veykril:closure-capture-inlays, r=Veykril
feat: Closure capture inlay hints

I opted for a fictional `move(foo, &bar, &mut qux)` syntax here, disabled by default as these are not correct rust syntax and hence could cause confusion.
![image](https://user-images.githubusercontent.com/3757771/236447484-649a4ea6-ad61-496e-bad8-765a5236150e.png)
2023-05-08 09:52:29 +00:00
Lukas Wirth
4c5fd19ee5 Render places in capture inlay hints 2023-05-08 09:50:58 +02:00
bors
ff8b969951 Auto merge of #14727 - HKalbasi:mir, r=HKalbasi
Lazy evaluate consts in `path_to_const`

fix #14275
2023-05-08 07:14:57 +00:00
bors
833d5301d1 Auto merge of #14758 - lumenian:hover-layout-config, r=HKalbasi
Add config for disabling hover memory layout data

Requested in https://github.com/rust-lang/rust-analyzer/pull/14748#issuecomment-1537190252
2023-05-07 16:22:57 +00:00
Yury Ivanou
8e1ba7fdab Fix memory layout config not working for closures 2023-05-07 19:10:01 +03:00
Yury Ivanou
98a4c5049f Rename hover memory layout config key 2023-05-07 18:37:56 +03:00
Yury Ivanou
4ed0fa8414 Add config for disabling hover memory layout data 2023-05-07 18:21:07 +03:00
bors
260e996140 Auto merge of #14733 - azdavis:master, r=matklad
Make line-index a lib, use nohash_hasher

These seem like they are not specific to rust-analyzer and could be pulled out to their own libraries. So I did.

https://github.com/azdavis/millet/issues/31
2023-05-06 23:37:02 +00:00
bors
a10fd83120 Auto merge of #14748 - lumenian:type-alias-layout, r=HKalbasi
Show type alias layout

This PR expands on #13490 to allow displaying layout data on hover for type aliases.
2023-05-06 19:18:30 +00:00
Ryo Yoshida
9360adccda
Ignore impls with #[rustc_reservation_impl] 2023-05-07 01:31:36 +09:00
Yury Ivanou
ecc081d625 Show type alias layout on hover 2023-05-06 16:58:57 +03:00
Ryo Yoshida
fa2340a4df
Parse associated return type bounds 2023-05-06 20:31:11 +09:00
Ryo Yoshida
d7d8971203
Remove (..)-style return type notation 2023-05-06 20:30:17 +09:00
Ariel Davis
02e8bb0c6e Return Option 2023-05-06 00:57:57 -07:00