rust/crates
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
..
base-db fix: Fix body lowering not using block def maps 2023-05-04 20:46:05 +02:00
cfg ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
flycheck Bump Cargo.lock 2023-03-25 15:12:39 +01:00
hir Auto merge of #14781 - lowr:patch/macro-subns-and-prelude, r=Veykril 2023-05-11 14:26:59 +00:00
hir-def Consider macro sub-namespace during name resolution 2023-05-11 21:13:12 +09:00
hir-expand fix: column!() and line!() built-in macros return u32 2023-05-11 21:13:05 +09:00
hir-ty Auto merge of #14781 - lowr:patch/macro-subns-and-prelude, r=Veykril 2023-05-11 14:26:59 +00:00
ide Add basic support for augmentsSyntaxTokens 2023-05-10 20:48:51 +02:00
ide-assists Fix pattern type mismatch in tuples 2023-05-04 16:03:36 +03:30
ide-completion Auto merge of #14513 - hecatia-elegua:alias-based-completion2, r=Veykril 2023-04-24 06:34:25 +00:00
ide-db Return Option 2023-05-06 00:57:57 -07:00
ide-diagnostics Fix pattern type mismatch in tuples 2023-05-04 16:03:36 +03:30
ide-ssr Depend on nohash-hasher individually 2023-05-06 00:49:23 -07:00
intern Use triomphe Arc 2023-05-02 20:02:43 +03:00
limit Move Expander and LowerCtx into separate modules 2023-04-17 20:44:06 +02:00
mbe Use boxed slices instead ovecs in decl macros 2023-05-02 17:04:53 +02:00
parser Parse bare dyn types with leading lifetime 2023-05-05 04:30:37 +09:00
paths accepting review suggestions 2023-05-02 11:01:41 -03:00
proc-macro-api Use triomphe Arc 2023-05-02 20:02:43 +03:00
proc-macro-srv Encode closing delimiter span in FlatTrees 2023-04-14 10:34:41 +02:00
proc-macro-srv-cli Remove proc-macro server command from the rust-analyzer binary 2023-04-26 08:19:28 +02:00
proc-macro-test ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
profile internal: Add some additional status ouput 2023-04-22 09:34:47 +02:00
project-model Use triomphe Arc 2023-05-02 20:02:43 +03:00
rust-analyzer Add config for disabling non standard lsp highlight tokens 2023-05-11 10:01:38 +02:00
sourcegen Use retain_mut in CommentBlock::extract 2023-03-31 17:41:40 -04:00
stdx Depend on nohash-hasher individually 2023-05-06 00:49:23 -07:00
syntax Use triomphe Arc 2023-05-02 20:02:43 +03:00
test-utils Make text-size a workspace dep 2023-05-06 00:49:23 -07:00
text-edit Make text-size a workspace dep 2023-05-06 00:49:23 -07:00
toolchain ⬆️ rust-analyzer 2023-03-13 10:42:24 +02:00
tt Emit function bodies in expanding builtin derives 2023-05-03 14:14:47 +03:30
vfs Depend on nohash-hasher individually 2023-05-06 00:49:23 -07:00
vfs-notify ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00