diff --git a/mordant-baseline.toml b/mordant-baseline.toml index 6d22d0f04b30..387a65337e48 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] 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] {