mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-18 08:10:11 +00:00
fix: Reimplement mapping out of test/bench attributes for runnables
This commit is contained in:
parent
73668334f0
commit
d2513deb62
2 changed files with 17 additions and 2 deletions
|
@ -701,6 +701,16 @@ impl<N: AstNode> InFile<N> {
|
|||
}
|
||||
}
|
||||
|
||||
impl InFile<ast::Fn> {
|
||||
pub fn map_out_of_test_attr(self, db: &dyn db::AstDatabase) -> InFile<ast::Fn> {
|
||||
(|| {
|
||||
let InFile { file_id, value } = self.file_id.call_node(db)?;
|
||||
ast::Fn::cast(value).map(|n| InFile::new(file_id, n))
|
||||
})()
|
||||
.unwrap_or(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// In Rust, macros expand token trees to token trees. When we want to turn a
|
||||
/// token tree into an AST node, we need to figure out what kind of AST node we
|
||||
/// want: something like `foo` can be a type, an expression, or a pattern.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue