about summary refs log tree commit diff
path: root/tests/codegen-llvm/src-hash-algorithm/src-hash-algorithm-sha1.rs
diff options
context:
space:
mode:
authorEd Page <eopage@gmail.com>2024-12-17 15:42:39 -0600
committerEd Page <eopage@gmail.com>2025-06-09 15:25:26 -0500
commitfea6a2289bd3412da1f61ded1f3825c10a361b53 (patch)
tree575191180bb5ab7b659cebd90f4a068b5b2b3258 /tests/codegen-llvm/src-hash-algorithm/src-hash-algorithm-sha1.rs
parent00b526212bbdd68872d6f964fcc9a14a66c36fd8 (diff)
downloadrust-fea6a2289bd3412da1f61ded1f3825c10a361b53.tar.gz
rust-fea6a2289bd3412da1f61ded1f3825c10a361b53.zip
Specify the behavior of `file!`
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
- Being able to look up test assets relative to the current file
  ([example](https://github.com/rust-lang/cargo/blob/b9026bf654d7fac283465e58b8b76742244ef07d/tests/testsuite/cargo_add/add_basic/mod.rs#L34))
- Inline snapshotting libraries being able to update Rust source code
  ([example](https://github.com/rust-lang/cargo/blob/b9026bf654d7fac283465e58b8b76742244ef07d/tests/testsuite/alt_registry.rs#L36-L45))

T-libs-api discussed two solutions
- `file_absolute!`:
  - Has less meaning in other build tools like buck2
  - Bakes in the assumption that a full path is available (e.g. with
    trim-paths)
- Specifying `file!`s behavior (this PR):
  - Leaves it to the user to deal with trim-paths
  - Even though `file!` is currently unspecified, changing it would
    likely have too large of an impact on the ecosystem at this time.

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.
Diffstat (limited to 'tests/codegen-llvm/src-hash-algorithm/src-hash-algorithm-sha1.rs')
0 files changed, 0 insertions, 0 deletions