From c3d6ce4f6dc86ea5dd712cd89f7ff9abec2439b4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:41:46 +0200 Subject: [PATCH] subscriber: correct spans in Directive::parse `i` refers to `from.trim()` but `from` is used when indexing. --- tracing-subscriber/src/filter/env/directive.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tracing-subscriber/src/filter/env/directive.rs b/tracing-subscriber/src/filter/env/directive.rs index 0b9ffc4c00..97c06597cc 100644 --- a/tracing-subscriber/src/filter/env/directive.rs +++ b/tracing-subscriber/src/filter/env/directive.rs @@ -139,7 +139,8 @@ impl Directive { use ParseState::*; let mut state = Start; - for (i, c) in from.trim().char_indices() { + let from = from.trim(); + for (i, c) in from.char_indices() { state = match (state, c) { (Start, '[') => Span { span_start: i + 1 }, (Start, c) if !['-', ':', '_'].contains(&c) && !c.is_alphanumeric() => {