Do less panicking in general
This commit is contained in:
parent
3a872782d3
commit
11e0ba4340
3 changed files with 24 additions and 2 deletions
|
|
@ -84,7 +84,13 @@ pub fn compile_input(sess: &Session,
|
|||
// possible to keep the peak memory usage low
|
||||
let (outputs, trans) = {
|
||||
let (outputs, expanded_crate, id) = {
|
||||
let krate = panictry!(phase_1_parse_input(sess, cfg, input));
|
||||
let krate = match phase_1_parse_input(sess, cfg, input) {
|
||||
Ok(krate) => krate,
|
||||
Err(mut parse_error) => {
|
||||
parse_error.emit();
|
||||
return Err(1);
|
||||
}
|
||||
};
|
||||
|
||||
controller_entry_point!(after_parse,
|
||||
sess,
|
||||
|
|
|
|||
|
|
@ -529,7 +529,19 @@ impl RustcDefaultCalls {
|
|||
return Compilation::Continue;
|
||||
}
|
||||
|
||||
let attrs = input.map(|input| panictry!(parse_crate_attrs(sess, input)));
|
||||
let attrs = match input {
|
||||
None => None,
|
||||
Some(input) => {
|
||||
let result = parse_crate_attrs(sess, input);
|
||||
match result {
|
||||
Ok(attrs) => Some(attrs),
|
||||
Err(mut parse_error) => {
|
||||
parse_error.emit();
|
||||
return Compilation::Stop;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
for req in &sess.opts.prints {
|
||||
match *req {
|
||||
PrintRequest::TargetList => {
|
||||
|
|
|
|||
|
|
@ -120,6 +120,10 @@ pub fn parse_expr_from_source_str<'a>(name: String,
|
|||
p.parse_expr()
|
||||
}
|
||||
|
||||
/// Parses an item.
|
||||
///
|
||||
/// Returns `Ok(Some(item))` when successful, `Ok(None)` when no item was found, and`Err`
|
||||
/// when a syntax error occurred.
|
||||
pub fn parse_item_from_source_str<'a>(name: String,
|
||||
source: String,
|
||||
cfg: ast::CrateConfig,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue