@@ -50,15 +50,15 @@ macro_rules! panictry_buffer {
5050}
5151
5252pub fn parse_crate_from_file < ' a > ( input : & Path , sess : & ' a ParseSess ) -> PResult < ' a , ast:: Crate > {
53- let mut parser = new_parser_from_file ( sess, input) ;
53+ let mut parser = new_parser_from_file ( sess, input, None ) ;
5454 parser. parse_crate_mod ( )
5555}
5656
5757pub fn parse_crate_attrs_from_file < ' a > (
5858 input : & Path ,
5959 sess : & ' a ParseSess ,
6060) -> PResult < ' a , Vec < ast:: Attribute > > {
61- let mut parser = new_parser_from_file ( sess, input) ;
61+ let mut parser = new_parser_from_file ( sess, input, None ) ;
6262 parser. parse_inner_attributes ( )
6363}
6464
@@ -106,8 +106,9 @@ pub fn maybe_new_parser_from_source_str(
106106}
107107
108108/// Creates a new parser, handling errors as appropriate if the file doesn't exist.
109- pub fn new_parser_from_file < ' a > ( sess : & ' a ParseSess , path : & Path ) -> Parser < ' a > {
110- source_file_to_parser ( sess, file_to_source_file ( sess, path, None ) )
109+ /// If a span is given, that is used on an error as the as the source of the problem.
110+ pub fn new_parser_from_file < ' a > ( sess : & ' a ParseSess , path : & Path , sp : Option < Span > ) -> Parser < ' a > {
111+ source_file_to_parser ( sess, file_to_source_file ( sess, path, sp) )
111112}
112113
113114/// Creates a new parser, returning buffered diagnostics if the file doesn't exist,
@@ -120,20 +121,6 @@ pub fn maybe_new_parser_from_file<'a>(
120121 maybe_source_file_to_parser ( sess, file)
121122}
122123
123- /// Given a session, a crate config, a path, and a span, add
124- /// the file at the given path to the `source_map`, and returns a parser.
125- /// On an error, uses the given span as the source of the problem.
126- pub fn new_sub_parser_from_file < ' a > (
127- sess : & ' a ParseSess ,
128- path : & Path ,
129- module_name : Option < String > ,
130- sp : Span ,
131- ) -> Parser < ' a > {
132- let mut p = source_file_to_parser ( sess, file_to_source_file ( sess, path, Some ( sp) ) ) ;
133- p. root_module_name = module_name;
134- p
135- }
136-
137124/// Given a `source_file` and config, returns a parser.
138125fn source_file_to_parser ( sess : & ParseSess , source_file : Lrc < SourceFile > ) -> Parser < ' _ > {
139126 panictry_buffer ! ( & sess. span_diagnostic, maybe_source_file_to_parser( sess, source_file) )
0 commit comments