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.
rust-analyzer is a modular compiler frontend for the Rust language. It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust.
Quick Start
https://rust-analyzer.github.io/manual.html#installation
Documentation
If you want to contribute to rust-analyzer or are just curious about how things work under the hood, check the ./docs/dev folder.
If you want to use rust-analyzer's language server with your editor of choice, check the manual folder. It also contains some tips & tricks to help you be more productive when using rust-analyzer.
Security and Privacy
See the corresponding sections of the manual.
Communication
For usage and troubleshooting requests, please use "IDEs and Editors" category of the Rust forum:
https://users.rust-lang.org/c/ide/14
For questions about development and implementation, join rust-analyzer working group on Zulip:
https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer
Quick Links
- Website: https://rust-analyzer.github.io/
- Metrics: https://rust-analyzer.github.io/metrics/
- API docs: https://rust-lang.github.io/rust-analyzer/ide/
- Changelog: https://rust-analyzer.github.io/thisweek
License
rust-analyzer is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.