I am actually using emacs Rust binding C-c C-f to invoke formating. which it tells me is (rust-format-buffer). Any idea how I tell that --edition 2024?
I tried putting a rustfmt.toml file next to the Cargo.toml, with the line from the manual.
I then went to the directory with the file giving me trouble, and ran rustfmt on the file. It gave me the same error. Do I need to put rustfmt.toml in the src directory? In src plus every subdirectory? (Not that big a deal, just confusing.)
Thanks,
Joel
Found it. I needed to put in a line slightly different from what the doc page seemed to suggest. The doc talked about a line
style-edition = "2024"
``
but of course what I needed was
Anyone using the emacs invocation of formating? At this point, if I run rustfmt from the command line, it doesn't complain. But if I have the file in emacs, and type C-c C-f, I get the version complaint. Do I not mroe copies of rustfmt.toml because of how emacs runs it? Do I need to tell the emacs command somehow --edition 2024?
Joel
PS: jer, thanks for the prompt response that covered the non-emacs part of the problem.
IIRC rustfmt will search up the directory tree. I always put my rustfmt.toml in the crate/workspace root, and it is automatically picked up whichever subcrate I am working in.
Could you check the emacs "plugin" that runs rustfmt to see if it sets the current directory before running the command? Just a wild guess, but maybe the plugin just pipes the source through rustfmt, and it doesn't bother setting the current directory. (Though to be honest that would surprise me).
As far as I know, rustfmt itself is a compiled lisp thing, so I am not sure how to check it. BBut I tried checking the other way. I copied rustfmt.toml into the directory with the file giving me trouble. And then told emacs to run rustfmt. And got the same error.
When I search I find references to a rust-rustfmt-switchesrust-rustfmt-buffer variable defined in rust-mode.el. I'm not an emacs user so I can't tell you how to set it.
Yes, that is the emacs lisp function that is used to invoke rustfmt. I have not found any way to specify the --edition parameter for it. I have also been unable to figure out why it is ignore rustfmt.toml. I am starting to conclude that emacs use for rust is less common than I had hoped.
At a guess, the problem is my emacs config, not cargo. Running cargo fmt directly works fine. With the suggested changes, even running rustfmt directly works.
Yours,
Joel
I tried sprinkling rustfmt.toml files on .config/rustfmt/, in .emacs.d/, and in .emacs.d/rustfmt/. Didn't do the trick. I wonder where I am supposed to put it, or if I need a line in my .init.el to tell it where to look?
Thanks,
Joel