mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Merge #1815
1815: Support correct `$crate` expansion in macros r=uHOOCCOOHu a=uHOOCCOOHu This PR makes normal use cases of `$crate` from macros work as expected. It makes more macros from `std` work. Type inference works well with `panic`, `unimplemented`, `format`, and maybe more. Sadly that `vec![1, 2, 3]` still not works, but it is not longer an issue about macro. Screenshot:  Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
This commit is contained in:
commit
2b69c84396
20 changed files with 374 additions and 127 deletions
|
@ -21,6 +21,16 @@ impl ast::NameRef {
|
|||
pub fn text(&self) -> &SmolStr {
|
||||
text_of_first_token(self.syntax())
|
||||
}
|
||||
|
||||
pub fn as_tuple_field(&self) -> Option<usize> {
|
||||
self.syntax().children_with_tokens().find_map(|c| {
|
||||
if c.kind() == SyntaxKind::INT_NUMBER {
|
||||
c.as_token().and_then(|tok| tok.text().as_str().parse().ok())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn text_of_first_token(node: &SyntaxNode) -> &SmolStr {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue