Skip to content

Commit

Permalink
Rename ShowSpanVisitor::span_diagnostic as ShowSpanVisitor::dcx.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Dec 18, 2023
1 parent 5ad7144 commit dea752e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions compiler/rustc_ast_passes/src/show_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,37 @@ impl FromStr for Mode {
}

struct ShowSpanVisitor<'a> {
span_diagnostic: &'a rustc_errors::DiagCtxt,
dcx: &'a rustc_errors::DiagCtxt,
mode: Mode,
}

impl<'a> Visitor<'a> for ShowSpanVisitor<'a> {
fn visit_expr(&mut self, e: &'a ast::Expr) {
if let Mode::Expression = self.mode {
self.span_diagnostic.emit_warning(errors::ShowSpan { span: e.span, msg: "expression" });
self.dcx.emit_warning(errors::ShowSpan { span: e.span, msg: "expression" });
}
visit::walk_expr(self, e);
}

fn visit_pat(&mut self, p: &'a ast::Pat) {
if let Mode::Pattern = self.mode {
self.span_diagnostic.emit_warning(errors::ShowSpan { span: p.span, msg: "pattern" });
self.dcx.emit_warning(errors::ShowSpan { span: p.span, msg: "pattern" });
}
visit::walk_pat(self, p);
}

fn visit_ty(&mut self, t: &'a ast::Ty) {
if let Mode::Type = self.mode {
self.span_diagnostic.emit_warning(errors::ShowSpan { span: t.span, msg: "type" });
self.dcx.emit_warning(errors::ShowSpan { span: t.span, msg: "type" });
}
visit::walk_ty(self, t);
}
}

pub fn run(span_diagnostic: &rustc_errors::DiagCtxt, mode: &str, krate: &ast::Crate) {
pub fn run(dcx: &rustc_errors::DiagCtxt, mode: &str, krate: &ast::Crate) {
let Ok(mode) = mode.parse() else {
return;
};
let mut v = ShowSpanVisitor { span_diagnostic, mode };
let mut v = ShowSpanVisitor { dcx, mode };
visit::walk_crate(&mut v, krate);
}

0 comments on commit dea752e

Please sign in to comment.