Skip to content

Commit d39a00a

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

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
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 & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -772,19 +772,6 @@ fn run_merge_finalize(opt: config::RenderOptions) -> Result<(), error::Error> {
772772
Ok(())
773773
}
774774

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-
788775
fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
789776
// Throw away the first argument, the name of the binary.
790777
// In case of at_args being empty, as might be the case by
@@ -923,21 +910,7 @@ fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
923910
for owner_id in tcx.hir_crate_items(()).delayed_lint_items() {
924911
if let Some(delayed_lints) = tcx.opt_ast_lowering_delayed_lints(owner_id) {
925912
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-
}
913+
rustc_hir_analysis::emit_delayed_lint(lint, tcx);
941914
}
942915
}
943916
}

0 commit comments

Comments
 (0)