Commit Graph

25073 Commits

Author SHA1 Message Date
bors
884dd8c966 Auto merge of #14788 - HKalbasi:derive-impl-f, r=Veykril
Use double reference in debug derive

fix #14768
2023-05-12 09:14:55 +00: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
bors
b069eb720b Auto merge of #14777 - rust-lang:highlight, r=Veykril
Add basic support for `augmentsSyntaxTokens` and non-standard semantic token config

cc #12783
Closes https://github.com/rust-lang/rust-analyzer/issues/13066
2023-05-11 08:08:38 +00: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
bors
b7cdd93f3e Auto merge of #14747 - oxalica:feat/arena-idx-range, r=HKalbasi
More APIs for `la_arena::IdxRange`

```rust
impl<T> ExactSizeIterator for IdxRange<T>;

impl<T> Arena<T> {
    pub fn alloc_many<II: IntoIterator<Item = T>>(&mut self, iter: II) -> IdxRange<T>;
}
```

1. There are no currently ways to get `IdxRange` without manually offseting `Idx`. Providing a method for multiple-allocation simplifies this process and makes it less error-prone.
2. `IdxRange: ExactSizeIterator` makes `iter.zip(range).rev()` possible. Since `Zip: DoubleEndedIterator` requires all its arguments to be `ExactSizeIterator`. It also ease the usage for, eg. `len()`.
3. Fixed a typo.

I noticed that `IdxRange::end` may be invalid. Is it good to return `Idx` instead of `RawIdx`?
2023-05-09 17:36:48 +00:00
bors
c26a43d6bd Auto merge of #14764 - lnicola:deps-fixes-2, r=lnicola
minor: Hide deps panel outside of Rust projects and set missing category

Closes #14760
2023-05-08 18:44:59 +00:00
Laurențiu Nicola
f8477d0cb4 Hide deps panel outside of Rust projects and set missing category 2023-05-08 21:43:59 +03: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
053741c28c Remove duplicate command 2023-05-08 21:27:52 +03: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
aaf670b649 Auto merge of #14757 - azdavis:master, r=lnicola
Fix libs publish branch filter

line-index didn't actually get published from #14733, probably because the branch filter was for main but the main branch is called master here. This fixes the workflow file

I also tweaked the libs readme mostly just so the paths filter would pick up the changes.
2023-05-07 09:54:50 +00:00
Ariel Davis
db40fef6b1 Improve lib readme 2023-05-07 02:41:44 -07:00
Ariel Davis
913c1b846e Publish libs on master push 2023-05-07 02:40:37 -07: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
Ariel Davis
60056b8845 Expose len 2023-05-06 15:44:37 -07:00
Ariel Davis
9d4d45215a Rename 2023-05-06 15:44:09 -07:00
Ariel Davis
369e430b05 Improve doc 2023-05-06 15:42:15 -07:00
Ariel Davis
1cf74802ab Improve docs 2023-05-06 15:14:02 -07:00
Ariel Davis
ed498b6eff Rm out of bounds 2023-05-06 15:11:18 -07:00
Ariel Davis
cc2936b93e Use size field 2023-05-06 15:10:35 -07:00
Ariel Davis
510050ecdc Add more types 2023-05-06 15:09:34 -07:00
Ariel Davis
7a7f90cf28 Use de morgan 2023-05-06 15:06:51 -07:00
Ariel Davis
7cdca727a8 Use all not instead of find is none 2023-05-06 15:06:23 -07:00
Ariel Davis
e4d053e794 Rm into 2023-05-06 15:05:38 -07:00
Ariel Davis
1bc6bca478 Use checked 2023-05-06 15:05:03 -07: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
bors
bb66f6fc3c Auto merge of #14750 - lowr:fix/rustc_reservation_impl, r=HKalbasi
fix: ignore impls with `#[rustc_reservation_impl]`

Fixes #12247
Fixes #14279

Currently core has two blanket impls for `From`: `impl<T> From<T> for T` and `impl<T> From<!> for T`. These are conflicting and thus chalk cannot uniquely solve `S: From<?0>` for any type `S`.

The latter impl is actually a reservation impl and should not be considered during trait selection. More generally, impls attributed with perma-unstable `#[rustc_reservation_impl]` attribute should be disregarded except for coherence checks. See rust-lang/rust#64631 and rust-lang/rust#64715 for details.

I chose to entirely ignore them in hir-ty because we don't do coherence checks.
2023-05-06 17:44:48 +00:00
Ryo Yoshida
9360adccda
Ignore impls with #[rustc_reservation_impl] 2023-05-07 01:31:36 +09:00
bors
5ee39a6ee5 Auto merge of #14749 - matklad:matklad/panic-is-a-problem, r=lnicola
feat: define problem matcher for panics in VS Code

Now in VS Code "go to next error" (`F8`) will bring you to the source of a panic.
2023-05-06 15:54:00 +00:00
Aleksey Kladov
7bc60f512e feat: define problem matcher for panics in VS Code
Now in VS Code "go to next error" (`F8`) will bring you to the source of
a panic.
2023-05-06 16:49:42 +01:00
oxalica
add94d3b9c Impl FusedIterator for IdxRange 2023-05-06 22:02:30 +08:00
oxalica
665c0cb547 Forward Iterator::{count,last,nth} for IdxRange random access 2023-05-06 22:00:04 +08:00
Yury Ivanou
ecc081d625 Show type alias layout on hover 2023-05-06 16:58:57 +03:00
oxalica
86eaf53600 Fix typo in docs 2023-05-06 21:27:35 +08:00
oxalica
4e4940e21e Add Arena::alloc_many to easily get IdxRange
There are no currently ways to get `IdxRange` without manually offseting
`Idx`. Providing a method for multiple-allocation simplifies this
process and makes it less error-prone.
2023-05-06 21:21:00 +08:00