mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-17 07:45:08 +00:00
introduce hacks module
This commit is contained in:
parent
aa1788dc71
commit
bfc263f1f9
6 changed files with 34 additions and 51 deletions
|
@ -40,6 +40,7 @@ pub mod ast;
|
|||
pub mod fuzz;
|
||||
pub mod utils;
|
||||
pub mod ted;
|
||||
pub mod hacks;
|
||||
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
||||
|
@ -167,26 +168,6 @@ impl SourceFile {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: `parse` functions shouldn't hang directly from AST nodes, and they
|
||||
// shouldn't return `Result`.
|
||||
//
|
||||
// We need a dedicated module for parser entry points, and they should always
|
||||
// return `Parse`.
|
||||
|
||||
impl ast::Path {
|
||||
/// Returns `text`, parsed as a path, but only if it has no errors.
|
||||
pub fn parse(text: &str) -> Result<Self, ()> {
|
||||
parsing::parse_text_as(text, parser::ParserEntryPoint::Path)
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::Expr {
|
||||
/// Returns `text`, parsed as an expression, but only if it has no errors.
|
||||
pub fn parse(text: &str) -> Result<Self, ()> {
|
||||
parsing::parse_text_as(text, parser::ParserEntryPoint::Expr)
|
||||
}
|
||||
}
|
||||
|
||||
/// Matches a `SyntaxNode` against an `ast` type.
|
||||
///
|
||||
/// # Example:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue