Skip to content

Commit db35df7

Browse files
committed
comment on _no_rule_target_rewrite!
1 parent a66f5e7 commit db35df7

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/rule_definition_tools.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -440,16 +440,7 @@ macro opt_out(expr)
440440
end
441441
end
442442

443-
function _no_rule_target_rewrite!(call_target::Symbol)
444-
return if call_target == :rrule
445-
:(ChainRulesCore.no_rrule)
446-
elseif call_target == :frule
447-
:(ChainRulesCore.no_frule)
448-
else
449-
error("Unexpected opt-out target. Exprected frule or rrule, got: $call_target")
450-
end
451-
end
452-
_no_rule_target_rewrite!(qt::QuoteNode) = _no_rule_target_rewrite!(qt.value)
443+
"Rewrite method sig Expr for `rrule` to be for `no_rrule`, and `frule` to be `no_frule`."
453444
function _no_rule_target_rewrite!(expr::Expr)
454445
length(expr.args)===0 && error("Malformed method expression. $expr")
455446
if expr.head === :call || expr.head === :where
@@ -461,6 +452,17 @@ function _no_rule_target_rewrite!(expr::Expr)
461452
end
462453
return expr
463454
end
455+
_no_rule_target_rewrite!(qt::QuoteNode) = _no_rule_target_rewrite!(qt.value)
456+
function _no_rule_target_rewrite!(call_target::Symbol)
457+
return if call_target == :rrule
458+
:(ChainRulesCore.no_rrule)
459+
elseif call_target == :frule
460+
:(ChainRulesCore.no_frule)
461+
else
462+
error("Unexpected opt-out target. Exprected frule or rrule, got: $call_target")
463+
end
464+
end
465+
464466

465467

466468
############################################################################################

0 commit comments

Comments
 (0)