@@ -62,25 +62,18 @@ use crate::sync::OnceLock;
62
62
/// Should only be relevant in case of a badly configured cycle recovery.
63
63
pub const MAX_ITERATIONS : IterationCount = IterationCount ( 200 ) ;
64
64
65
- pub struct UnexpectedCycle ( Option < crate :: Backtrace > ) ;
66
-
67
- impl fmt:: Debug for UnexpectedCycle {
68
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
69
- f. write_str ( "cycle detected but no cycle handler found" ) ?;
70
- if let Some ( backtrace) = & self . 0 {
71
- f. write_str ( ": " ) ?;
72
- backtrace. fmt ( f) ?;
73
- }
74
- Ok ( ( ) )
75
- }
65
+ pub struct UnexpectedCycle {
66
+ backtrace : std:: backtrace:: Backtrace ,
67
+ query_trace : Option < crate :: Backtrace > ,
76
68
}
77
69
78
70
impl fmt:: Display for UnexpectedCycle {
79
71
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
80
- f. write_str ( "cycle detected but no cycle handler found" ) ?;
81
- if let Some ( backtrace) = & self . 0 {
72
+ f. write_str ( "cycle detected but no cycle handler found\n " ) ?;
73
+ self . backtrace . fmt ( f) ?;
74
+ if let Some ( query_trace) = & self . query_trace {
82
75
f. write_str ( "\n " ) ?;
83
- backtrace . fmt ( f) ?;
76
+ query_trace . fmt ( f) ?;
84
77
}
85
78
Ok ( ( ) )
86
79
}
@@ -89,8 +82,11 @@ impl fmt::Display for UnexpectedCycle {
89
82
impl UnexpectedCycle {
90
83
pub ( crate ) fn throw ( ) -> ! {
91
84
// We use resume and not panic here to avoid running the panic
92
- // hook (that is, to avoid collecting and printing backtrace).
93
- panic:: resume_unwind ( Box :: new ( Self ( crate :: Backtrace :: capture ( ) ) ) ) ;
85
+ // hook (that is to avoid printing the backtrace).
86
+ panic:: resume_unwind ( Box :: new ( Self {
87
+ backtrace : std:: backtrace:: Backtrace :: capture ( ) ,
88
+ query_trace : crate :: Backtrace :: capture ( ) ,
89
+ } ) ) ;
94
90
}
95
91
96
92
/// Runs `f`, and catches any salsa cycle.
0 commit comments