diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-21 23:10:10 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-22 00:35:20 +0100 |
| commit | eaa0ae503fd952c7296d8787d70460fe96ccf9ee (patch) | |
| tree | f92746697bffa1028daba2b3dff6335a0adc5c46 /src/librustc_parse | |
| parent | d18ed205c9032003e2f3b3227a40bdc8f8763c9b (diff) | |
| download | rust-eaa0ae503fd952c7296d8787d70460fe96ccf9ee.tar.gz rust-eaa0ae503fd952c7296d8787d70460fe96ccf9ee.zip | |
parse: nix new_sub_parser_from_file
Diffstat (limited to 'src/librustc_parse')
| -rw-r--r-- | src/librustc_parse/lib.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/librustc_parse/lib.rs b/src/librustc_parse/lib.rs index 112c733a81b..13fb85db847 100644 --- a/src/librustc_parse/lib.rs +++ b/src/librustc_parse/lib.rs @@ -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)) |
