mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Modify hacks::parse_expr_from_str()
to take an edition too
This will be needed as we parse unknown identifiers and want to insert them into source code.
This commit is contained in:
parent
e6d59e65ec
commit
ddbb28daa0
4 changed files with 14 additions and 10 deletions
|
@ -6,9 +6,9 @@ use parser::Edition;
|
|||
|
||||
use crate::{ast, AstNode};
|
||||
|
||||
pub fn parse_expr_from_str(s: &str) -> Option<ast::Expr> {
|
||||
pub fn parse_expr_from_str(s: &str, edition: Edition) -> Option<ast::Expr> {
|
||||
let s = s.trim();
|
||||
let file = ast::SourceFile::parse(&format!("const _: () = {s};"), Edition::CURRENT);
|
||||
let file = ast::SourceFile::parse(&format!("const _: () = {s};"), edition);
|
||||
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