Skip to content

Inferring the Rust edition in use doesn't always work #274

@meithecatte

Description

@meithecatte

Hi,

my tests started suddenly failing because CI pulled in the latest version of trybuild. I tracked this down to commit c74de40 "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):

[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions