-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Add per query cycle handlers and use them for representability #153028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,8 @@ use crate::dep_graph; | |
| use crate::dep_graph::{DepKind, DepNodeIndex, SerializedDepNodeIndex}; | ||
| use crate::ich::StableHashingContext; | ||
| use crate::queries::{ | ||
| ExternProviders, PerQueryVTables, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates, | ||
| CycleHandlers, ExternProviders, PerQueryVTables, Providers, QueryArenas, QueryCaches, | ||
| QueryEngine, QueryStates, | ||
| }; | ||
| use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache}; | ||
| use crate::query::stack::{QueryStackDeferred, QueryStackFrame, QueryStackFrameExtra}; | ||
|
|
@@ -146,6 +147,7 @@ pub struct QuerySystemFns { | |
| pub engine: QueryEngine, | ||
| pub local_providers: Providers, | ||
| pub extern_providers: ExternProviders, | ||
| pub cycle_handlers: CycleHandlers, | ||
| pub encode_query_results: for<'tcx> fn( | ||
| tcx: TyCtxt<'tcx>, | ||
| encoder: &mut CacheEncoder<'_, 'tcx>, | ||
|
|
@@ -565,6 +567,18 @@ macro_rules! define_callbacks { | |
| fn clone(&self) -> Self { *self } | ||
| } | ||
|
|
||
| #[derive(Default)] | ||
| pub struct CycleHandlers { | ||
| $( | ||
| pub $name: Option<fn(TyCtxt<'_>, &$crate::query::CycleError) -> Option<ErrorGuaranteed>>, | ||
| )* | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be put into |
||
|
|
||
| impl Copy for CycleHandlers {} | ||
| impl Clone for CycleHandlers { | ||
| fn clone(&self) -> Self { *self } | ||
| } | ||
|
|
||
| pub struct QueryEngine { | ||
| $( | ||
| pub $name: for<'tcx> fn( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ use std::marker::ConstParamTy; | |
| use rustc_data_structures::sync::AtomicU64; | ||
| use rustc_middle::dep_graph::{self, DepKind, DepNode, DepNodeIndex, SerializedDepNodeIndex}; | ||
| use rustc_middle::queries::{ | ||
| self, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates, | ||
| self, CycleHandlers, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates, | ||
| }; | ||
| use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache}; | ||
| use rustc_middle::query::plumbing::{ | ||
|
|
@@ -239,6 +239,7 @@ trait QueryDispatcherUnerased<'tcx, C: QueryCache, const FLAGS: QueryFlags> { | |
| pub fn query_system<'tcx>( | ||
| local_providers: Providers, | ||
| extern_providers: ExternProviders, | ||
| cycle_decor_providers: CycleHandlers, | ||
| on_disk_cache: Option<OnDiskCache>, | ||
| incremental: bool, | ||
| ) -> QuerySystem<'tcx> { | ||
|
|
@@ -252,6 +253,7 @@ pub fn query_system<'tcx>( | |
| engine: engine(incremental), | ||
| local_providers, | ||
| extern_providers, | ||
| cycle_handlers: cycle_decor_providers, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type is called |
||
| encode_query_results: encode_all_query_results, | ||
| try_mark_green, | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be
check_representableor sth now