[SOLVED] Rustfmt stable errors on dyn keyword (out of date)


#1

Hey there, I’m working through the Rust book right now (it’s fantastic, by the way) but I’ve hit a snag with rustfmt.

On my work laptop it works absolutely fine, but on my home laptop (also an XPS 13 with Arch Linux) it errors when I use <dyn Error> on this line https://github.com/Olical/rust-book/blob/984fcc7446d2a2b04ebee97760260e5032883d66/minigrep/src/lib.rs#L29

error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `Error`
  --> /home/oliver/repos/rust-book/minigrep/src/lib.rs:29:50
   |
29 | pub fn run(config: Config) -> Result<(), Box<dyn Error>> {
   |                                                  ^^^^^

If I remove the dyn it’s absolutely fine. My local version is:

$ rustfmt -V
0.8.3 ()

I’m using stable in both environments, I’ve tried to update everything I can. Does anything look out of date or sound strange? Is there any common thing I can do to make sure the right version is installed?

Thanks a lot!


#2

Unfortunately you are running an old version of rustfmt.
Try doing this:

cargo uninstall rustfmt
rustup self update
rustup update
rustup component add rustfmt-preview

#3

I thought so! I didn’t realise I had it installed via cargo, the cargo uninstall rustfmt was all I needed.

I’d already tried removing the entire toolchain and the component but hadn’t tried cargo uninstall

Thank you! Happy to delete this if it serves no use to anyone else?


#4

Add [SOLVED] at the beginning of the title, maybe someone could have the same problem. :wink: