未验证 提交 a1645e5b 编写于 作者: M Matthias Krüger 提交者: GitHub

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`
...@@ -445,9 +445,6 @@ struct HandlerInner { ...@@ -445,9 +445,6 @@ struct HandlerInner {
deduplicated_warn_count: usize, deduplicated_warn_count: usize,
future_breakage_diagnostics: Vec<Diagnostic>, 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. /// A key denoting where from a diagnostic was stashed.
...@@ -563,19 +560,10 @@ pub fn with_emitter_and_flags( ...@@ -563,19 +560,10 @@ pub fn with_emitter_and_flags(
emitted_diagnostics: Default::default(), emitted_diagnostics: Default::default(),
stashed_diagnostics: Default::default(), stashed_diagnostics: Default::default(),
future_breakage_diagnostics: Vec::new(), 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; // This is here to not allow mutation of flags;
// as of this writing it's only used in tests in librustc_middle. // as of this writing it's only used in tests in librustc_middle.
pub fn can_emit_warnings(&self) -> bool { pub fn can_emit_warnings(&self) -> bool {
...@@ -946,7 +934,7 @@ fn emit_stashed_diagnostics(&mut self) { ...@@ -946,7 +934,7 @@ fn emit_stashed_diagnostics(&mut self) {
} }
fn emit_diagnostic(&mut self, diagnostic: &Diagnostic) { fn emit_diagnostic(&mut self, diagnostic: &Diagnostic) {
if diagnostic.cancelled() || self.quiet { if diagnostic.cancelled() {
return; return;
} }
...@@ -1170,9 +1158,6 @@ fn bug(&mut self, msg: &str) -> ! { ...@@ -1170,9 +1158,6 @@ fn bug(&mut self, msg: &str) -> ! {
} }
fn delay_as_bug(&mut self, diagnostic: Diagnostic) { fn delay_as_bug(&mut self, diagnostic: Diagnostic) {
if self.quiet {
return;
}
if self.flags.report_delayed_bugs { if self.flags.report_delayed_bugs {
self.emit_diagnostic(&diagnostic); self.emit_diagnostic(&diagnostic);
} }
......
...@@ -476,10 +476,6 @@ pub fn diagnostic(&self) -> &rustc_errors::Handler { ...@@ -476,10 +476,6 @@ pub fn diagnostic(&self) -> &rustc_errors::Handler {
&self.parse_sess.span_diagnostic &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 /// Analogous to calling methods on the given `DiagnosticBuilder`, but
/// deduplicates on lint ID, span (if any), and message for this `Session` /// deduplicates on lint ID, span (if any), and message for this `Session`
fn diag_once<'a, 'b>( fn diag_once<'a, 'b>(
......
...@@ -134,11 +134,13 @@ fn visit_expr(&mut self, expr: &'tcx rustc_hir::Expr<'tcx>) { ...@@ -134,11 +134,13 @@ fn visit_expr(&mut self, expr: &'tcx rustc_hir::Expr<'tcx>) {
if let Some(hir_id) = segment.hir_id { if let Some(hir_id) = segment.hir_id {
let hir = self.tcx.hir(); let hir = self.tcx.hir();
let body_id = hir.enclosing_body_owner(hir_id); let body_id = hir.enclosing_body_owner(hir_id);
let typeck_results = self.tcx.sess.with_disabled_diagnostic(|| { // FIXME: this is showing error messages for parts of the code that are not
self.tcx.typeck_body( // compiled (because of cfg)!
hir.maybe_body_owned_by(body_id).expect("a body which isn't a body"), //
) // 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) { if let Some(def_id) = typeck_results.type_dependent_def_id(expr.hir_id) {
self.matches.insert( self.matches.insert(
segment.ident.span, segment.ident.span,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册