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

dyn and :: should have a space between #3724

Closed
agrover opened this issue Aug 2, 2019 · 5 comments
Closed

dyn and :: should have a space between #3724

agrover opened this issue Aug 2, 2019 · 5 comments

Comments

@agrover
Copy link

agrover commented Aug 2, 2019

When given this code:

fn foo(_x: &u64) -> Option<&(dyn ::std::error::Error + 'static)> {
    None
}

rustfmt 1.2.2 stable removes the space between dyn and ::, resulting in this:

fn foo(_x: &u64) -> Option<&(dyn::std::error::Error + 'static)> {
    None
}
@topecongiro topecongiro added bug Panic, non-idempotency, invalid code, etc. and removed bug Panic, non-idempotency, invalid code, etc. labels Aug 4, 2019
@topecongiro
Copy link
Contributor

We need to use edition 2018 to use the dyn syntax with a path that starts with ::. If you are using edition 2015 in your project, then you need to write like (dyn (::std::error::Error)).

cc rust-lang/rust#49218 (comment)

@agrover
Copy link
Author

agrover commented Aug 5, 2019

This is with edition 2018. Please reopen?

@sinkuu
Copy link
Contributor

sinkuu commented Aug 6, 2019

It seems that rustfmt (on playground) correctly adds spacing if edition is set to 2018. I guess https://github.com/rust-lang/rustfmt#rusts-editions fixes your problem.

@agrover
Copy link
Author

agrover commented Aug 17, 2019

No, we are using 2018 edition.

  • git clone https://github.com/mozilla/neqo.git
  • Observe that neqo-transport/Cargo.toml sets edition = "2018"
  • Observe that neqo-transport/src/lib.rs line 120 is mis-formatted.

@agrover
Copy link
Author

agrover commented Aug 17, 2019

Oops, I can't repro with cargo fmt -- --check, this is happening with emacs rust-mode autoformat-on-save, so I think it is to blame, not rustfmt. Sorry to bother y'all.

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