@@ -50,15 +50,15 @@ macro_rules! panictry_buffer {
50
50
}
51
51
52
52
pub 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 ) ;
54
54
parser. parse_crate_mod ( )
55
55
}
56
56
57
57
pub fn parse_crate_attrs_from_file < ' a > (
58
58
input : & Path ,
59
59
sess : & ' a ParseSess ,
60
60
) -> 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 ) ;
62
62
parser. parse_inner_attributes ( )
63
63
}
64
64
@@ -106,8 +106,9 @@ pub fn maybe_new_parser_from_source_str(
106
106
}
107
107
108
108
/// 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) )
111
112
}
112
113
113
114
/// 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>(
120
121
maybe_source_file_to_parser ( sess, file)
121
122
}
122
123
123
- /// Given a session, a path, and a span,
124
- /// add 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 > ( sess : & ' a ParseSess , path : & Path , sp : Span ) -> Parser < ' a > {
127
- source_file_to_parser ( sess, file_to_source_file ( sess, path, Some ( sp) ) )
128
- }
129
-
130
124
/// Given a `source_file` and config, returns a parser.
131
125
fn source_file_to_parser ( sess : & ParseSess , source_file : Lrc < SourceFile > ) -> Parser < ' _ > {
132
126
panictry_buffer ! ( & sess. span_diagnostic, maybe_source_file_to_parser( sess, source_file) )
0 commit comments