dtolnay/no-panic

Doesn't work with `impl Trait` return type

Wolvereness opened this issue · 0 comments

A minimal use-case of what I'd need:

use std::io;

struct Foo;

impl Foo {
    #[no_panic::no_panic]
    fn get(&mut self) -> io::Result<impl io::Write> {
        Ok(Vec::new())
    }
}

Error:

error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
 --> src\lib.rs:7:37
  |
7 |     fn get(&mut self) -> io::Result<impl io::Write> {
  |                                     ^^^^^^^^^^^^^^

A minimal reproduction case:

#[no_panic::no_panic]
fn get() -> impl std::io::Write {
    Vec::new()
}

Error:

error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
 --> src\lib.rs:2:17
  |
2 |     fn get() -> impl std::io::Write {
  |                 ^^^^^^^^^^^^^^^^^^^