mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
internal: Thread edition through to parsing/tt-to-syntax-tree routines for macros
This commit is contained in:
parent
83370fe5d7
commit
a483d3bc37
39 changed files with 187 additions and 145 deletions
|
@ -2,11 +2,13 @@
|
|||
//!
|
||||
//! Please avoid adding new usages of the functions in this module
|
||||
|
||||
use parser::Edition;
|
||||
|
||||
use crate::{ast, AstNode};
|
||||
|
||||
pub fn parse_expr_from_str(s: &str) -> Option<ast::Expr> {
|
||||
let s = s.trim();
|
||||
let file = ast::SourceFile::parse(&format!("const _: () = {s};"));
|
||||
let file = ast::SourceFile::parse(&format!("const _: () = {s};"), Edition::CURRENT);
|
||||
let expr = file.syntax_node().descendants().find_map(ast::Expr::cast)?;
|
||||
if expr.syntax().text() != s {
|
||||
return None;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue