Skip to content

Commit f3d639f

Browse files
Remove duplicated code for delayed lints between rustc_hir_analysis and rustdoc
1 parent 2b502f5 commit f3d639f

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn provide(providers: &mut Providers) {
148148
};
149149
}
150150

151-
fn emit_delayed_lint(lint: &DelayedLint, tcx: TyCtxt<'_>) {
151+
pub fn emit_delayed_lint(lint: &DelayedLint, tcx: TyCtxt<'_>) {
152152
struct DiagEmitter<'tcx> {
153153
hir_id: rustc_hir::HirId,
154154
tcx: TyCtxt<'tcx>,

src/librustdoc/lib.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ use std::process::ExitCode;
7474

7575
use rustc_errors::DiagCtxtHandle;
7676
use rustc_hir::def_id::LOCAL_CRATE;
77-
use rustc_hir::lints::DelayedLint;
7877
use rustc_interface::interface;
7978
use rustc_middle::ty::TyCtxt;
8079
use rustc_session::config::{ErrorOutputType, RustcOptGroup, make_crate_type_option};
@@ -772,19 +771,6 @@ fn run_merge_finalize(opt: config::RenderOptions) -> Result<(), error::Error> {
772771
Ok(())
773772
}
774773

775-
struct DiagEmitter<'tcx> {
776-
hir_id: rustc_hir::HirId,
777-
tcx: TyCtxt<'tcx>,
778-
span: rustc_span::Span,
779-
lint: &'static rustc_lint::Lint,
780-
}
781-
782-
impl rustc_lint::EmitDiag for DiagEmitter<'_> {
783-
fn emit(&self, diag: impl for<'a> rustc_errors::Diagnostic<'a, ()>) {
784-
self.tcx.emit_node_span_lint(self.lint, self.hir_id, self.span, diag);
785-
}
786-
}
787-
788774
fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
789775
// Throw away the first argument, the name of the binary.
790776
// In case of at_args being empty, as might be the case by
@@ -923,21 +909,7 @@ fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
923909
for owner_id in tcx.hir_crate_items(()).delayed_lint_items() {
924910
if let Some(delayed_lints) = tcx.opt_ast_lowering_delayed_lints(owner_id) {
925911
for lint in &delayed_lints.lints {
926-
match lint {
927-
DelayedLint::AttributeParsing(attribute_lint) => {
928-
rustc_lint::decorate_attribute_lint(
929-
&DiagEmitter {
930-
hir_id: attribute_lint.id,
931-
tcx,
932-
span: attribute_lint.span,
933-
lint: attribute_lint.lint_id.lint,
934-
},
935-
tcx.sess,
936-
Some(tcx),
937-
&attribute_lint.kind,
938-
);
939-
}
940-
}
912+
rustc_hir_analysis::emit_delayed_lint(lint, tcx);
941913
}
942914
}
943915
}

0 commit comments

Comments
 (0)