Commit 5a1fa7f
committed
feat: Stablize
This provides what cargo sets as the `current_dir` for the `rustc`
process.
While `std::file!` is unspecified in what it is relative to,
it is relatively safe, it is generally relative to `rustc`s
`current_dir`.
This can be useful for snapshot testing.
For example, `snapbox` has been using this macro on nightly since
assert-rs/snapbox#247, falling back to finding a parent of
`CARGO_MANIFEST_DIR`, if present.
This has been in use in Cargo since #13441.
This was added in #12996.
Relevant points discussed in that issue:
- This diverged from the original proposal from the Cargo team of having
a `CARGO_WORKSPACE_DIR` that is the "workspace" of the package being
built (ie registry packages would map to `CARGO_MANIFEST_DIR`).
In looking at the `std::file!` use case, `CARGO_MANIFEST_DIR`, no
matter how we defined it, would only sort of work because no sane
definition of that maps to `rustc`'s `current_dir`.a
This instead focuses on the mechanism currently being used.
- Using "current dir" in the name is meant to be consistent with
`std::env::current_dir`.
- I can go either way on `CARGO_RUSTC` vs `RUSTC`. Existing related
variables:
- `RUSTC`
- `RUSTC_WRAPPER`
- `RUSTC_WORKSPACE_WRAPPER`
- `RUSTFLAGS` (no `C`)
- `CARGO_CACHE_RUSTC_INFO`
Note that #3946 was overly broad and covered many use cases.
One of those was for packages to look up information on their
dependents.
Issue #13484 is being left open to track that.
Fixes #3946CARGO_RUSTC_CURRENT_DIR
1 parent a510712 commit 5a1fa7f
3 files changed
Lines changed: 13 additions & 48 deletions
File tree
- src
- cargo/core/compiler
- doc/src/reference
- tests/testsuite
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
696 | 696 | | |
697 | 697 | | |
698 | 698 | | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
709 | 707 | | |
710 | 708 | | |
711 | 709 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
| 268 | + | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1705 | 1705 | | |
1706 | 1706 | | |
1707 | 1707 | | |
1708 | | - | |
1709 | | - | |
1710 | | - | |
| 1708 | + | |
1711 | 1709 | | |
1712 | 1710 | | |
1713 | 1711 | | |
1714 | 1712 | | |
1715 | 1713 | | |
1716 | 1714 | | |
1717 | 1715 | | |
1718 | | - | |
1719 | | - | |
1720 | | - | |
| 1716 | + | |
1721 | 1717 | | |
1722 | 1718 | | |
1723 | | - | |
1724 | | - | |
1725 | | - | |
| 1719 | + | |
1726 | 1720 | | |
1727 | 1721 | | |
1728 | 1722 | | |
1729 | | - | |
1730 | | - | |
1731 | | - | |
| 1723 | + | |
1732 | 1724 | | |
1733 | 1725 | | |
1734 | 1726 | | |
| |||
1814 | 1806 | | |
1815 | 1807 | | |
1816 | 1808 | | |
1817 | | - | |
1818 | 1809 | | |
1819 | 1810 | | |
1820 | 1811 | | |
1821 | | - | |
1822 | 1812 | | |
1823 | 1813 | | |
1824 | 1814 | | |
| |||
1863 | 1853 | | |
1864 | 1854 | | |
1865 | 1855 | | |
1866 | | - | |
1867 | 1856 | | |
1868 | 1857 | | |
1869 | 1858 | | |
1870 | 1859 | | |
1871 | | - | |
1872 | | - | |
1873 | | - | |
1874 | | - | |
1875 | | - | |
1876 | | - | |
1877 | | - | |
1878 | | - | |
1879 | | - | |
1880 | | - | |
1881 | | - | |
1882 | | - | |
1883 | | - | |
1884 | | - | |
1885 | | - | |
1886 | | - | |
1887 | | - | |
1888 | | - | |
1889 | | - | |
1890 | | - | |
1891 | | - | |
1892 | | - | |
1893 | 1860 | | |
1894 | 1861 | | |
1895 | 1862 | | |
| |||
0 commit comments