`cargo fix --edition` failed: `error: expected item after attributes`
Open
Nobody has claimed this yet.
A-diagnostics
A-edition-2024
A-lints
A-macros
C-bug
D-invalid-suggestion
F-precise_capturing
I-edition-triaged
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code: https://github.com/eval-exec/cargo-migration-2024-bug.git
Execute cargo fix --edition
I expected to see this happen: migration success
Instead, this happened:
Checking cargo-migration-2024-bug v0.1.0 (/home/exec/Projects/github.com/eval-exec/cargo-migration-2024-bug)
Migrating src/main.rs from 2021 edition to 2024
warning: failed to automatically apply fixes suggested by rustc to crate `cargo_migration_2024_bug`
after fixes were automatically applied the compiler reported errors within these files:
* src/main.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error: expected item after attributes
--> src/main.rs:4:1
|
4 | #[rpc] + use<>
| ^^^^^^
error: aborting due to 1 previous error
Original diagnostics will follow.
warning: `impl std::future::Future<Output = Result<bool, RpcError>>` will capture more lifetimes than possibly intended in edition 2024
--> src/main.rs:4:1
|
4 | #[rpc]
| ^^^^^^
|
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/rpit-lifetime-capture.html>
note: specifically, this lifetime is in scope but not mentioned in the type's bounds
--> src/main.rs:4:1
|
4 | #[rpc]
| ^
= note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024
= note: `--force-warn impl-trait-overcaptures` implied by `--force-warn rust-2024-compatibility`
= note: this warning originates in the attribute macro `rpc` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use the precise capturing `use<...>` syntax to make the captures explicit
|
4 | #[rpc] + use<>
| +++++++
warning: `cargo-migration-2024-bug` (bin "cargo-migration-2024-bug") generated 1 warning (run `cargo fix --bin "cargo-migration-2024-bug"` to apply 1 suggestion)
warning: failed to automatically apply fixes suggested by rustc to crate `cargo_migration_2024_bug`
after fixes were automatically applied the compiler reported errors within these files:
* src/main.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error: expected item after attributes
--> src/main.rs:4:1
|
4 | #[rpc] + use<>
| ^^^^^^
error: aborting due to 1 previous error
Original diagnostics will follow.
warning: `cargo-migration-2024-bug` (bin "cargo-migration-2024-bug" test) generated 1 warning (1 duplicate)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.04s
Meta
rustc --version --verbose:
❯ rustc --version --verbose
rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: x86_64-unknown-linux-gnu
release: 1.85.0
LLVM version: 19.1.7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the linked cargo-migration-2024-bug repository by running cargo fix --edition, then inspect src/main.rs and the rustc compatibility diagnostic around #[rpc]. Trace the cargo fix/rustc fix application path responsible for producing #[rpc] + use<>; done means the migration completes without malformed output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100