@@ -116,8 +116,15 @@ impl<'v> QueryContext<'v> {
116
116
///
117
117
/// (Use the index with [`QueryContext::get_condition`])
118
118
pub fn add_condition ( & mut self , condition : & ( impl Condition < ' v > + ?Sized ) ) -> usize {
119
+ condition. build ( ConditionBuilder {
120
+ context : self ,
121
+ only_accept_paths : true ,
122
+ } ) ;
119
123
let index = self . conditions . len ( ) ;
120
- condition. build ( ConditionBuilder { context : self } ) ;
124
+ condition. build ( ConditionBuilder {
125
+ context : self ,
126
+ only_accept_paths : false ,
127
+ } ) ;
121
128
self . span . in_scope ( || {
122
129
trace ! (
123
130
condition = ?self . conditions. get( index..) ,
@@ -411,22 +418,32 @@ impl QueryContext<'_> {
411
418
/// A [`&mut QueryContext`] with restricted API which is passed to [`Condition::build`]
412
419
pub struct ConditionBuilder < ' r , ' v > {
413
420
context : & ' r mut QueryContext < ' v > ,
421
+ only_accept_paths : bool ,
414
422
}
415
423
416
424
impl < ' v > ConditionBuilder < ' _ , ' v > {
417
425
pub ( crate ) fn reborrow < ' r > ( & ' r mut self ) -> ConditionBuilder < ' r , ' v > {
418
426
ConditionBuilder :: < ' r , ' v > {
419
427
context : & mut * self . context ,
428
+ only_accept_paths : self . only_accept_paths ,
420
429
}
421
430
}
422
431
423
432
pub ( crate ) fn push_condition ( & mut self , condition : FlatCondition ) -> usize {
433
+ if self . only_accept_paths {
434
+ return usize:: MAX ;
435
+ }
436
+
424
437
let index = self . context . conditions . len ( ) ;
425
438
self . context . conditions . push ( condition) ;
426
439
index
427
440
}
428
441
429
442
pub ( crate ) fn pop_condition ( & mut self ) {
443
+ if self . only_accept_paths {
444
+ return ;
445
+ }
446
+
430
447
self . context . conditions . pop ( ) ;
431
448
}
432
449
@@ -435,6 +452,10 @@ impl<'v> ConditionBuilder<'_, 'v> {
435
452
}
436
453
437
454
pub ( crate ) fn push_value ( & mut self , value : Value < ' v > ) -> usize {
455
+ if self . only_accept_paths {
456
+ return usize:: MAX ;
457
+ }
458
+
438
459
let index = self . context . values . len ( ) ;
439
460
self . context . values . push ( value) ;
440
461
index
0 commit comments