Skip to content

Commit

Permalink
syntax: fix 'unused' warnings
Browse files Browse the repository at this point in the history
It looks like the dead code detector got smarter. We never ended up
using the 'printer' field in these visitors, so just get rid of it.
  • Loading branch information
BurntSushi committed Feb 25, 2022
1 parent 5197f21 commit f6e52da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions regex-syntax/src/ast/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,16 @@ impl Printer {
/// here are a `fmt::Formatter` (which is available in `fmt::Display`
/// implementations) or a `&mut String`.
pub fn print<W: fmt::Write>(&mut self, ast: &Ast, wtr: W) -> fmt::Result {
visitor::visit(ast, Writer { printer: self, wtr: wtr })
visitor::visit(ast, Writer { wtr })
}
}

#[derive(Debug)]
struct Writer<'p, W> {
printer: &'p mut Printer,
struct Writer<W> {
wtr: W,
}

impl<'p, W: fmt::Write> Visitor for Writer<'p, W> {
impl<W: fmt::Write> Visitor for Writer<W> {
type Output = ();
type Err = fmt::Error;

Expand Down Expand Up @@ -153,7 +152,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> {
}
}

impl<'p, W: fmt::Write> Writer<'p, W> {
impl<W: fmt::Write> Writer<W> {
fn fmt_group_pre(&mut self, ast: &ast::Group) -> fmt::Result {
use crate::ast::GroupKind::*;
match ast.kind {
Expand Down
9 changes: 4 additions & 5 deletions regex-syntax/src/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,16 @@ impl Printer {
/// here are a `fmt::Formatter` (which is available in `fmt::Display`
/// implementations) or a `&mut String`.
pub fn print<W: fmt::Write>(&mut self, hir: &Hir, wtr: W) -> fmt::Result {
visitor::visit(hir, Writer { printer: self, wtr: wtr })
visitor::visit(hir, Writer { wtr })
}
}

#[derive(Debug)]
struct Writer<'p, W> {
printer: &'p mut Printer,
struct Writer<W> {
wtr: W,
}

impl<'p, W: fmt::Write> Visitor for Writer<'p, W> {
impl<W: fmt::Write> Visitor for Writer<W> {
type Output = ();
type Err = fmt::Error;

Expand Down Expand Up @@ -209,7 +208,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> {
}
}

impl<'p, W: fmt::Write> Writer<'p, W> {
impl<W: fmt::Write> Writer<W> {
fn write_literal_char(&mut self, c: char) -> fmt::Result {
if is_meta_character(c) {
self.wtr.write_str("\\")?;
Expand Down

0 comments on commit f6e52da

Please sign in to comment.