From 18173fbbf6771ab3bf31997331cbfbf6e028620c Mon Sep 17 00:00:00 2001 From: CensoredUsername Date: Fri, 27 Sep 2024 02:02:12 +0200 Subject: [PATCH] Remove unused spans that started producing unused attribute warnings. --- plugin/src/arch/aarch64/ast.rs | 12 ++---------- plugin/src/arch/aarch64/matching.rs | 12 ++++++------ plugin/src/arch/aarch64/parser.rs | 7 ++----- plugin/src/arch/x64/ast.rs | 4 ---- plugin/src/arch/x64/compiler.rs | 10 +++++----- plugin/src/arch/x64/parser.rs | 3 +-- 6 files changed, 16 insertions(+), 32 deletions(-) diff --git a/plugin/src/arch/aarch64/ast.rs b/plugin/src/arch/aarch64/ast.rs index bc17e323f..c80e65a41 100644 --- a/plugin/src/arch/aarch64/ast.rs +++ b/plugin/src/arch/aarch64/ast.rs @@ -281,14 +281,12 @@ impl ModifyExpr { #[derive(Debug)] pub enum RefItem { Direct { - span: Span, reg: Register }, Immediate { value: syn::Expr }, Modifier { - span: Span, modifier: ModifyExpr } } @@ -341,9 +339,7 @@ pub enum RawArg { modifier: ModifyExpr }, // a dot - Dot { - span: Span - }, + Dot {}, // an ident, not intended to be parsed as an expression Lit { ident: syn::Ident @@ -391,12 +387,9 @@ pub enum CleanArg { value: syn::Expr, }, Modifier { - span: Span, modifier: ModifyExpr }, - Dot { - span: Span - }, + Dot {}, Lit { ident: syn::Ident } @@ -413,7 +406,6 @@ pub enum FlatArg { value: syn::Expr, }, Modifier { - span: Span, modifier: Modifier, }, JumpTarget { diff --git a/plugin/src/arch/aarch64/matching.rs b/plugin/src/arch/aarch64/matching.rs index 34bb8c8bc..429c43b96 100644 --- a/plugin/src/arch/aarch64/matching.rs +++ b/plugin/src/arch/aarch64/matching.rs @@ -68,11 +68,11 @@ fn sanitize_args(args: Vec) -> Result, Option> { return Err(None); } - res.push(CleanArg::Modifier { span, modifier }); + res.push(CleanArg::Modifier { modifier }); }, // dot: passthrough - RawArg::Dot { span } => { - res.push(CleanArg::Dot { span } ); + RawArg::Dot {} => { + res.push(CleanArg::Dot {} ); }, // lit: passthrough RawArg::Lit { ident } => { @@ -592,7 +592,7 @@ fn flatten_args(args: Vec, data: &Opdata, ctx: &mut MatchData) { RefKind::Indexed(index, modifier) => { new_args.push(FlatArg::Direct { span, reg: index.kind_owned() } ); if let Some(modifier) = modifier { - new_args.push(FlatArg::Modifier { span, modifier: modifier.op } ); + new_args.push(FlatArg::Modifier { modifier: modifier.op } ); if let Some(expr) = modifier.expr { new_args.push(FlatArg::Immediate { value: expr } ); } @@ -625,9 +625,9 @@ fn flatten_args(args: Vec, data: &Opdata, ctx: &mut MatchData) { CleanArg::Immediate { value, .. } => { new_args.push(FlatArg::Immediate { value } ); }, - CleanArg::Modifier { span, modifier } => { + CleanArg::Modifier { modifier } => { if arg_count >= 2 { - new_args.push(FlatArg::Modifier { span, modifier: modifier.op } ); + new_args.push(FlatArg::Modifier { modifier: modifier.op } ); } if let Some(expr) = modifier.expr { new_args.push(FlatArg::Immediate { value: expr }); diff --git a/plugin/src/arch/aarch64/parser.rs b/plugin/src/arch/aarch64/parser.rs index 90e0caaa9..5a7c5f45a 100644 --- a/plugin/src/arch/aarch64/parser.rs +++ b/plugin/src/arch/aarch64/parser.rs @@ -22,11 +22,10 @@ pub(super) fn parse_instruction(ctx: &mut Context, input: parse::ParseStream) -> // parse any dot args while input.peek(Token![.]) { - let span = input.cursor().span(); let _: Token![.] = input.parse()?; let arg: syn::Ident = input.parse()?; - args.push(RawArg::Dot { span } ); + args.push(RawArg::Dot {} ); args.push(RawArg::Lit { ident: arg }); } @@ -206,7 +205,6 @@ fn parse_refitem(ctx: &mut Context, input: parse::ParseStream) -> parse::Result< // modifier if let Some(modifier) = input.parse_opt()? { return Ok(RefItem::Modifier { - span: _start, modifier }); } @@ -223,8 +221,7 @@ fn parse_refitem(ctx: &mut Context, input: parse::ParseStream) -> parse::Result< // register if let Some(reg) = parse_reg(ctx, input)? { return Ok(RefItem::Direct { - reg, - span: _start + reg }) } diff --git a/plugin/src/arch/x64/ast.rs b/plugin/src/arch/x64/ast.rs index 954c9816d..c6e30fe27 100644 --- a/plugin/src/arch/x64/ast.rs +++ b/plugin/src/arch/x64/ast.rs @@ -273,7 +273,6 @@ pub enum RawArg { }, // direct register reference, Direct { - span: Span, reg: Register }, // a jump offset, i.e. ->foo @@ -309,7 +308,6 @@ pub enum CleanArg { }, // direct register reference, Direct { - span: Span, reg: Register }, // a jump offset, i.e. ->foo @@ -334,7 +332,6 @@ pub enum SizedArg { // memory reference. size info is lost here as // it is never actually encoded Indirect { - span: Span, disp_size: Option, base: Option, index: Option<(Register, isize, Option)>, @@ -342,7 +339,6 @@ pub enum SizedArg { }, // direct register reference, Direct { - span: Span, reg: Register }, // a jump offset, i.e. ->foo diff --git a/plugin/src/arch/x64/compiler.rs b/plugin/src/arch/x64/compiler.rs index 583cab8d9..4fa7b9934 100644 --- a/plugin/src/arch/x64/compiler.rs +++ b/plugin/src/arch/x64/compiler.rs @@ -522,7 +522,7 @@ pub(super) fn compile_instruction(ctx: &mut Context, instruction: Instruction, a // Folds RawArgs into CleanArgs by analyzing the different raw memoryref variants fn clean_memoryref(arg: RawArg) -> Result> { Ok(match arg { - RawArg::Direct {span, reg} => CleanArg::Direct {span, reg}, + RawArg::Direct {reg} => CleanArg::Direct {reg}, RawArg::JumpTarget {jump, size} => CleanArg::JumpTarget {jump, size}, RawArg::IndirectJumpTarget {jump, size} => { if let JumpKind::Bare(_) = jump.kind { @@ -1257,16 +1257,16 @@ fn size_operands(fmt: &Opdata, args: Vec) -> Result<(Option, Vec }; new_args.push(match arg { - CleanArg::Direct {span, reg} => - SizedArg::Direct {span, reg}, + CleanArg::Direct {reg} => + SizedArg::Direct {reg}, CleanArg::JumpTarget {jump, ..} => SizedArg::JumpTarget {jump, size}, CleanArg::IndirectJumpTarget {jump, ..} => SizedArg::IndirectJumpTarget {jump}, CleanArg::Immediate {value, ..} => SizedArg::Immediate {value, size}, - CleanArg::Indirect {span, disp_size, base, index, disp, ..} => - SizedArg::Indirect {span, disp_size, base, index, disp}, + CleanArg::Indirect {disp_size, base, index, disp, ..} => + SizedArg::Indirect {disp_size, base, index, disp}, }); } diff --git a/plugin/src/arch/x64/parser.rs b/plugin/src/arch/x64/parser.rs index 5fb31af6c..c3e3e4311 100644 --- a/plugin/src/arch/x64/parser.rs +++ b/plugin/src/arch/x64/parser.rs @@ -214,8 +214,7 @@ fn parse_arg(ctx: &mut Context, input: parse::ParseStream) -> parse::Result