From 4a3670aec100f1f8599d71c7f52cea9811fa498e Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sat, 15 Aug 2026 17:06:12 +0000 Subject: [PATCH] ast: name BabyString::r#in's parameters for what they are r#in(parent, text) locates `text` inside `parent`, so every caller passes its message text as `parent`, which mordant's arg_named_like_other_param flags as a possibly transposed call. The calls are in the right order; only the parameter names were misleading. Rename them to `container` and `substring`, matching BabyString::slice. No behavior change. Regenerate mordant-baseline.toml. Besides the entry this fixes, it drops two that were already stale: the PackageInstall.rs Option removed in #38271 and the node_crypto_binding.rs narrowing removed in #37648, both of which landed after the baseline was recorded. --- mordant-baseline.toml | 3 --- src/ast/lib.rs | 14 ++++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mordant-baseline.toml b/mordant-baseline.toml index 109483f7b029..d6f8812102c7 100644 --- a/mordant-baseline.toml +++ b/mordant-baseline.toml @@ -1,5 +1,4 @@ [bun_ast] -"arg_named_like_other_param:src/ast/lib.rs" = 1 "bare_bool_args:src/ast/lib.rs" = 1 [bun_bundler] @@ -18,7 +17,6 @@ "tuple_wants_struct:src/css/values/color.rs" = 5 [bun_install] -"always_unwrapped_option:src/install/PackageInstall.rs" = 1 "arg_named_like_other_param:src/install/PackageManager/PackageJSONEditor.rs" = 3 "arg_named_like_other_param:src/install/resolution.rs" = 1 "bare_bool_args:src/install/isolated_install.rs" = 1 @@ -69,7 +67,6 @@ "error_collapsed_to_bool:src/runtime/ffi/ffi_body.rs" = 1 "field_valid_only_when:src/runtime/cli/filter_run.rs" = 1 "field_valid_only_when:src/runtime/shell/builtin/rm.rs" = 1 -"narrowed_two_ways:src/runtime/node/node_crypto_binding.rs" = 1 "parallel_vecs:src/runtime/api/html_rewriter.rs" = 1 "parallel_vecs:src/runtime/bake/dev_server/incremental_graph.rs" = 1 "reimplemented_helper:src/runtime/api/bun/Terminal.rs" = 1 diff --git a/src/ast/lib.rs b/src/ast/lib.rs index a7e8f91cb162..6318a8584fb2 100644 --- a/src/ast/lib.rs +++ b/src/ast/lib.rs @@ -1077,15 +1077,17 @@ impl BabyString { (self.0 >> 16) as u16 } - pub fn r#in(parent: &[u8], text: &[u8]) -> BabyString { + /// Locates `substring` inside `container` (the string later passed to + /// [`BabyString::slice`]) and records its offset and length. + pub fn r#in(container: &[u8], substring: &[u8]) -> BabyString { // bun_core::strings::index_of deliberately returns None for an empty - // needle, but an empty `text` reaches this path via resolve errors for - // `import ""`, so short-circuit it here to offset 0. - if text.is_empty() { + // needle, but an empty `substring` reaches this path via resolve errors + // for `import ""`, so short-circuit it here to offset 0. + if substring.is_empty() { return BabyString::new(0, 0); } - let off = bun_core::strings::index_of(parent, text).expect("unreachable"); - BabyString::new(off as u16, text.len() as u16) // @truncate + let off = bun_core::strings::index_of(container, substring).expect("unreachable"); + BabyString::new(off as u16, substring.len() as u16) // @truncate } pub fn slice<'a>(self, container: &'a [u8]) -> &'a [u8] {