parse: nix new_sub_parser_from_file
This commit is contained in:
parent
d18ed205c9
commit
eaa0ae503f
4 changed files with 10 additions and 16 deletions
|
@ -50,7 +50,7 @@ macro_rules! panictry_buffer {
|
|||
}
|
||||
|
||||
pub fn parse_crate_from_file<'a>(input: &Path, sess: &'a ParseSess) -> PResult<'a, ast::Crate> {
|
||||
let mut parser = new_parser_from_file(sess, input);
|
||||
let mut parser = new_parser_from_file(sess, input, None);
|
||||
parser.parse_crate_mod()
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ pub fn parse_crate_attrs_from_file<'a>(
|
|||
input: &Path,
|
||||
sess: &'a ParseSess,
|
||||
) -> PResult<'a, Vec<ast::Attribute>> {
|
||||
let mut parser = new_parser_from_file(sess, input);
|
||||
let mut parser = new_parser_from_file(sess, input, None);
|
||||
parser.parse_inner_attributes()
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,9 @@ pub fn maybe_new_parser_from_source_str(
|
|||
}
|
||||
|
||||
/// Creates a new parser, handling errors as appropriate if the file doesn't exist.
|
||||
pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path) -> Parser<'a> {
|
||||
source_file_to_parser(sess, file_to_source_file(sess, path, None))
|
||||
/// If a span is given, that is used on an error as the as the source of the problem.
|
||||
pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Option<Span>) -> Parser<'a> {
|
||||
source_file_to_parser(sess, file_to_source_file(sess, path, sp))
|
||||
}
|
||||
|
||||
/// Creates a new parser, returning buffered diagnostics if the file doesn't exist,
|
||||
|
@ -120,13 +121,6 @@ pub fn maybe_new_parser_from_file<'a>(
|
|||
maybe_source_file_to_parser(sess, file)
|
||||
}
|
||||
|
||||
/// Given a session, a path, and a span,
|
||||
/// add the file at the given path to the `source_map`, and returns a parser.
|
||||
/// On an error, uses the given span as the source of the problem.
|
||||
pub fn new_sub_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Span) -> Parser<'a> {
|
||||
source_file_to_parser(sess, file_to_source_file(sess, path, Some(sp)))
|
||||
}
|
||||
|
||||
/// Given a `source_file` and config, returns a parser.
|
||||
fn source_file_to_parser(sess: &ParseSess, source_file: Lrc<SourceFile>) -> Parser<'_> {
|
||||
panictry_buffer!(&sess.span_diagnostic, maybe_source_file_to_parser(sess, source_file))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue