Skip to content

unused_parens warning generated #118

Closed
@georgemp

Description

@georgemp

Hi,

I'm running into an issue wherein I get unused_parens warnings. A reproducible version on the rust playground can be found here.

The code is

use tokio;
use async_trait::async_trait;

#[async_trait]
trait Resetable {
    async fn reset(&mut self);
}

struct Modifier {
    action: fn(String) -> String,
}

impl Modifier {
    fn new(action: fn(String) -> String) -> Self {
        Modifier {
            action
        }
    }
}

#[async_trait]
impl Resetable for Modifier {
    async fn reset(&mut self) {
        //println!("resetting action");
        self.action = |str| str;
    }
}

#[tokio::main]
async fn main() {
    let mut modifier = Modifier::new(|str| {
        format!("{}{}", str, str)
    });
    
    let orig = "Frank".to_owned();
    let modified = (modifier.action)(orig);
    println!("{}", modified);
    
    let _ = modifier.reset().await;
    let orig = "Bob".to_owned();
    let modified = (modifier.action)(orig);
    println!("{}", modified);
}

If i uncomment the println! on line 24 (on the playground), the warning goes away. Do let me know if you would need any more details with this (or, would like me to try something else). Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions