diff options
| author | mark <markm@cs.wisc.edu> | 2022-01-22 18:49:12 -0600 |
|---|---|---|
| committer | mark <markm@cs.wisc.edu> | 2022-03-16 10:35:24 -0500 |
| commit | bb8d4307eb723850e98bcb52d71d860a4aba220a (patch) | |
| tree | f3215627c474542776bdbcb03f634651a89b70f8 /compiler/rustc_interface/src/passes.rs | |
| parent | 461e8078010433ff7de2db2aaae8a3cfb0847215 (diff) | |
| download | rust-bb8d4307eb723850e98bcb52d71d860a4aba220a.tar.gz rust-bb8d4307eb723850e98bcb52d71d860a4aba220a.zip | |
rustc_error: make ErrorReported impossible to construct
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
Diffstat (limited to 'compiler/rustc_interface/src/passes.rs')
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 1aceb4e95e6..4f30e78f5e2 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -373,7 +373,7 @@ pub fn configure_and_expand( if recursion_limit_hit { // If we hit a recursion limit, exit early to avoid later passes getting overwhelmed // with a large AST - Err(ErrorGuaranteed) + Err(ErrorGuaranteed::unchecked_claim_error_was_emitted()) } else { Ok(krate) } @@ -413,7 +413,7 @@ pub fn configure_and_expand( ); msg.warn("The generated documentation may be incorrect"); - msg.emit() + msg.emit(); } else { krate = sess.time("maybe_create_a_macro_crate", || { let is_test_crate = sess.opts.test; @@ -742,29 +742,30 @@ pub fn prepare_outputs( if let Some(ref input_path) = compiler.input_path { if sess.opts.will_create_output_file() { if output_contains_path(&output_paths, input_path) { - sess.err(&format!( + let reported = sess.err(&format!( "the input file \"{}\" would be overwritten by the generated \ executable", input_path.display() )); - return Err(ErrorGuaranteed); + return Err(reported); } if let Some(dir_path) = output_conflicts_with_dir(&output_paths) { - sess.err(&format!( + let reported = sess.err(&format!( "the generated executable for the input file \"{}\" conflicts with the \ existing directory \"{}\"", input_path.display(), dir_path.display() )); - return Err(ErrorGuaranteed); + return Err(reported); } } } if let Some(ref dir) = compiler.temps_dir { if fs::create_dir_all(dir).is_err() { - sess.err("failed to find or create the directory specified by `--temps-dir`"); - return Err(ErrorGuaranteed); + let reported = + sess.err("failed to find or create the directory specified by `--temps-dir`"); + return Err(reported); } } @@ -776,8 +777,9 @@ pub fn prepare_outputs( if !only_dep_info { if let Some(ref dir) = compiler.output_dir { if fs::create_dir_all(dir).is_err() { - sess.err("failed to find or create the directory specified by `--out-dir`"); - return Err(ErrorGuaranteed); + let reported = + sess.err("failed to find or create the directory specified by `--out-dir`"); + return Err(reported); } } } @@ -987,8 +989,8 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { // lot of annoying errors in the ui tests (basically, // lint warnings and so on -- kindck used to do this abort, but // kindck is gone now). -nmatsakis - if sess.has_errors() { - return Err(ErrorGuaranteed); + if let Some(reported) = sess.has_errors() { + return Err(reported); } sess.time("misc_checking_3", || { |
