dtolnay / no-panic

Attribute macro to require that the compiler prove a function can't ever panic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

issue with `mut self: std::pin::Pin<&mut Self>` parameter

brodybits opened this issue · comments

Here is a reproduction now demonstrated in PR #34:

mod test_self_with_std_pin {
    pub struct S {
        data: usize,
    }

    impl S {
        #[no_panic]
        fn f1(mut self: std::pin::Pin<&mut Self>) { }

        fn f2(mut self: std::pin::Pin<&mut Self>) { }
    }

    fn main() { }
}

gives me the following output if I would paste it into the test suite:

error: `mut` must be followed by a named binding
 --> /var/folders/47/6fqcq_l90jb7ffb_khxrjtbr0000gp/T/.tmpT9x81h/test_self_with_pin.rs:3:23
  |
3 |     #[no_panic] fn f1(mut self : std :: pin :: Pin < & mut Self >) {} fn
  |                       ^^^^^^^^ help: remove the `mut` prefix: `self`
  |
  = note: `mut` may be followed by `variable` and `variable @ pattern`

error[E0424]: expected unit struct, unit variant or constant, found module `self`
 --> /var/folders/47/6fqcq_l90jb7ffb_khxrjtbr0000gp/T/.tmpT9x81h/test_self_with_pin.rs:3:27
  |
3 |     #[no_panic] fn f1(mut self : std :: pin :: Pin < & mut Self >) {} fn
  |                    --     ^^^^ `self` value is a keyword and may not be bound to variables or shadowed
  |                    |
  |                    this function doesn't have a `self` parameter
  |
help: add a `self` receiver parameter to make the associated `fn` a method
  |
3 |     &self, #[no_panic] fn f1(mut self : std :: pin :: Pin < & mut Self >) {} fn
  |     ++++++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0424`.

Note that this only happens with f1 where I used #[no_panic].

Please bear with my lack of proper terminology as I am still quite new with Rust.

I will now raise a failing PR with the reproduction.

Fixed in 0.1.18.