Repository navigation
Conversation
daef30d to
7da399f
Compare
| } | ||
|
|
||
| /// Query data from non-local crates | ||
| query experimental_comptime_fetch_file(key: (CrateNum, &'tcx String)) -> Option<&'tcx [u8]> { |
There was a problem hiding this comment.
| query experimental_comptime_fetch_file(key: (CrateNum, &'tcx String)) -> Option<&'tcx [u8]> { | |
| query experimental_comptime_fetch_file(key: (CrateNum, Symbol)) -> Option<&'tcx [u8]> { |
we usually try to encode such things as symbols to trivially copy them around, I'm not sure that's the right thing here, but we can start with it and optimize later
|
|
||
| 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
| Lock<FxHashMap<(ty::Clauses<'tcx>, &'tcx [ty::GenericArg<'tcx>]), ty::Clauses<'tcx>>>, | ||
|
|
||
| /// Cache of files that have been read by the const evaluator | ||
| pub experimental_comptime_files: Lock<FxIndexMap<&'tcx String, &'tcx [u8]>>, |
There was a problem hiding this comment.
this cache shouldn't be necessary, queries have their result cached automatically
There was a problem hiding this comment.
Honestly, that was more so I could easily get access to all the read files when encoding the crate metadata. Is it possible to somehow fetch all the cached queries? Or maybe just have a Vec of filepath to re-query with the local crate num?
Edit: ahah, read your comments linearly and literally got the answer to my question two comments down 😆
| if let Some(value) = files.get(&key) { | ||
| Some(*value) | ||
| } else { | ||
| let file = std::fs::read(key).ok()?; |
There was a problem hiding this comment.
need to check the file name against the command line argument list
| let comptime_files = tcx.caches.experimental_comptime_files.borrow(); | ||
| let comptime_files = | ||
| comptime_files.iter().map(|(k, v)| ((*k).clone(), v.to_vec())).collect::<Vec<_>>(); |
There was a problem hiding this comment.
can iterate the command line list here and call the query on each entry
| let comptime_files = | ||
| comptime_files.iter().map(|(k, v)| ((*k).clone(), v.to_vec())).collect::<Vec<_>>(); | ||
|
|
||
| // Should I somehow sort by filename here in case this does *anything* with the parallel frontend stuff or something? |
There was a problem hiding this comment.
if the list comes from the CLI that isn't necessary, unless you wanna do a binary search instead of using a LazyTable (which may be sufficiently fast for small lists, and still ok for long lists, compared to the lazy table hash lookup)
|
Reminder, once the PR becomes ready for a review, use |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Connected to tracking issue: #146922
r? @oli-obk
#goals/reflection > Reading files at comptime