diff options
| author | bors <bors@rust-lang.org> | 2022-03-18 00:35:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-18 00:35:19 +0000 |
| commit | cd119057160cedea245aa2679add56723f3dc784 (patch) | |
| tree | 21335c52669bb2665024cf37adf8d892925d9d31 /compiler/rustc_session/src | |
| parent | 4ca56d2b7bbe275bc6c9f3cd698c6e0719a07182 (diff) | |
| parent | 4493826d07bf38cca058b4d9e75bce14ceeeaab9 (diff) | |
| download | rust-cd119057160cedea245aa2679add56723f3dc784.tar.gz rust-cd119057160cedea245aa2679add56723f3dc784.zip | |
Auto merge of #95056 - Dylan-DPC:rollup-swtuw2n, r=Dylan-DPC
Rollup of 10 pull requests
Successful merges:
- #91133 (Improve `unsafe` diagnostic)
- #93222 (Make ErrorReported impossible to construct outside `rustc_errors`)
- #93745 (Stabilize ADX target feature)
- #94309 ([generator_interior] Be more precise with scopes of borrowed places)
- #94698 (Remove redundant code from copy-suggestions)
- #94731 (Suggest adding `{ .. }` around a const function call with arguments)
- #94960 (Fix many spelling mistakes)
- #94982 (Add deprecated_safe feature gate and attribute, cc #94978)
- #94997 (debuginfo: Fix ICE when generating name for type that produces a layout error.)
- #95000 (Fixed wrong type name in comment)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/output.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 45 | ||||
| -rw-r--r-- | compiler/rustc_session/src/utils.rs | 4 |
5 files changed, 33 insertions, 22 deletions
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index a6506dbad16..14420909f50 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -223,7 +223,7 @@ top_level_options!( /// `true` if we're emitting a JSON blob containing the unused externs json_unused_externs: bool [UNTRACKED], - /// `true` if we're emitting a JSON job containg a future-incompat report for lints + /// `true` if we're emitting a JSON job containing a future-incompat report for lints json_future_incompat: bool [TRACKED], pretty: Option<PpMode> [UNTRACKED], diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs index bca19e84cf8..7f696da86f2 100644 --- a/compiler/rustc_session/src/output.rs +++ b/compiler/rustc_session/src/output.rs @@ -100,7 +100,7 @@ pub fn validate_crate_name(sess: &Session, s: &str, sp: Option<Span>) { match sp { Some(sp) => sess.span_err(sp, s), None => sess.err(s), - } + }; err_count += 1; }; if s.is_empty() { diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 707c609d8bf..36bbccf1b90 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -69,7 +69,7 @@ pub struct SymbolGallery { impl SymbolGallery { /// Insert a symbol and its span into symbol gallery. - /// If the symbol has occurred before, ignore the new occurrance. + /// If the symbol has occurred before, ignore the new occurrence. pub fn insert(&self, symbol: Symbol, span: Span) { self.symbols.lock().entry(symbol).or_insert(span); } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index eabebfcf3ea..7eeb6f90f99 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -262,7 +262,7 @@ impl Session { } diag.emit(); // If we should err, make sure we did. - if must_err && !self.has_errors() { + if must_err && !self.has_errors().is_some() { // We have skipped a feature gate, and not run into other errors... reject. self.err( "`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature \ @@ -404,13 +404,13 @@ impl Session { self.span_err(sp, msg); } } - pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str) { + pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ErrorGuaranteed { self.diagnostic().span_err(sp, msg) } pub fn span_err_with_code<S: Into<MultiSpan>>(&self, sp: S, msg: &str, code: DiagnosticId) { self.diagnostic().span_err_with_code(sp, &msg, code) } - pub fn err(&self, msg: &str) { + pub fn err(&self, msg: &str) -> ErrorGuaranteed { self.diagnostic().err(msg) } pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed { @@ -420,7 +420,7 @@ impl Session { pub fn err_count(&self) -> usize { self.diagnostic().err_count() } - pub fn has_errors(&self) -> bool { + pub fn has_errors(&self) -> Option<ErrorGuaranteed> { self.diagnostic().has_errors() } pub fn has_errors_or_delayed_span_bugs(&self) -> bool { @@ -430,9 +430,9 @@ impl Session { self.diagnostic().abort_if_errors(); } pub fn compile_status(&self) -> Result<(), ErrorGuaranteed> { - if self.diagnostic().has_errors_or_lint_errors() { - self.diagnostic().emit_stashed_diagnostics(); - Err(ErrorGuaranteed) + if let Some(reported) = self.diagnostic().has_errors_or_lint_errors() { + let _ = self.diagnostic().emit_stashed_diagnostics(); + Err(reported) } else { Ok(()) } @@ -444,7 +444,11 @@ impl Session { { let old_count = self.err_count(); let result = f(); - if self.err_count() == old_count { Ok(result) } else { Err(ErrorGuaranteed) } + if self.err_count() == old_count { + Ok(result) + } else { + Err(ErrorGuaranteed::unchecked_claim_error_was_emitted()) + } } pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) { self.diagnostic().span_warn(sp, msg) @@ -457,7 +461,7 @@ impl Session { } /// Delay a span_bug() call until abort_if_errors() #[track_caller] - pub fn delay_span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) { + pub fn delay_span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ErrorGuaranteed { self.diagnostic().delay_span_bug(sp, msg) } @@ -1387,12 +1391,18 @@ fn validate_commandline_args_with_session_available(sess: &Session) { let unsupported_sanitizers = sess.opts.debugging_opts.sanitizer - supported_sanitizers; match unsupported_sanitizers.into_iter().count() { 0 => {} - 1 => sess - .err(&format!("{} sanitizer is not supported for this target", unsupported_sanitizers)), - _ => sess.err(&format!( - "{} sanitizers are not supported for this target", - unsupported_sanitizers - )), + 1 => { + sess.err(&format!( + "{} sanitizer is not supported for this target", + unsupported_sanitizers + )); + } + _ => { + sess.err(&format!( + "{} sanitizers are not supported for this target", + unsupported_sanitizers + )); + } } // Cannot mix and match sanitizers. let mut sanitizer_iter = sess.opts.debugging_opts.sanitizer.into_iter(); @@ -1446,7 +1456,7 @@ pub enum IncrCompSession { InvalidBecauseOfErrors { session_directory: PathBuf }, } -pub fn early_error_no_abort(output: config::ErrorOutputType, msg: &str) { +pub fn early_error_no_abort(output: config::ErrorOutputType, msg: &str) -> ErrorGuaranteed { let emitter: Box<dyn Emitter + sync::Send> = match output { config::ErrorOutputType::HumanReadable(kind) => { let (short, color_config) = kind.unzip(); @@ -1457,7 +1467,8 @@ pub fn early_error_no_abort(output: config::ErrorOutputType, msg: &str) { } }; let handler = rustc_errors::Handler::with_emitter(true, None, emitter); - handler.struct_fatal(msg).emit(); + let reported = handler.struct_fatal(msg).emit(); + reported } pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs index 1a044e677a0..a33f94013d2 100644 --- a/compiler/rustc_session/src/utils.rs +++ b/compiler/rustc_session/src/utils.rs @@ -29,14 +29,14 @@ pub enum NativeLibKind { /// Dynamic library (e.g. `libfoo.so` on Linux) /// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC). Dylib { - /// Whether the dynamic library will be linked only if it satifies some undefined symbols + /// Whether the dynamic library will be linked only if it satisfies some undefined symbols as_needed: Option<bool>, }, /// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library. RawDylib, /// A macOS-specific kind of dynamic libraries. Framework { - /// Whether the framework will be linked only if it satifies some undefined symbols + /// Whether the framework will be linked only if it satisfies some undefined symbols as_needed: Option<bool>, }, /// The library kind wasn't specified, `Dylib` is currently used as a default. |
