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
|
☔ The latest upstream changes (presumably #165760) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
Connected to tracking issue: #146922
r? @oli-obk
#goals/reflection > Reading files at comptime