From f6e52dafdee305d16d6778e7bfe935bd9a6ae38b Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 25 Feb 2022 12:48:26 -0500 Subject: [PATCH] syntax: fix 'unused' warnings 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. --- regex-syntax/src/ast/print.rs | 9 ++++----- regex-syntax/src/hir/print.rs | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/regex-syntax/src/ast/print.rs b/regex-syntax/src/ast/print.rs index 283ce4c57..045de2eaf 100644 --- a/regex-syntax/src/ast/print.rs +++ b/regex-syntax/src/ast/print.rs @@ -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(&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 { wtr: W, } -impl<'p, W: fmt::Write> Visitor for Writer<'p, W> { +impl Visitor for Writer { type Output = (); type Err = fmt::Error; @@ -153,7 +152,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> { } } -impl<'p, W: fmt::Write> Writer<'p, W> { +impl Writer { fn fmt_group_pre(&mut self, ast: &ast::Group) -> fmt::Result { use crate::ast::GroupKind::*; match ast.kind { diff --git a/regex-syntax/src/hir/print.rs b/regex-syntax/src/hir/print.rs index ff18c6e92..b71f3897c 100644 --- a/regex-syntax/src/hir/print.rs +++ b/regex-syntax/src/hir/print.rs @@ -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(&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 { wtr: W, } -impl<'p, W: fmt::Write> Visitor for Writer<'p, W> { +impl Visitor for Writer { type Output = (); type Err = fmt::Error; @@ -209,7 +208,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> { } } -impl<'p, W: fmt::Write> Writer<'p, W> { +impl Writer { fn write_literal_char(&mut self, c: char) -> fmt::Result { if is_meta_character(c) { self.wtr.write_str("\\")?;