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_metadata/src | |
| 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_metadata/src')
| -rw-r--r-- | compiler/rustc_metadata/src/creader.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/native_libs.rs | 50 |
2 files changed, 35 insertions, 23 deletions
diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index f667aec03c5..a9e3b55aeee 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -825,11 +825,13 @@ impl<'a> CrateLoader<'a> { for (_, data) in self.cstore.iter_crate_data() { if data.has_global_allocator() { match global_allocator { - Some(other_crate) => self.sess.err(&format!( + Some(other_crate) => { + self.sess.err(&format!( "the `#[global_allocator]` in {} conflicts with global allocator in: {}", other_crate, data.name() - )), + )); + } None => global_allocator = Some(data.name()), } } @@ -864,7 +866,7 @@ impl<'a> CrateLoader<'a> { // don't perform this validation if the session has errors, as one of // those errors may indicate a circular dependency which could cause // this to stack overflow. - if self.sess.has_errors() { + if self.sess.has_errors().is_some() { return; } diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index f4bc28f4da1..c3a76112391 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -145,41 +145,49 @@ impl<'tcx> ItemLikeVisitor<'tcx> for Collector<'tcx> { ("bundle", NativeLibKind::Static { bundle, .. }) => { *bundle = Some(value); } - ("bundle", _) => sess.span_err( - span, - "bundle linking modifier is only compatible with \ + ("bundle", _) => { + sess.span_err( + span, + "bundle linking modifier is only compatible with \ `static` linking kind", - ), + ); + } ("verbatim", _) => lib.verbatim = Some(value), ("whole-archive", NativeLibKind::Static { whole_archive, .. }) => { *whole_archive = Some(value); } - ("whole-archive", _) => sess.span_err( - span, - "whole-archive linking modifier is only compatible with \ + ("whole-archive", _) => { + sess.span_err( + span, + "whole-archive linking modifier is only compatible with \ `static` linking kind", - ), + ); + } ("as-needed", NativeLibKind::Dylib { as_needed }) | ("as-needed", NativeLibKind::Framework { as_needed }) => { *as_needed = Some(value); } - ("as-needed", _) => sess.span_err( - span, - "as-needed linking modifier is only compatible with \ + ("as-needed", _) => { + sess.span_err( + span, + "as-needed linking modifier is only compatible with \ `dylib` and `framework` linking kinds", - ), + ); + } - _ => sess.span_err( - span, - &format!( - "unrecognized linking modifier `{}`, expected one \ + _ => { + sess.span_err( + span, + &format!( + "unrecognized linking modifier `{}`, expected one \ of: bundle, verbatim, whole-archive, as-needed", - modifier - ), - ), + modifier + ), + ); + } } } } else { @@ -247,7 +255,9 @@ impl Collector<'_> { Some(span) => { struct_span_err!(self.tcx.sess, span, E0455, "{}", msg).emit(); } - None => self.tcx.sess.err(msg), + None => { + self.tcx.sess.err(msg); + } } } if lib.cfg.is_some() && !self.tcx.features().link_cfg { |
