diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-23 20:13:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-23 20:13:07 +0100 |
| commit | a1645e5b57a42831e98b6c160b31f9f185e8b0c2 (patch) | |
| tree | f08a428f95494f258e824d579e808414ad021d6b | |
| parent | 8810af8082e760cf6d7930be88877e5aae2bf65a (diff) | |
| parent | cf382de0cc268e6af8d37d31323bf36d0099ade3 (diff) | |
| download | rust-a1645e5b57a42831e98b6c160b31f9f185e8b0c2.tar.gz rust-a1645e5b57a42831e98b6c160b31f9f185e8b0c2.zip | |
Rollup merge of #93229 - mark-i-m:noquiet, r=eddyb
Remove DiagnosticBuilder.quiet r? `@eddyb` cc https://github.com/rust-lang/rust/issues/69426 `@GuillaumeGomez` `@Manishearth`
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/html/render/span_map.rs | 12 |
3 files changed, 8 insertions, 25 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index dbacbba2ce0..16e9b265d69 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -445,9 +445,6 @@ struct HandlerInner { deduplicated_warn_count: usize, future_breakage_diagnostics: Vec<Diagnostic>, - - /// If set to `true`, no warning or error will be emitted. - quiet: bool, } /// A key denoting where from a diagnostic was stashed. @@ -563,19 +560,10 @@ impl Handler { emitted_diagnostics: Default::default(), stashed_diagnostics: Default::default(), future_breakage_diagnostics: Vec::new(), - quiet: false, }), } } - pub fn with_disabled_diagnostic<T, F: FnOnce() -> T>(&self, f: F) -> T { - let prev = self.inner.borrow_mut().quiet; - self.inner.borrow_mut().quiet = true; - let ret = f(); - self.inner.borrow_mut().quiet = prev; - ret - } - // This is here to not allow mutation of flags; // as of this writing it's only used in tests in librustc_middle. pub fn can_emit_warnings(&self) -> bool { @@ -946,7 +934,7 @@ impl HandlerInner { } fn emit_diagnostic(&mut self, diagnostic: &Diagnostic) { - if diagnostic.cancelled() || self.quiet { + if diagnostic.cancelled() { return; } @@ -1170,9 +1158,6 @@ impl HandlerInner { } fn delay_as_bug(&mut self, diagnostic: Diagnostic) { - if self.quiet { - return; - } if self.flags.report_delayed_bugs { self.emit_diagnostic(&diagnostic); } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 730e79a5647..9bcdd7f3da6 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -476,10 +476,6 @@ impl Session { &self.parse_sess.span_diagnostic } - pub fn with_disabled_diagnostic<T, F: FnOnce() -> T>(&self, f: F) -> T { - self.parse_sess.span_diagnostic.with_disabled_diagnostic(f) - } - /// Analogous to calling methods on the given `DiagnosticBuilder`, but /// deduplicates on lint ID, span (if any), and message for this `Session` fn diag_once<'a, 'b>( diff --git a/src/librustdoc/html/render/span_map.rs b/src/librustdoc/html/render/span_map.rs index 586f34cd2c8..731e18b1eec 100644 --- a/src/librustdoc/html/render/span_map.rs +++ b/src/librustdoc/html/render/span_map.rs @@ -134,11 +134,13 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> { if let Some(hir_id) = segment.hir_id { let hir = self.tcx.hir(); let body_id = hir.enclosing_body_owner(hir_id); - let typeck_results = self.tcx.sess.with_disabled_diagnostic(|| { - self.tcx.typeck_body( - hir.maybe_body_owned_by(body_id).expect("a body which isn't a body"), - ) - }); + // FIXME: this is showing error messages for parts of the code that are not + // compiled (because of cfg)! + // + // See discussion in https://github.com/rust-lang/rust/issues/69426#issuecomment-1019412352 + let typeck_results = self.tcx.typeck_body( + hir.maybe_body_owned_by(body_id).expect("a body which isn't a body"), + ); if let Some(def_id) = typeck_results.type_dependent_def_id(expr.hir_id) { self.matches.insert( segment.ident.span, |
