Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectively allow unused fields and trait members for rust-1.83 #470

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions librubyfmt/src/parser_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,17 @@ where
fn current_formatting_context(&self) -> FormattingContext;
fn is_absorbing_indents(&self) -> bool;
fn has_comments_in_line(&self, start_line: LineNumber, end_line: LineNumber) -> bool;

#[allow(unused)]
fn current_line_number(&self) -> u64;

// blocks
#[allow(unused)]
fn start_indent(&mut self);
fn start_indent_for_call_chain(&mut self);
#[allow(unused)]
fn end_indent_for_call_chain(&mut self);
#[allow(unused)]
fn end_indent(&mut self);
fn with_formatting_context(&mut self, fc: FormattingContext, f: RenderFunc);
fn new_scope(&mut self, f: RenderFunc);
Expand All @@ -153,6 +158,7 @@ where
fn with_suppress_comments(&mut self, suppress: bool, f: RenderFunc);
fn will_render_as_multiline(&mut self, f: RenderFunc) -> bool;

#[allow(unused)]
fn will_render_beyond_max_line_length(&mut self, f: RenderFunc) -> bool;

// stuff to remove from this enum
Expand Down
18 changes: 16 additions & 2 deletions librubyfmt/src/ripper_tree_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,7 @@ impl Params {
// we have for some reason.
#[derive(RipperDeserialize, Debug, Clone)]
pub enum RestParamOr0OrExcessedComma {
#[allow(unused)]
Zero(i64),
RestParam(RestParam),
ExcessedComma(ExcessedComma),
Expand Down Expand Up @@ -1290,6 +1291,7 @@ impl Params {
#[allow(clippy::large_enum_variant)]
pub enum ExpressionOrFalse {
Expression(Expression),
#[allow(unused)]
False(bool),
}

Expand All @@ -1312,6 +1314,7 @@ def_tag!(blockarg_tag, "blockarg");
pub struct BlockArg(pub blockarg_tag, pub Option<Ident>);

#[derive(Deserialize, Debug, Clone)]
#[allow(unused)]
pub struct LineCol(pub LineNumber, pub u64);

#[derive(Deserialize, Debug, Clone, Eq, PartialEq)]
Expand Down Expand Up @@ -1415,16 +1418,19 @@ pub enum ArgNode {
Exprs(Vec<Expression>),
Const(Const),
Ident(Ident),
#[allow(unused)]
Null(Option<String>),
}

def_tag!(arg_paren_tag, "arg_paren");
#[derive(Deserialize, Debug, Clone)]
#[allow(unused)]
pub struct ArgParen(pub arg_paren_tag, pub Box<ArgNode>, pub StartEnd);

// See: https://dev.to/penelope_zone/understanding-ruby-s-block-proc-parsing-4a89
#[derive(RipperDeserialize, Debug, Clone)]
pub enum ToProcExpr {
#[allow(unused)]
NotPresent(bool),
Present(Box<Expression>),
}
Expand All @@ -1436,12 +1442,13 @@ pub struct ArgsAddBlock(
pub args_add_block_tag,
pub ArgsAddBlockInner,
pub Option<ToProcExpr>,
pub StartEnd,
#[allow(unused)] pub StartEnd,
);

#[derive(RipperDeserialize, Debug, Clone)]
pub enum AABParen {
Paren((paren_tag, Box<Expression>)),
#[allow(unused)]
EmptyParen((paren_tag, bool)),
Expression(Box<Expression>),
}
Expand Down Expand Up @@ -1945,6 +1952,7 @@ impl DotTypeOrOp {

def_tag!(period_tag, "@period");
#[derive(Deserialize, Debug, Clone)]
#[allow(unused)]
pub struct Period(pub period_tag, pub String, pub LineCol);

def_tag!(equals_tag, "==");
Expand Down Expand Up @@ -2103,7 +2111,7 @@ def_tag!(defs_tag, "defs");
pub struct Defs(
pub defs_tag,
pub Singleton,
pub DotOrColon,
#[allow(unused)] pub DotOrColon,
pub IdentOrOpOrKeywordOrConst,
pub ParenOrParams,
pub Box<DefBodyStmt>,
Expand All @@ -2112,7 +2120,9 @@ pub struct Defs(

#[derive(RipperDeserialize, Debug, Clone)]
pub enum IdentOrKw {
#[allow(unused)]
Ident(Ident),
#[allow(unused)]
Kw(Kw),
}

Expand All @@ -2126,7 +2136,9 @@ pub enum Singleton {
// can only occur in defs, Op is always `::`
#[derive(RipperDeserialize, Debug, Clone)]
pub enum DotOrColon {
#[allow(unused)]
Period(Period),
#[allow(unused)]
Op(Operator),
}

Expand Down Expand Up @@ -2292,7 +2304,9 @@ impl Block {
// variables are present
#[derive(RipperDeserialize, Debug, Clone)]
pub enum BlockLocalVariables {
#[allow(unused)]
EmptyBecauseParamsWerePresent(bool),
#[allow(unused)]
NilBecauseParamsWereNotPresent(Option<()>),
Present(Vec<Ident>),
}
Expand Down
Loading