Type inference in anyhow::Context wrapper

Hi,

I use anyhow for errors in a codebase where errors in some parts are frequent but have had to disable backtracing/capture of stacktrace (they have horrible performance on windows) but still need to propagate the context of en error upwards.

My attempt to do this is to create a extension trait extending anyhow::Result with a method .at() togeather with a macro at!() (allows me to use the line! and file! macros) with the intended use as:

...
inner_function().at(at!("error while eating icecream"))?;
....

However, I'm struggling to get the type inference to work - does anyone have any idea why the floowing does not work / what I can do about it?

Thanks

Remove the unused generic parameter E from your trait.

trait MyContext<T> {
    fn at<C, F>(self, f: F) -> Result<T, Error>
    where
        C: std::fmt::Display + Send + Sync + 'static,
        F: FnOnce() -> C;
}

impl<T> MyContext<T> for Result<T, anyhow::Error> {
    fn at<C, F>(self, f: F) -> Result<T, anyhow::Error>
    where
        C: std::fmt::Display + Send + Sync + 'static,
        F: FnOnce() -> C,
    {
        self.context(f())
    }
}

The error is because it can't figure out what E should be.

Thanks!