From e66476015be1899678fb3dc0b0b00184d832e2b7 Mon Sep 17 00:00:00 2001 From: Shon Feder Date: Sat, 7 Jun 2025 10:56:56 -0400 Subject: [PATCH] Move deprecation alerts to valid location As discussed in https://github.com/ocaml/ocaml/issues/14078, alerts (with deprecation alerts as a special case) are not currently supported as item-attributes on let-bindings. This usage produces `misplaced-attribute` warnings, such as ``` Warning 53 [misplaced-attribute]: the "deprecated" attribute cannot appear in this context File "src/core/opentelemetry.ml", line 1229, characters 37-47: 1229 | let add_event = Scope.add_event [@@deprecated "use Scope.add_event"] ^^^^^^^^^^ Warning 53 [misplaced-attribute]: the "deprecated" attribute cannot appear in this context File "src/core/opentelemetry.ml", line 1231, characters 37-47: 1231 | let add_attrs = Scope.add_attrs [@@deprecated "use Scope.add_attrs"] ^^^^^^^^^^ Warning 53 [misplaced-attribute]: the "deprecated" attribute cannot appear in this context ``` Fortunately, we can still add deprecation alerts to these value by moving the alert to the pattern, as done here. --- src/core/opentelemetry.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/opentelemetry.ml b/src/core/opentelemetry.ml index 5d80d1fa..e494ea88 100644 --- a/src/core/opentelemetry.ml +++ b/src/core/opentelemetry.ml @@ -1226,9 +1226,9 @@ module Trace = struct } [@@deprecated "use Scope.t"] - let add_event = Scope.add_event [@@deprecated "use Scope.add_event"] + let (add_event [@deprecated "use Scope.add_event"]) = Scope.add_event - let add_attrs = Scope.add_attrs [@@deprecated "use Scope.add_attrs"] + let (add_attrs [@deprecated "use Scope.add_attrs"]) = Scope.add_attrs let with_' ?(force_new_trace_id = false) ?trace_state ?service_name ?(attrs : (string * [< value ]) list = []) ?kind ?trace_id ?parent ?scope