5

Expand more single ident macro calls upon item collection by lowr · Pull Request...

 1 year ago
source link: https://github.com/rust-lang/rust-analyzer/pull/14800
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Contributor

Addresses #14781 (comment)

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

r-a version analysis-stats compiler/rustc (rust-lang/rust@69fef92)
pre-#14781 (b069eb7) exprs: 2747778, ??ty: 122236 (4%), ?ty: 107826 (3%), !ty: 728
#14781 (a7944a9) 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.

//- /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 } }
    }
}
Veykril reacted with rocket emoji

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK