mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
23747419ca
This PR will fix some typos detected by [typos]. There are also some other typos in the function names, variable names, and file names, which I leave as they are. I'm more certain that typos in comments should be fixed. [typos]: https://github.com/crate-ci/typos
15 lines
486 B
Rust
15 lines
486 B
Rust
//! Things which exist to solve practical issues, but which shouldn't exist.
|
|
//!
|
|
//! Please avoid adding new usages of the functions in this module
|
|
|
|
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 expr = file.syntax_node().descendants().find_map(ast::Expr::cast)?;
|
|
if expr.syntax().text() != s {
|
|
return None;
|
|
}
|
|
Some(expr)
|
|
}
|