File tree 3 files changed +24
-2
lines changed
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,
84
84
// possible to keep the peak memory usage low
85
85
let ( outputs, trans) = {
86
86
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
+ } ;
88
94
89
95
controller_entry_point ! ( after_parse,
90
96
sess,
Original file line number Diff line number Diff line change @@ -529,7 +529,19 @@ impl RustcDefaultCalls {
529
529
return Compilation :: Continue ;
530
530
}
531
531
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
+ } ;
533
545
for req in & sess. opts . prints {
534
546
match * req {
535
547
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,
120
120
p. parse_expr ( )
121
121
}
122
122
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.
123
127
pub fn parse_item_from_source_str < ' a > ( name : String ,
124
128
source : String ,
125
129
cfg : ast:: CrateConfig ,
You can’t perform that action at this time.
0 commit comments