Specify the behavior of file! by epage · Pull Request #134442 · rust-lang/rust (original) (raw)

This takes the current behavior of file! and documents it so it is safe to make assumptions about.
For example, Cargo could provide a CARGO_RUSTC_CURRENT_DIR as a base path for file!.

Example use cases

See rust-lang/cargo#3946 for more context.

T-libs-api discussed two solutions in rust-lang/libs-team#478

A future possibility is that rustc could have a flag that controls modifies the base path used for file!.
That seems purely additive with specifying the behavior and we do not want to block on it.
It would also likely be too disruptive for Cargo users (as mentioned). However, we tried to keep this in mind when specifying the behavior.