Code compiles on playground but fails when passed via stdin to rustc

Do note that I implemented this as an undismisable note, which could also be a warning (that wouldn't be affected by forbid warnings, if iirc, as that only looks at lints, but might be getting things wrong there). The only people affected would be those explicitly comparing textual compiler output in scripts.

4 Likes

Around the time we approved an environment variable, there started talk among T-lang to add an edition cfg which would then be exposed to build scripts as CARGO_CFG_EDITION. That went through several proposals, delaying it. The latest has been untouched for enough time that it might not be worth waiting on anymore and to instead use CARGO_PKG_EDITION.

2 Likes

I'm also struggling to see how this would work. To my understanding the cargo env variables are set once for a cargo invocation[1]. Build scripts and edition selection are unique to a specific crate, wherever it sits in the dependency tree; not driven by the one(s) at the top of the chain which triggered the build.


  1. building all crates in parallel and the global-nature of env vars suggests this cannot be done any other way(?) ↩︎

Cargo sets a bunch of env vars for each build script invocation with different values depending on the package they are part of.