Inferring the Rust edition in use doesn't always work
- Dominant language
- Rust
- Stars
- 998
- Forks
- 84
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
my tests started suddenly failing because CI pulled in the latest version of `trybuild`. I tracked this down to commit c74de40e1daedad82a012e9a817eb72d224cd6b8 "Use 2015 as the default edition if not found in Cargo.toml".
It's somewhat unfortunate that this (technically breaking!) change wasn't listed in the changelog, but this shouldn't affect anyone in the first place because `cargo` warns when no edition is specified and it defaults to Rust 2015.
Indeed, the underlying issue is in how the following `Cargo.toml` file will get parsed ([full file from my repo](https://github.com/meithecatte/enumflags2/blob/73b1469cc637fbad3f2474ccb1f270785a7a4e41/test_suite/Cargo.toml)):
```toml
[package]
name = "test-suite"
version = "0.0.0"
publish = false
# note: no edition key here, I am setting this separately per test
[[test]]
name = "ui-tests"
path = "ui_tests.rs"
edition = "2018"
[[test]]
name = "test-edition-2015"
path = "tests/tests.rs"
edition = "2015"
```
Cargo will use one of the `edition` keys in the `[[test]]` sections, while `trybuild` will only look in `[package]`, not find anything, and silently default to 2015.
Ideally, `trybuild` would correctly grab the `edition` field corresponding to the test being ran. Alternatively, a small and easy solution would be to warn when the default fallback is being used.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.