File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,13 @@ pub fn compile_input(sess: &Session,
8484 // possible to keep the peak memory usage low
8585 let ( outputs, trans) = {
8686 let ( outputs, expanded_crate, id) = {
87- let krate = panictry ! ( phase_1_parse_input( sess, cfg, input) ) ;
87+ let krate = match phase_1_parse_input ( sess, cfg, input) {
88+ Ok ( krate) => krate,
89+ Err ( mut parse_error) => {
90+ parse_error. emit ( ) ;
91+ return Err ( 1 ) ;
92+ }
93+ } ;
8894
8995 controller_entry_point ! ( after_parse,
9096 sess,
Original file line number Diff line number Diff line change @@ -529,7 +529,19 @@ impl RustcDefaultCalls {
529529 return Compilation :: Continue ;
530530 }
531531
532- let attrs = input. map ( |input| panictry ! ( parse_crate_attrs( sess, input) ) ) ;
532+ let attrs = match input {
533+ None => None ,
534+ Some ( input) => {
535+ let result = parse_crate_attrs ( sess, input) ;
536+ match result {
537+ Ok ( attrs) => Some ( attrs) ,
538+ Err ( mut parse_error) => {
539+ parse_error. emit ( ) ;
540+ return Compilation :: Stop ;
541+ }
542+ }
543+ }
544+ } ;
533545 for req in & sess. opts . prints {
534546 match * req {
535547 PrintRequest :: TargetList => {
Original file line number Diff line number Diff line change @@ -120,6 +120,10 @@ pub fn parse_expr_from_source_str<'a>(name: String,
120120 p. parse_expr ( )
121121}
122122
123+ /// Parses an item.
124+ ///
125+ /// Returns `Ok(Some(item))` when successful, `Ok(None)` when no item was found, and`Err`
126+ /// when a syntax error occurred.
123127pub fn parse_item_from_source_str < ' a > ( name : String ,
124128 source : String ,
125129 cfg : ast:: CrateConfig ,
You can’t perform that action at this time.
0 commit comments