Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo fmt breaks Sequoia-PGP by introducing syntax errors #4996

Closed
larswirzenius opened this issue Sep 20, 2021 · 6 comments
Closed

cargo fmt breaks Sequoia-PGP by introducing syntax errors #4996

larswirzenius opened this issue Sep 20, 2021 · 6 comments

Comments

@larswirzenius
Copy link

larswirzenius commented Sep 20, 2021

When I try to use cargo fmt on the Sequoia-PGP source tree, so that cargo check fails.

The source code: https://gitlab.com/sequoia-pgp/sequoia
Commit: 22071cfb1324ef87e2ad2ee8c38c3b5e1a1375d4

Sequoia normally builds with 1.48.0, and cargo check -q reports nothinig. If I use the current version of the toolchain there is a warning due to the code base not being entirely clean, but cargo check -q works otherwise. After cargo fmt however there are syntax errors.

Version of rustfmt that breaks the code: rustfmt 1.4.37-stable (c8dfcfe 2021-09-06)

Commands and output Commands:
$ git reset --hard
HEAD is now at 22071cfb openpgp: Don't assert that the NIST curves are supported.
$ git clean -fdxq
$ cargo clean
$ cargo check -q
$ cat rust-toolchain 
1.48.0
$ rm rust-toolchain 
$ cargo clean
$ cargo check -q
warning: unused borrow that must be used
   --> ffi-macros/src/lib.rs:408:5
    |
408 | /     &mut c_type_name_padded[..::std::cmp::min(C_TYPE_NAME_LEN,
409 | |                                               c_type_name.as_bytes().len())]
410 | |         .copy_from_slice(c_type_name.as_bytes());
    | |________________________________________________^
    |
    = note: `#[warn(unused_must_use)]` on by default

$ rustfmt --version
rustfmt 1.4.37-stable (c8dfcfe 2021-09-06)
$ cargo fmt
$ cargo check -q
warning: unused borrow that must be used
   --> ffi-macros/src/lib.rs:442:5
    |
442 | /     &mut c_type_name_padded[..::std::cmp::min(C_TYPE_NAME_LEN, c_type_name.as_bytes().len())]
443 | |         .copy_from_slice(c_type_name.as_bytes());
    | |________________________________________________^
    |
    = note: `#[warn(unused_must_use)]` on by default

error: unexpected end of macro invocation
   --> openpgp/src/packet/key/conversions.rs:410:24
    |
250 | macro_rules! create_conversions {
    | ------------------------------- when calling this macro
...
410 | create_conversions!(Key);
    |                        ^ missing tokens in macro arguments

error: unexpected end of macro invocation
   --> openpgp/src/packet/key/conversions.rs:411:25
    |
250 | macro_rules! create_conversions {
    | ------------------------------- when calling this macro
...
411 | create_conversions!(Key4);
    |                         ^ missing tokens in macro arguments

error: unexpected end of macro invocation
   --> openpgp/src/packet/key/conversions.rs:412:30
    |
250 | macro_rules! create_conversions {
    | ------------------------------- when calling this macro
...
412 | create_conversions!(KeyBundle);
    |                              ^ missing tokens in macro arguments

error[E0599]: no method named `parts_into_secret` found for enum `packet::Key<PublicParts, PrimaryRole>` in the current scope
    --> openpgp/src/cert.rs:1349:45
     |
1349 |                         Packet::SecretKey(k.parts_into_secret().unwrap())
     |                                             ^^^^^^^^^^^^^^^^^ method not found in `packet::Key<PublicParts, PrimaryRole>`
     | 
    ::: openpgp/src/packet/mod.rs:1475:1
     |
1475 | pub enum Key<P: key::KeyParts, R: key::KeyRole> {
     | ----------------------------------------------- method `parts_into_secret` not found for this

error[E0599]: no method named `parts_into_secret` found for enum `packet::Key<PublicParts, SubordinateRole>` in the current scope
    --> openpgp/src/cert.rs:1356:48
     |
1356 |                         Packet::SecretSubkey(k.parts_into_secret().unwrap())
     |                                                ^^^^^^^^^^^^^^^^^ method not found in `packet::Key<PublicParts, SubordinateRole>`
     | 
    ::: openpgp/src/packet/mod.rs:1475:1
     |
1475 | pub enum Key<P: key::KeyParts, R: key::KeyRole> {
     | ----------------------------------------------- method `parts_into_secret` not found for this

error[E0599]: no method named `parts_as_public` found for reference `&packet::Key<P, R>` in the current scope
   --> openpgp/src/crypto/backend/nettle/asymmetric.rs:263:55
    |
263 |             ECDH => crate::crypto::ecdh::encrypt(self.parts_as_public(), data),
    |                                                       ^^^^^^^^^^^^^^^ method not found in `&packet::Key<P, R>`

error[E0599]: no method named `role_into_unspecified` found for struct `packet::key::Key4` in the current scope
    --> openpgp/src/packet/mod.rs:1767:26
     |
1767 |           KeyPair::new(key.role_into_unspecified().into(), secret)
     |                            ^^^^^^^^^^^^^^^^^^^^^ method not found in `packet::key::Key4<PublicParts, R>`
     | 
    ::: openpgp/src/packet/key.rs:768:1
     |
768  | / pub struct Key4<P, R>
769  | | where
770  | |     P: KeyParts,
771  | |     R: KeyRole,
...    |
785  | |     r: std::marker::PhantomData<R>,
786  | | }
     | |_- method `role_into_unspecified` not found for this

error[E0277]: the trait bound `packet::Key<PublicParts, R>: From<packet::Key<UnspecifiedParts, R>>` is not satisfied
   --> openpgp/src/packet/key.rs:460:12
    |
460 |         Ok(key.into())
    |            ^^^^^^^^^^ the trait `From<packet::Key<UnspecifiedParts, R>>` is not implemented for `packet::Key<PublicParts, R>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<packet::Key<PublicParts, R>>` for `packet::Key<UnspecifiedParts, R>`

error[E0277]: the trait bound `&packet::Key<PublicParts, R>: From<&packet::Key<UnspecifiedParts, R>>` is not satisfied
   --> openpgp/src/packet/key.rs:464:12
    |
464 |         Ok(key.into())
    |            ^^^^^^^^^^ the trait `From<&packet::Key<UnspecifiedParts, R>>` is not implemented for `&packet::Key<PublicParts, R>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<PublicParts, R>>` for `&packet::Key<UnspecifiedParts, R>`

error[E0277]: the trait bound `bundle::ComponentBundle<packet::Key<PublicParts, R>>: From<bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` is not satisfied
   --> openpgp/src/packet/key.rs:470:12
    |
470 |         Ok(bundle.into())
    |            ^^^^^^^^^^^^^ the trait `From<bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` is not implemented for `bundle::ComponentBundle<packet::Key<PublicParts, R>>`
    |
    = note: required because of the requirements on the impl of `Into<bundle::ComponentBundle<packet::Key<PublicParts, R>>>` for `bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>`

error[E0277]: the trait bound `&bundle::ComponentBundle<packet::Key<PublicParts, R>>: From<&bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` is not satisfied
   --> openpgp/src/packet/key.rs:476:12
    |
476 |         Ok(bundle.into())
    |            ^^^^^^^^^^^^^ the trait `From<&bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` is not implemented for `&bundle::ComponentBundle<packet::Key<PublicParts, R>>`
    |
    = note: required because of the requirements on the impl of `Into<&bundle::ComponentBundle<packet::Key<PublicParts, R>>>` for `&bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>`

error[E0271]: type mismatch resolving `<packet::Key<SecretParts, R> as TryFrom<packet::Key<UnspecifiedParts, R>>>::Error == anyhow::Error`
   --> openpgp/src/packet/key.rs:516:13
    |
516 |         key.try_into()
    |             ^^^^^^^^ expected enum `Infallible`, found struct `anyhow::Error`

error[E0277]: the trait bound `packet::Key<SecretParts, R>: From<packet::Key<UnspecifiedParts, R>>` is not satisfied
   --> openpgp/src/packet/key.rs:516:13
    |
516 |         key.try_into()
    |             ^^^^^^^^ the trait `From<packet::Key<UnspecifiedParts, R>>` is not implemented for `packet::Key<SecretParts, R>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<packet::Key<SecretParts, R>>` for `packet::Key<UnspecifiedParts, R>`
    = note: required because of the requirements on the impl of `TryFrom<packet::Key<UnspecifiedParts, R>>` for `packet::Key<SecretParts, R>`
    = note: required because of the requirements on the impl of `TryInto<packet::Key<SecretParts, R>>` for `packet::Key<UnspecifiedParts, R>`

error[E0271]: type mismatch resolving `<&packet::Key<SecretParts, R> as TryFrom<&packet::Key<UnspecifiedParts, R>>>::Error == anyhow::Error`
   --> openpgp/src/packet/key.rs:520:13
    |
520 |         key.try_into()
    |             ^^^^^^^^ expected enum `Infallible`, found struct `anyhow::Error`

error[E0277]: the trait bound `&packet::Key<SecretParts, R>: From<&packet::Key<UnspecifiedParts, R>>` is not satisfied
   --> openpgp/src/packet/key.rs:520:13
    |
520 |         key.try_into()
    |             ^^^^^^^^ the trait `From<&packet::Key<UnspecifiedParts, R>>` is not implemented for `&packet::Key<SecretParts, R>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<SecretParts, R>>` for `&packet::Key<UnspecifiedParts, R>`
    = note: required because of the requirements on the impl of `TryFrom<&packet::Key<UnspecifiedParts, R>>` for `&packet::Key<SecretParts, R>`
    = note: required because of the requirements on the impl of `TryInto<&packet::Key<SecretParts, R>>` for `&packet::Key<UnspecifiedParts, R>`

error[E0271]: type mismatch resolving `<bundle::ComponentBundle<packet::Key<SecretParts, R>> as TryFrom<bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>>::Error == anyhow::Error`
   --> openpgp/src/packet/key.rs:526:16
    |
526 |         bundle.try_into()
    |                ^^^^^^^^ expected enum `Infallible`, found struct `anyhow::Error`

error[E0277]: the trait bound `bundle::ComponentBundle<packet::Key<SecretParts, R>>: From<bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` is not satisfied
   --> openpgp/src/packet/key.rs:526:16
    |
526 |         bundle.try_into()
    |                ^^^^^^^^ the trait `From<bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` is not implemented for `bundle::ComponentBundle<packet::Key<SecretParts, R>>`
    |
    = note: required because of the requirements on the impl of `Into<bundle::ComponentBundle<packet::Key<SecretParts, R>>>` for `bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>`
    = note: required because of the requirements on the impl of `TryFrom<bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` for `bundle::ComponentBundle<packet::Key<SecretParts, R>>`
    = note: required because of the requirements on the impl of `TryInto<bundle::ComponentBundle<packet::Key<SecretParts, R>>>` for `bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>`

error[E0271]: type mismatch resolving `<&bundle::ComponentBundle<packet::Key<SecretParts, R>> as TryFrom<&bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>>::Error == anyhow::Error`
   --> openpgp/src/packet/key.rs:532:16
    |
532 |         bundle.try_into()
    |                ^^^^^^^^ expected enum `Infallible`, found struct `anyhow::Error`

error[E0277]: the trait bound `&bundle::ComponentBundle<packet::Key<SecretParts, R>>: From<&bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` is not satisfied
   --> openpgp/src/packet/key.rs:532:16
    |
532 |         bundle.try_into()
    |                ^^^^^^^^ the trait `From<&bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` is not implemented for `&bundle::ComponentBundle<packet::Key<SecretParts, R>>`
    |
    = note: required because of the requirements on the impl of `Into<&bundle::ComponentBundle<packet::Key<SecretParts, R>>>` for `&bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>`
    = note: required because of the requirements on the impl of `TryFrom<&bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>>` for `&bundle::ComponentBundle<packet::Key<SecretParts, R>>`
    = note: required because of the requirements on the impl of `TryInto<&bundle::ComponentBundle<packet::Key<SecretParts, R>>>` for `&bundle::ComponentBundle<packet::Key<UnspecifiedParts, R>>`

error[E0277]: the trait bound `packet::Key<P, PrimaryRole>: From<packet::Key<P, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/packet/key.rs:628:13
    |
628 |         key.into()
    |             ^^^^ the trait `From<packet::Key<P, UnspecifiedRole>>` is not implemented for `packet::Key<P, PrimaryRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<packet::Key<P, PrimaryRole>>` for `packet::Key<P, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<P, PrimaryRole>: From<&packet::Key<P, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/packet/key.rs:632:13
    |
632 |         key.into()
    |             ^^^^ the trait `From<&packet::Key<P, UnspecifiedRole>>` is not implemented for `&packet::Key<P, PrimaryRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<P, PrimaryRole>>` for `&packet::Key<P, UnspecifiedRole>`

error[E0277]: the trait bound `bundle::ComponentBundle<packet::Key<P, PrimaryRole>>: From<bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>>` is not satisfied
   --> openpgp/src/packet/key.rs:636:16
    |
636 |         bundle.into()
    |                ^^^^ the trait `From<bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>>` is not implemented for `bundle::ComponentBundle<packet::Key<P, PrimaryRole>>`
    |
    = note: required because of the requirements on the impl of `Into<bundle::ComponentBundle<packet::Key<P, PrimaryRole>>>` for `bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>`

error[E0277]: the trait bound `&bundle::ComponentBundle<packet::Key<P, PrimaryRole>>: From<&bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>>` is not satisfied
   --> openpgp/src/packet/key.rs:642:16
    |
642 |         bundle.into()
    |                ^^^^ the trait `From<&bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>>` is not implemented for `&bundle::ComponentBundle<packet::Key<P, PrimaryRole>>`
    |
    = note: required because of the requirements on the impl of `Into<&bundle::ComponentBundle<packet::Key<P, PrimaryRole>>>` for `&bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>`

error[E0277]: the trait bound `packet::Key<P, SubordinateRole>: From<packet::Key<P, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/packet/key.rs:658:13
    |
658 |         key.into()
    |             ^^^^ the trait `From<packet::Key<P, UnspecifiedRole>>` is not implemented for `packet::Key<P, SubordinateRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<packet::Key<P, SubordinateRole>>` for `packet::Key<P, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<P, SubordinateRole>: From<&packet::Key<P, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/packet/key.rs:662:13
    |
662 |         key.into()
    |             ^^^^ the trait `From<&packet::Key<P, UnspecifiedRole>>` is not implemented for `&packet::Key<P, SubordinateRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<P, SubordinateRole>>` for `&packet::Key<P, UnspecifiedRole>`

error[E0277]: the trait bound `bundle::ComponentBundle<packet::Key<P, SubordinateRole>>: From<bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>>` is not satisfied
   --> openpgp/src/packet/key.rs:666:16
    |
666 |         bundle.into()
    |                ^^^^ the trait `From<bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>>` is not implemented for `bundle::ComponentBundle<packet::Key<P, SubordinateRole>>`
    |
    = note: required because of the requirements on the impl of `Into<bundle::ComponentBundle<packet::Key<P, SubordinateRole>>>` for `bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>`

error[E0277]: the trait bound `&bundle::ComponentBundle<packet::Key<P, SubordinateRole>>: From<&bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>>` is not satisfied
   --> openpgp/src/packet/key.rs:672:16
    |
672 |         bundle.into()
    |                ^^^^ the trait `From<&bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>>` is not implemented for `&bundle::ComponentBundle<packet::Key<P, SubordinateRole>>`
    |
    = note: required because of the requirements on the impl of `Into<&bundle::ComponentBundle<packet::Key<P, SubordinateRole>>>` for `&bundle::ComponentBundle<packet::Key<P, UnspecifiedRole>>`

error[E0599]: no method named `parts_into_public` found for struct `packet::key::Key4` in the current scope
    --> openpgp/src/packet/key.rs:1180:23
     |
768  | / pub struct Key4<P, R>
769  | | where
770  | |     P: KeyParts,
771  | |     R: KeyRole,
...    |
785  | |     r: std::marker::PhantomData<R>,
786  | | }
     | |_- method `parts_into_public` not found for this
...
1180 |                   (self.parts_into_public(), old)
     |                         ^^^^^^^^^^^^^^^^^ method not found in `packet::key::Key4<PublicParts, R>`
...
1195 |   impl_common_secret_functions!(PublicParts);
     |   ------------------------------------------- in this macro invocation
     |
     = note: this error originates in the macro `impl_common_secret_functions` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `parts_into_public` found for struct `packet::key::Key4` in the current scope
    --> openpgp/src/packet/key.rs:1180:23
     |
768  | / pub struct Key4<P, R>
769  | | where
770  | |     P: KeyParts,
771  | |     R: KeyRole,
...    |
785  | |     r: std::marker::PhantomData<R>,
786  | | }
     | |_- method `parts_into_public` not found for this
...
1180 |                   (self.parts_into_public(), old)
     |                         ^^^^^^^^^^^^^^^^^ method not found in `packet::key::Key4<UnspecifiedParts, R>`
...
1196 |   impl_common_secret_functions!(UnspecifiedParts);
     |   ------------------------------------------------ in this macro invocation
     |
     = note: this error originates in the macro `impl_common_secret_functions` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `parts_into_secret` found for struct `packet::key::Key4` in the current scope
    --> openpgp/src/packet/key.rs:1190:23
     |
768  | / pub struct Key4<P, R>
769  | | where
770  | |     P: KeyParts,
771  | |     R: KeyRole,
...    |
785  | |     r: std::marker::PhantomData<R>,
786  | | }
     | |_- method `parts_into_secret` not found for this
...
1190 |                   (self.parts_into_secret().expect("secret just set"), old)
     |                         ^^^^^^^^^^^^^^^^^ method not found in `packet::key::Key4<PublicParts, R>`
...
1195 |   impl_common_secret_functions!(PublicParts);
     |   ------------------------------------------- in this macro invocation
     |
     = note: this error originates in the macro `impl_common_secret_functions` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `parts_into_secret` found for struct `packet::key::Key4` in the current scope
    --> openpgp/src/packet/key.rs:1190:23
     |
768  | / pub struct Key4<P, R>
769  | | where
770  | |     P: KeyParts,
771  | |     R: KeyRole,
...    |
785  | |     r: std::marker::PhantomData<R>,
786  | | }
     | |_- method `parts_into_secret` not found for this
...
1190 |                   (self.parts_into_secret().expect("secret just set"), old)
     |                         ^^^^^^^^^^^^^^^^^ method not found in `packet::key::Key4<UnspecifiedParts, R>`
...
1196 |   impl_common_secret_functions!(UnspecifiedParts);
     |   ------------------------------------------------ in this macro invocation
     |
     = note: this error originates in the macro `impl_common_secret_functions` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `parts_into_public` found for struct `packet::key::Key4` in the current scope
    --> openpgp/src/packet/key.rs:1217:18
     |
768  | / pub struct Key4<P, R>
769  | | where
770  | |     P: KeyParts,
771  | |     R: KeyRole,
...    |
785  | |     r: std::marker::PhantomData<R>,
786  | | }
     | |_- method `parts_into_public` not found for this
...
1217 |               self.parts_into_public(),
     |                    ^^^^^^^^^^^^^^^^^ method not found in `packet::key::Key4<SecretParts, R>`

error[E0599]: no method named `parts_into_secret` found for struct `packet::key::Key4` in the current scope
    --> openpgp/src/packet/key.rs:1231:18
     |
768  | / pub struct Key4<P, R>
769  | | where
770  | |     P: KeyParts,
771  | |     R: KeyRole,
...    |
785  | |     r: std::marker::PhantomData<R>,
786  | | }
     | |_- method `parts_into_secret` not found for this
...
1231 |               self.parts_into_secret().expect("secret just set"),
     |                    ^^^^^^^^^^^^^^^^^ method not found in `packet::key::Key4<SecretParts, R>`

error[E0599]: no method named `role_as_primary` found for reference `&packet::Key<PublicParts, UnspecifiedRole>` in the current scope
   --> openpgp/src/packet/signature.rs:814:48
    |
814 |             .unwrap_or_else(|| signer.public().role_as_primary());
    |                                                ^^^^^^^^^^^^^^^ method not found in `&packet::Key<PublicParts, UnspecifiedRole>`

error[E0599]: no method named `role_as_primary` found for reference `&packet::Key<PublicParts, UnspecifiedRole>` in the current scope
   --> openpgp/src/packet/signature.rs:962:48
    |
962 |             .unwrap_or_else(|| signer.public().role_as_primary());
    |                                                ^^^^^^^^^^^^^^^ method not found in `&packet::Key<PublicParts, UnspecifiedRole>`

error[E0599]: no method named `role_as_primary` found for reference `&packet::Key<PublicParts, UnspecifiedRole>` in the current scope
    --> openpgp/src/packet/signature.rs:1092:48
     |
1092 |             .unwrap_or_else(|| signer.public().role_as_primary());
     |                                                ^^^^^^^^^^^^^^^ method not found in `&packet::Key<PublicParts, UnspecifiedRole>`

error[E0599]: no method named `role_as_primary` found for reference `&packet::Key<PublicParts, UnspecifiedRole>` in the current scope
    --> openpgp/src/packet/signature.rs:1386:48
     |
1386 |             .unwrap_or_else(|| signer.public().role_as_primary());
     |                                                ^^^^^^^^^^^^^^^ method not found in `&packet::Key<PublicParts, UnspecifiedRole>`

error[E0277]: the trait bound `packet::Key<UnspecifiedParts, UnspecifiedRole>: From<packet::Key<PublicParts, PrimaryRole>>` is not satisfied
    --> openpgp/src/parse.rs:2413:70
     |
2413 |             (Packet::PublicKey(o), PacketParserResult::EOF(_)) => Ok(o.into()),
     |                                                                      ^^^^^^^^ the trait `From<packet::Key<PublicParts, PrimaryRole>>` is not implemented for `packet::Key<UnspecifiedParts, UnspecifiedRole>`
     |
     = help: the following implementations were found:
               <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
               <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
     = note: required because of the requirements on the impl of `Into<packet::Key<UnspecifiedParts, UnspecifiedRole>>` for `packet::Key<PublicParts, PrimaryRole>`

error[E0277]: the trait bound `packet::Key<UnspecifiedParts, UnspecifiedRole>: From<packet::Key<PublicParts, SubordinateRole>>` is not satisfied
    --> openpgp/src/parse.rs:2414:73
     |
2414 |             (Packet::PublicSubkey(o), PacketParserResult::EOF(_)) => Ok(o.into()),
     |                                                                         ^^^^^^^^ the trait `From<packet::Key<PublicParts, SubordinateRole>>` is not implemented for `packet::Key<UnspecifiedParts, UnspecifiedRole>`
     |
     = help: the following implementations were found:
               <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
               <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
     = note: required because of the requirements on the impl of `Into<packet::Key<UnspecifiedParts, UnspecifiedRole>>` for `packet::Key<PublicParts, SubordinateRole>`

error[E0277]: the trait bound `packet::Key<UnspecifiedParts, UnspecifiedRole>: From<packet::Key<SecretParts, PrimaryRole>>` is not satisfied
    --> openpgp/src/parse.rs:2415:70
     |
2415 |             (Packet::SecretKey(o), PacketParserResult::EOF(_)) => Ok(o.into()),
     |                                                                      ^^^^^^^^ the trait `From<packet::Key<SecretParts, PrimaryRole>>` is not implemented for `packet::Key<UnspecifiedParts, UnspecifiedRole>`
     |
     = help: the following implementations were found:
               <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
               <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
     = note: required because of the requirements on the impl of `Into<packet::Key<UnspecifiedParts, UnspecifiedRole>>` for `packet::Key<SecretParts, PrimaryRole>`

error[E0277]: the trait bound `packet::Key<UnspecifiedParts, UnspecifiedRole>: From<packet::Key<SecretParts, SubordinateRole>>` is not satisfied
    --> openpgp/src/parse.rs:2416:73
     |
2416 |             (Packet::SecretSubkey(o), PacketParserResult::EOF(_)) => Ok(o.into()),
     |                                                                         ^^^^^^^^ the trait `From<packet::Key<SecretParts, SubordinateRole>>` is not implemented for `packet::Key<UnspecifiedParts, UnspecifiedRole>`
     |
     = help: the following implementations were found:
               <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
               <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
     = note: required because of the requirements on the impl of `Into<packet::Key<UnspecifiedParts, UnspecifiedRole>>` for `packet::Key<SecretParts, SubordinateRole>`

error[E0599]: no method named `role_as_subordinate` found for reference `&packet::Key<P, UnspecifiedRole>` in the current scope
    --> openpgp/src/cert/amalgamation/key.rs:1733:44
     |
1733 | ...                   self.key().role_as_subordinate(),
     |                                  ^^^^^^^^^^^^^^^^^^^ method not found in `&packet::Key<P, UnspecifiedRole>`

error[E0599]: no method named `role_as_subordinate` found for reference `&packet::Key<P, UnspecifiedRole>` in the current scope
    --> openpgp/src/cert/amalgamation/key.rs:1765:28
     |
1765 |                 self.key().role_as_subordinate(),
     |                            ^^^^^^^^^^^^^^^^^^^ method not found in `&packet::Key<P, UnspecifiedRole>`

error[E0599]: no method named `parts_as_public` found for enum `packet::Key<SecretParts, _>` in the current scope
    --> openpgp/src/cert/builder.rs:1452:56
     |
1452 |         let sig = sig.sign_direct_key(&mut signer, key.parts_as_public())?;
     |                                                        ^^^^^^^^^^^^^^^ method not found in `packet::Key<SecretParts, _>`
     | 
    ::: openpgp/src/packet/mod.rs:1475:1
     |
1475 | pub enum Key<P: key::KeyParts, R: key::KeyRole> {
     | ----------------------------------------------- method `parts_as_public` not found for this

error[E0599]: no method named `parts_as_secret` found for reference `&packet::Key<PublicParts, UnspecifiedRole>` in the current scope
   --> openpgp/src/serialize/cert.rs:247:57
    |
247 |                 a.has_secret() && (self.filter)(a.key().parts_as_secret().expect("has secret")),
    |                                                         ^^^^^^^^^^^^^^^ method not found in `&packet::Key<PublicParts, UnspecifiedRole>`

error[E0599]: no method named `parts_as_secret` found for reference `&packet::Key<PublicParts, UnspecifiedRole>` in the current scope
   --> openpgp/src/serialize/cert.rs:248:58
    |
248 |                 b.has_secret() && (other.filter)(b.key().parts_as_secret().expect("has_secret")),
    |                                                          ^^^^^^^^^^^^^^^ method not found in `&packet::Key<PublicParts, UnspecifiedRole>`

error[E0277]: the trait bound `packet::Key<SecretParts, PrimaryRole>: From<packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:454:64
    |
454 |                     Tag::PublicKey => crate::Packet::SecretKey(key_with_stub.into()).serialize(o),
    |                                                                ^^^^^^^^^^^^^^^^^^^^ the trait `From<packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `packet::Key<SecretParts, PrimaryRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<packet::Key<SecretParts, PrimaryRole>>` for `packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `packet::Key<SecretParts, SubordinateRole>: From<packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:456:53
    |
456 |                         crate::Packet::SecretSubkey(key_with_stub.into()).serialize(o)
    |                                                     ^^^^^^^^^^^^^^^^^^^^ the trait `From<packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `packet::Key<SecretParts, SubordinateRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<packet::Key<SecretParts, SubordinateRole>>` for `packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<PublicParts, PrimaryRole>: From<&packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:463:56
    |
463 |                 Tag::PublicKey => PacketRef::PublicKey(key.into()).serialize(o),
    |                                                        ^^^^^^^^^^ the trait `From<&packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `&packet::Key<PublicParts, PrimaryRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<PublicParts, PrimaryRole>>` for `&packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<PublicParts, SubordinateRole>: From<&packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:464:62
    |
464 |                 Tag::PublicSubkey => PacketRef::PublicSubkey(key.into()).serialize(o),
    |                                                              ^^^^^^^^^^ the trait `From<&packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `&packet::Key<PublicParts, SubordinateRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<PublicParts, SubordinateRole>>` for `&packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<SecretParts, PrimaryRole>: From<&packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:465:56
    |
465 |                 Tag::SecretKey => PacketRef::SecretKey(key.into()).serialize(o),
    |                                                        ^^^^^^^^^^ the trait `From<&packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `&packet::Key<SecretParts, PrimaryRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<SecretParts, PrimaryRole>>` for `&packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<SecretParts, SubordinateRole>: From<&packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:466:62
    |
466 |                 Tag::SecretSubkey => PacketRef::SecretSubkey(key.into()).serialize(o),
    |                                                              ^^^^^^^^^^ the trait `From<&packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `&packet::Key<SecretParts, SubordinateRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<SecretParts, SubordinateRole>>` for `&packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<SecretParts, UnspecifiedRole>: From<&packet::Key<PublicParts, PrimaryRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:472:26
    |
472 |         serialize_key(o, primary.key().into(), Tag::PublicKey, Tag::SecretKey)?;
    |                          ^^^^^^^^^^^^^^^^^^^^ the trait `From<&packet::Key<PublicParts, PrimaryRole>>` is not implemented for `&packet::Key<SecretParts, UnspecifiedRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<SecretParts, UnspecifiedRole>>` for `&packet::Key<PublicParts, PrimaryRole>`

error[E0277]: the trait bound `&packet::Key<SecretParts, UnspecifiedRole>: From<&packet::Key<PublicParts, SubordinateRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:523:30
    |
523 |             serialize_key(o, k.key().into(), Tag::PublicSubkey, Tag::SecretSubkey)?;
    |                              ^^^^^^^^^^^^^^ the trait `From<&packet::Key<PublicParts, SubordinateRole>>` is not implemented for `&packet::Key<SecretParts, UnspecifiedRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<SecretParts, UnspecifiedRole>>` for `&packet::Key<PublicParts, SubordinateRole>`

error[E0599]: no method named `parts_as_public` found for reference `&'a packet::Key<SecretParts, UnspecifiedRole>` in the current scope
   --> openpgp/src/serialize/cert.rs:580:29
    |
580 |                 let l = key.parts_as_public().net_len() + 8;
    |                             ^^^^^^^^^^^^^^^ method not found in `&'a packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<PublicParts, PrimaryRole>: From<&packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:587:56
    |
587 |                 Tag::PublicKey => PacketRef::PublicKey(key.into()),
    |                                                        ^^^^^^^^^^ the trait `From<&packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `&packet::Key<PublicParts, PrimaryRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<PublicParts, PrimaryRole>>` for `&packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<PublicParts, SubordinateRole>: From<&packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:588:62
    |
588 |                 Tag::PublicSubkey => PacketRef::PublicSubkey(key.into()),
    |                                                              ^^^^^^^^^^ the trait `From<&packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `&packet::Key<PublicParts, SubordinateRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<PublicParts, SubordinateRole>>` for `&packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<SecretParts, PrimaryRole>: From<&packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:589:56
    |
589 |                 Tag::SecretKey => PacketRef::SecretKey(key.into()),
    |                                                        ^^^^^^^^^^ the trait `From<&packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `&packet::Key<SecretParts, PrimaryRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<SecretParts, PrimaryRole>>` for `&packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<SecretParts, SubordinateRole>: From<&packet::Key<SecretParts, UnspecifiedRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:590:62
    |
590 |                 Tag::SecretSubkey => PacketRef::SecretSubkey(key.into()),
    |                                                              ^^^^^^^^^^ the trait `From<&packet::Key<SecretParts, UnspecifiedRole>>` is not implemented for `&packet::Key<SecretParts, SubordinateRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<SecretParts, SubordinateRole>>` for `&packet::Key<SecretParts, UnspecifiedRole>`

error[E0277]: the trait bound `&packet::Key<SecretParts, UnspecifiedRole>: From<&packet::Key<PublicParts, PrimaryRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:598:33
    |
598 |         l += serialized_len_key(primary.key().into(), Tag::PublicKey, Tag::SecretKey);
    |                                 ^^^^^^^^^^^^^^^^^^^^ the trait `From<&packet::Key<PublicParts, PrimaryRole>>` is not implemented for `&packet::Key<SecretParts, UnspecifiedRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<SecretParts, UnspecifiedRole>>` for `&packet::Key<PublicParts, PrimaryRole>`

error[E0277]: the trait bound `&packet::Key<SecretParts, UnspecifiedRole>: From<&packet::Key<PublicParts, SubordinateRole>>` is not satisfied
   --> openpgp/src/serialize/cert.rs:621:37
    |
621 |             l += serialized_len_key(k.key().into(), Tag::PublicSubkey, Tag::SecretSubkey);
    |                                     ^^^^^^^^^^^^^^ the trait `From<&packet::Key<PublicParts, SubordinateRole>>` is not implemented for `&packet::Key<SecretParts, UnspecifiedRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<&packet::Key<SecretParts, UnspecifiedRole>>` for `&packet::Key<PublicParts, SubordinateRole>`

error[E0599]: no method named `parts_as_public` found for reference `&'a packet::Key<P, R>` in the current scope
    --> openpgp/src/serialize/stream.rs:2000:36
     |
2000 |         Self::new(key.keyid(), key.parts_as_public().role_as_unspecified())
     |                                    ^^^^^^^^^^^^^^^ method not found in `&'a packet::Key<P, R>`

error[E0599]: no method named `parts_as_public` found for reference `&'a packet::Key<P, R>` in the current scope
    --> openpgp/src/serialize/stream.rs:2081:22
     |
2081 |             key: key.parts_as_public().role_as_unspecified(),
     |                      ^^^^^^^^^^^^^^^ method not found in `&'a packet::Key<P, R>`

error[E0277]: the trait bound `packet::Key<PublicParts, PrimaryRole>: From<packet::Key<SecretParts, PrimaryRole>>` is not satisfied
   --> /home/liw/cargo/debug/build/sequoia-openpgp-d20775a29289aa5f/out/cert/parser/low_level/grammar.rs:873:66
    |
873 |                     Some((Packet::SecretKey(key), sigs)) => (key.into(), sigs),
    |                                                                  ^^^^ the trait `From<packet::Key<SecretParts, PrimaryRole>>` is not implemented for `packet::Key<PublicParts, PrimaryRole>`
    |
    = help: the following implementations were found:
              <packet::Key<P, R> as From<packet::key::Key4<P, R>>>
              <packet::Key<SecretParts, UnspecifiedRole> as From<KeyPair>>
    = note: required because of the requirements on the impl of `Into<packet::Key<PublicParts, PrimaryRole>>` for `packet::Key<SecretParts, PrimaryRole>`

error[E0599]: no method named `parts_into_public` found for enum `packet::Key<SecretParts, SubordinateRole>` in the current scope
    --> /home/liw/cargo/debug/build/sequoia-openpgp-d20775a29289aa5f/out/cert/parser/low_level/grammar.rs:1169:57
     |
1169 |             Some(Packet::SecretSubkey(key)) => Some(key.parts_into_public()),
     |                                                         ^^^^^^^^^^^^^^^^^ method not found in `packet::Key<SecretParts, SubordinateRole>`
     | 
    ::: openpgp/src/packet/mod.rs:1475:1
     |
1475 | pub enum Key<P: key::KeyParts, R: key::KeyRole> {
     | ----------------------------------------------- method `parts_into_public` not found for this

warning: unused import: `NetLength`
 --> openpgp/src/serialize/cert.rs:5:72
  |
5 |     generic_export_into, generic_serialize_into, Marshal, MarshalInto, NetLength, PacketRef,
  |                                                                        ^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Some errors have detailed explanations: E0271, E0277, E0599.
For more information about an error, try `rustc --explain E0271`.
error: could not compile `sequoia-openpgp` due to 65 previous errors; 1 warning emitted
error: build failed

(maintainer note: output moved to a collapsible section for better issue readability)

@larswirzenius
Copy link
Author

From Sequoia IRC: apparently rustfmt has trouble with the macros in Sequoia.

@calebcartwright
Copy link
Member

Thanks for reaching out with the report. However, there's a lot of extra noise in the description that makes it hard to zoom in on the formatting issue. Would you please extract a minimal reproduction example and update the issue description? I'd suggest starting with cargo fmt -- --check to get rustfmt to show you the diff, and imagine that it should be straight forward from there to figure out which mac call or def is being misformatted.

@calebcartwright calebcartwright added the needs-mcve needs a Minimal Complete and Verifiable Example label Sep 21, 2021
@Erik1000
Copy link

Hey there! I've investigated the problem here.

In short: there are two things that cause breakage:

1. rustfmt removes angle brackets from a macro

create_conversions!(Key<>);

becomes

create_conversions!(Key);

macro definition:

macro_rules! create_conversions {
    ( $Key:ident<$( $l:lifetime ),*> ) => {
        ...
    }
}

See here for the full macro

2. rustfmt gets confused about feature flags and code blocks

impl Default for CompressionAlgorithm {
    fn default() -> Self {
        use self::CompressionAlgorithm::*;
        #[cfg(feature = "compression-deflate")]
        { Zip }
        #[cfg(all(feature = "compression-bzip2",
                  not(feature = "compression-deflate")))]
        { BZip2 }
        #[cfg(all(not(feature = "compression-bzip2"),
                  not(feature = "compression-deflate")))]
        { Uncompressed }
    }
}

becomes

impl Default for CompressionAlgorithm {
    fn default() -> Self {
        use self::CompressionAlgorithm::*;
        #[cfg(feature = "compression-deflate")]
        {
            {            Zip
        }
        #[cfg(all(feature = "compression-bzip2", not(feature = "compression-deflate")))]
        {
            {            BZip2
        }
        #[cfg(all(
            not(feature = "compression-bzip2"),
            not(feature = "compression-deflate")
        ))]
        {
            {            Uncompressed
        }
    }
}

See full file here.

@calebcartwright calebcartwright removed the needs-mcve needs a Minimal Complete and Verifiable Example label Sep 24, 2021
@calebcartwright
Copy link
Member

Thanks again @larswirzenius for the report, and very much appreciated @Erik1000 for the succinct summary!

Your first section ultimately ties back to general macro handling limitations (e.g. #8). To be fully transparent, this is unlikely to change any time soon, so the recommended workarounds for now are:

  • using brace delimiters on calls instead of parens (e.g. create_conversions! { Key<> })
    • this works because rustfmt will attempt to format args on calls that use bracket and paren delimiters if they look like/can be parsed as valid rust AST kinds, and then formats them according to the corresponding rules for that kind. however, this doesn't always work and can produce the type of behavior you're experiencing
  • use the general, or macro-specific, skip attributes - https://github.com/rust-lang/rustfmt#tips

Your second item looks like an old bug, and not one I can reproduce with rustfmt on nightly, stable, nor from source. Are you sure you're not actually using an older version of rustfmt, and if so, could you share your configuration file?

@Erik1000
Copy link

Your second item looks like an old bug, and not one I can reproduce with rustfmt on nightly, stable, nor from source. Are you sure you're not actually using an older version of rustfmt, and if so, could you share your configuration file?

I actually can confirm that the second item is fixed on current stable. Sequoia is locked at 1.48.0 and the bug is present there.

@calebcartwright
Copy link
Member

Thanks for confirming. I'm going to go ahead and close this then given the only unresolved issue stems from the standard minimal macro support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants