Skip to content

Commit

Permalink
refactor(rust): remove some #[allow(unused)] (#5716)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Sep 12, 2024
1 parent c3dd2a0 commit 4bdc202
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 18 deletions.
3 changes: 1 addition & 2 deletions crates/oxc_prettier/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ pub struct IfBreak<'a> {
}

#[derive(Clone, Copy)]
#[allow(unused)]
pub enum Separator {
#[allow(unused)]
Softline,
Hardline,
CommaLine, // [",", line]
Expand Down Expand Up @@ -196,7 +196,6 @@ pub trait DocBuilder<'a> {
Box::new_in(doc, self.allocator())
}

#[allow(unused)]
fn join(&self, separator: Separator, docs: std::vec::Vec<Doc<'a>>) -> Vec<'a, Doc<'a>> {
let mut parts = self.vec();
for (i, doc) in docs.into_iter().enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_prettier/src/format/misc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use oxc_ast::{ast::*, AstKind};
use oxc_span::Span;

use crate::{array, doc::Doc, indent, line, space, ss, Prettier};
use crate::{array, doc::Doc, indent, line, space, ss, DocBuilder, Prettier};

pub(super) fn adjust_clause<'a>(
p: &Prettier<'a>,
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_prettier/src/format/ternary.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use oxc_ast::ast::*;

use crate::{doc::Doc, group, indent, line, ss, Format, Prettier};
use crate::{doc::Doc, group, indent, line, ss, DocBuilder, Format, Prettier};

pub(super) fn print_ternary<'a>(p: &mut Prettier<'a>, expr: &ConditionalExpression<'a>) -> Doc<'a> {
group![
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_prettier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ impl<'a> Prettier<'a> {
self.should_print_comma_impl(false)
}

#[allow(unused)]
fn should_print_all_comma(&self) -> bool {
self.should_print_comma_impl(true)
}
Expand Down
8 changes: 1 addition & 7 deletions crates/oxc_prettier/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ macro_rules! string {
macro_rules! indent {
($p:ident, $( $x:expr ),* $(,)?) => {
{
use $crate::doc::DocBuilder;
let mut temp_vec = $p.vec();
$(
temp_vec.push($x);
Expand Down Expand Up @@ -81,7 +80,6 @@ macro_rules! hardline {
macro_rules! array {
($p:ident, $( $x:expr ),* $(,)?) => {
{
use $crate::doc::DocBuilder;
let mut temp_vec = $p.vec();
$(
temp_vec.push($x);
Expand All @@ -95,7 +93,6 @@ macro_rules! array {
macro_rules! group {
($p:ident, $( $x:expr ),* $(,)?) => {
{
use $crate::doc::DocBuilder;
let mut temp_vec = $p.vec();
$(
temp_vec.push($x);
Expand All @@ -109,7 +106,6 @@ macro_rules! group {
macro_rules! conditional_group {
($p:ident, $c: expr, $( $x:expr ),* $(,)?) => {
{
use $crate::doc::DocBuilder;
let mut temp_vec = $p.vec();
$(
temp_vec.push($x);
Expand All @@ -124,7 +120,6 @@ macro_rules! conditional_group {
macro_rules! group_break {
($p:ident, $( $x:expr ),* $(,)?) => {
{
use $crate::doc::DocBuilder;
let mut temp_vec = $p.vec();
$(
temp_vec.push($x);
Expand All @@ -137,7 +132,7 @@ macro_rules! group_break {
#[macro_export]
macro_rules! if_break {
($p:ident, $s:expr, $flat:expr, $group_id:expr) => {{
use $crate::doc::{DocBuilder, IfBreak};
use $crate::doc::IfBreak;
Doc::IfBreak(IfBreak {
break_contents: $p.boxed(Doc::Str($s)),
flat_content: $p.boxed(Doc::Str($flat)),
Expand All @@ -156,7 +151,6 @@ macro_rules! if_break {
macro_rules! line_suffix {
($p:ident, $( $x:expr ),* $(,)?) => {
{
use $crate::doc::DocBuilder;
let mut temp_vec = $p.vec();
$(
temp_vec.push($x);
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_prettier/src/needs_parens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use oxc_syntax::{
precedence::GetPrecedence,
};

use crate::{array, binaryish::BinaryishOperator, doc::Doc, ss, Prettier};
use crate::{array, binaryish::BinaryishOperator, doc::Doc, ss, DocBuilder, Prettier};

impl<'a> Prettier<'a> {
pub(crate) fn wrap_parens(&mut self, doc: Doc<'a>, kind: AstKind<'a>) -> Doc<'a> {
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_semantic/src/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl Counts {
counts
}

#[cfg(debug_assertions)]
pub fn assert_accurate(actual: &Self, estimated: &Self) {
assert_eq!(actual.nodes, estimated.nodes, "nodes count mismatch");
assert_eq!(actual.scopes, estimated.scopes, "scopes count mismatch");
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_semantic/tests/integration/util/expect.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub trait Expect<P, R> {
#[allow(unused)]
#[must_use]
fn expect<F>(self, expectation: F) -> Self
where
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_transformer/src/env/targets/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use super::{version::Version, Versions};
#[allow(clippy::large_enum_variant)]
pub enum Targets {
Query(Query),
#[allow(unused)]
EsModules(EsModules),
Versions(Versions),
HashMap(FxHashMap<String, QueryOrVersion>),
Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_transformer/src/helpers/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ impl<'a> BoundIdentifier<'a> {
}

/// Create `IdentifierReference` referencing this binding, which is written to, with specified `Span`
#[allow(unused)]
pub fn create_spanned_write_reference(
&self,
span: Span,
Expand All @@ -127,7 +126,6 @@ impl<'a> BoundIdentifier<'a> {

/// Create `IdentifierReference` referencing this binding, which is read from + written to,
/// with specified `Span`
#[allow(unused)]
pub fn create_spanned_read_write_reference(
&self,
span: Span,
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_transformer/src/typescript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use crate::context::Ctx;
///
/// In: `const x: number = 0;`
/// Out: `const x = 0;`
#[allow(unused)]
pub struct TypeScript<'a> {
options: Rc<TypeScriptOptions>,
ctx: Ctx<'a>,
Expand Down

0 comments on commit 4bdc202

Please sign in to comment.