Skip to content

Commit 82cb95c

Browse files
committed
Resolve unused field of ReplaceSelf syntax tree visitor
warning: field `0` is never read --> src/receiver.rs:81:24 | 81 | pub struct ReplaceSelf(pub Span); | ----------- ^^^^^^^^ | | | field in this struct | = note: `#[warn(dead_code)]` on by default help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 81 | pub struct ReplaceSelf(()); | ~~
1 parent cd8286b commit 82cb95c

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/expand.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ fn transform_sig(
335335
// ___ret
336336
// })
337337
fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) {
338-
let mut self_span = None;
338+
let mut replace_self = false;
339339
let decls = sig
340340
.inputs
341341
.iter()
@@ -346,8 +346,8 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) {
346346
mutability,
347347
..
348348
}) => {
349+
replace_self = true;
349350
let ident = Ident::new("__self", self_token.span);
350-
self_span = Some(self_token.span);
351351
quote!(let #mutability #ident = #self_token;)
352352
}
353353
FnArg::Typed(arg) => {
@@ -389,9 +389,8 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) {
389389
})
390390
.collect::<Vec<_>>();
391391

392-
if let Some(span) = self_span {
393-
let mut replace_self = ReplaceSelf(span);
394-
replace_self.visit_block_mut(block);
392+
if replace_self {
393+
ReplaceSelf.visit_block_mut(block);
395394
}
396395

397396
let stmts = &block.stmts;

src/receiver.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use proc_macro2::{Group, Span, TokenStream, TokenTree};
1+
use proc_macro2::{Group, TokenStream, TokenTree};
22
use syn::visit_mut::{self, VisitMut};
33
use syn::{
44
Block, ExprPath, Ident, Item, Macro, Pat, PatIdent, Path, Receiver, Signature, Token, TypePath,
@@ -78,7 +78,7 @@ impl VisitMut for HasSelf {
7878
}
7979
}
8080

81-
pub struct ReplaceSelf(pub Span);
81+
pub struct ReplaceSelf;
8282

8383
impl ReplaceSelf {
8484
#[cfg_attr(not(self_span_hack), allow(clippy::unused_self))]

0 commit comments

Comments
 (0)