rust/library/core/src
Ed Page fea6a2289b 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](b9026bf654/tests/testsuite/cargo_add/add_basic/mod.rs (L34)))
- Inline snapshotting libraries being able to update Rust source code
  ([example](b9026bf654/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.
2025-06-09 15:25:26 -05:00
..
alloc Add some track_caller info to precondition panics 2025-05-21 09:10:06 -04:00
array Rollup merge of #140066 - thaliaarchi:const-array-as-mut-slice, r=jhpratt 2025-05-24 21:23:47 +02:00
ascii Add some track_caller info to precondition panics 2025-05-21 09:10:06 -04:00
async_iter Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
bstr Replace colon with parentheses, add missing period 2025-04-21 10:48:46 -04:00
cell Rollup merge of #129334 - ChayimFriedman2:more-lazy-methods, r=Amanieu 2025-05-10 16:26:01 +02:00
char Add some track_caller info to precondition panics 2025-05-21 09:10:06 -04:00
clone CloneToUninit: use a private specialization trait 2024-07-29 20:44:43 +03:00
cmp Use generic NonZero everywhere in core. 2024-02-22 15:17:33 +01:00
convert remove f16: From<u16> 2025-06-02 17:51:45 +08:00
ffi terminology: allocated object → allocation 2025-05-31 22:49:14 +02:00
fmt Compute number of digits instead of relying on constant value for u128 display code 2025-06-06 14:28:37 +02:00
future update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
hash library: Use size_of from the prelude instead of imported 2025-03-06 20:20:38 -08:00
intrinsics Remove rustc's notion of "preferred" alignment AKA __alignof 2025-06-08 16:41:46 -07:00
io Add inherent versions of MaybeUninit methods for slices 2025-01-11 23:57:00 -05:00
iter Fix usage of bootstrap in core 2025-06-07 18:11:53 +02:00
macros Specify the behavior of file! 2025-06-09 15:25:26 -05:00
marker Call out possibility of invariant result 2025-05-26 15:06:36 -04:00
mem Fixed a typo in ManuallyDrop's doc 2025-06-02 01:55:29 +02:00
net Add Ipv4Addr and Ipv6Addr diagnostic items 2025-05-14 09:34:25 +02:00
num De-duplicate f16 & f128 doctest attributes 2025-06-08 14:51:13 +02:00
ops Auto merge of #129658 - saethlin:spare-a-crumb, r=jhpratt 2025-05-27 22:11:53 +00:00
panic Add Location::file_with_nul 2025-06-04 09:23:05 -07:00
pin centralize aliasing rules discussion in UnsafeCell docs 2025-06-07 21:57:45 +02:00
prelude update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
ptr terminology: allocated object → allocation 2025-05-31 22:49:14 +02:00
range Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
slice Stabilize const_eq_ignore_ascii_case 2025-06-05 07:09:16 +00:00
str Stabilize const_eq_ignore_ascii_case 2025-06-05 07:09:16 +00:00
sync Rollup merge of #142053 - heiher:loong32-none, r=wesleywiser 2025-06-08 17:17:53 -07:00
task Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
unicode Remove unneeded parentheses. 2025-03-08 12:56:00 +01:00
any.rs fix missing word in comment 2025-04-16 18:53:40 -07:00
arch.rs update version placeholders 2025-05-12 15:33:30 +02:00
ascii.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
asserting.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
bool.rs Move select_unpredictable to the hint module 2025-04-13 01:34:25 +01:00
borrow.rs Suggest borrowing on fn argument that is impl AsRef 2024-05-09 23:25:31 +00:00
cell.rs centralize aliasing rules discussion in UnsafeCell docs 2025-06-07 21:57:45 +02:00
clone.rs std: clarify Clone trait documentation about duplication semantics 2025-05-31 12:01:57 +08:00
cmp.rs Extend the chaining logic to slices too 2025-04-12 22:10:17 -07:00
contracts.rs Apply suggestions from code review 2025-04-10 16:32:56 -07:00
default.rs Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
error.md Mention core's PanicInfo in error.md. 2024-06-11 15:47:00 +02:00
error.rs Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
escape.rs core: add #![warn(unreachable_pub)] 2025-01-20 18:35:32 +01:00
hint.rs Auto merge of #129658 - saethlin:spare-a-crumb, r=jhpratt 2025-05-27 22:11:53 +00:00
internal_macros.rs Use cfg_match in core 2025-03-26 14:32:35 -04:00
lib.miri.rs add 'x.py miri', and make it work for 'library/{core,alloc,std}' 2024-04-03 20:27:20 +02:00
lib.rs Remove bootstrap cfgs from library/ 2025-06-02 10:19:58 -07:00
marker.rs Fix typo in StructuralPartialEq docs 2025-06-01 08:15:00 -06:00
option.rs Rollup merge of #141447 - y86-dev:option-layout-docs, r=RalfJung 2025-06-07 22:22:56 +02:00
panic.rs update cfgs 2024-11-27 15:14:54 +00:00
panicking.rs update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
pat.rs update cfgs 2025-04-09 12:29:59 +01:00
pin.rs Remove more library bootstrap 2025-06-02 14:46:19 -07:00
primitive.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
primitive_docs.rs Rollup merge of #137306 - tgross35:remove-i128-u128-improper-ctypes, r=traviscross,workingjubilee 2025-06-04 07:54:31 +02:00
random.rs random: add tracking issue, address other comments 2024-09-23 10:36:16 +02:00
range.rs update cfg(bootstrap) 2025-02-18 09:32:44 -08:00
result.rs Rollup merge of #141072 - Rynibami:stabilize-const-result-flatten, r=jhpratt 2025-06-01 00:35:50 +02:00
time.rs Split duration_constructors to get non-controversial bits out faster. 2025-05-09 22:52:39 -04:00
tuple.rs Extend the chaining logic to slices too 2025-04-12 22:10:17 -07:00
ub_checks.rs Add some track_caller info to precondition panics 2025-05-21 09:10:06 -04:00
unit.rs core: Make Debug impl of raw pointers print metadata if present 2025-02-15 17:27:55 +01:00
unsafe_binder.rs Add unwrap_unsafe_binder and wrap_unsafe_binder macro operators 2024-12-12 16:29:40 +00:00