Repository navigation
Conversation
daef30d to
7da399f
Compare
|
|
||
| specialization_enabled_in: bool, | ||
|
|
||
| // LazyTable maybe?? |
There was a problem hiding this comment.
yea, definitely 😅 if the list gets large for anyone the linear search doesn't seem ideal
There was a problem hiding this comment.
Don't think I can actually use LazyTable here, as I have a hard time (maybe I just do not understand how). I cannot have a Symbol as a key since it does not implement the Idx trait.
Wonder if I could update this to UnordMap. That way, the whole thing can just go in a LazyValue
There was a problem hiding this comment.
Oh hm right. Just a list of entries seems fine, it's usually not gonna be very long anyway
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
| .sess | ||
| .opts | ||
| .unstable_opts | ||
| .experimental_comptime_files |
There was a problem hiding this comment.
Use the query everywhere instead of accessing the file list flag directly in other places
| } | ||
| } | ||
| } else { | ||
| tracing::debug!("not allowed to read file"); |
There was a problem hiding this comment.
This should probably just hard error, making the only way to get a None and not fail compilation is by the file not being actually there
There was a problem hiding this comment.
Added all proper diagnostics too! But I'm a bit unsure about the handling of the spans I did in the machine interpreter.
| match std::fs::read(resolved_path) { | ||
| Ok(content) => Some(tcx.arena.alloc_slice(&content)), | ||
| Err(err) => { | ||
| tracing::debug!(%err, "failed to read file"); |
There was a problem hiding this comment.
I'm really unsure what to do with this case. The file not being there is possibly useful as a fallible operation, but all other file reading failures should probably hard error
There was a problem hiding this comment.
I went for the query returning a Result<Option<&[u8]>, ReadFileError<'_>>. That should give us the following property:
- return None when file is not there, same as the query
- the caller of the query can emit a clear diagnostic, with the right span, as of why the read failed (not whitelisted, I/O error like
PermissionDenied)
| } | ||
|
|
||
| /// Query list of files available during const evaluation | ||
| query experimental_comptime_list_files(key: CrateNum) -> Option<&'tcx [Symbol]> { |
There was a problem hiding this comment.
There isn't really any useful difference between the empty slice and a None here, so we can just leave out the Option part
This comment has been minimized.
This comment has been minimized.
5c30c45 to
b7e2e75
Compare
This comment has been minimized.
This comment has been minimized.
745adf0 to
254081f
Compare
feat: add file reading query and rmeta encoding/decoding of comptime files remove caching and use CLI flags for comptime files implement intrinsic and add core support for it use symbol in fetch file query and resolve paths from crate root feat: properly track comptime files in crates deps enable proper cross-crate execution of read_file feat: add file list query feat: implement intrinsics and lib functions feat: add error handling for comptime file reading refactor: use query to get comptime filelist fix: set comptime fs queries as eval_always docs: clarify failure modes of read_file Signed-off-by: Lamb <contact@ltow.me>
254081f to
6258416
Compare
|
Some changes occurred to the CTFE machinery Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter |
View all comments
Connected to tracking issue: #146922
r? @oli-obk
#goals/reflection > Reading files at comptime