Skip to content

Commit 806848a

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Avoid gazebo str_pattern_extensions
Summary: It requires nightly. Reviewed By: bobyangyf Differential Revision: D41091687 fbshipit-source-id: ef131c629490adfe68f3f2a42cf87aab6d20fe51
1 parent e0df577 commit 806848a

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

starlark/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ memoffset = "0.6.4"
3535
thiserror = "1.0.36"
3636
starlark_derive = { version = "0.9.0-pre", path = "../starlark_derive" }
3737
starlark_map = { version = "0.9.0-pre", path = "../starlark_map" }
38-
gazebo = { workspace = true, features = ["str_pattern_extensions"] }
3938
gazebo_lint.version = "0.1"
4039
gazebo_lint.optional = true
4140
# @oss-disable: gazebo_lint.path = "../../gazebo_lint/gazebo_lint"
41+
gazebo = { workspace = true }
4242
walkdir = "2.3"
4343
serde = { version = "1.0", features = ["derive"] }
4444
logos = "0.12"

starlark/bin/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ fn main() -> anyhow::Result<()> {
221221
let ext = args
222222
.extension
223223
.as_ref()
224-
.map_or("bzl", |x| x.as_str())
225-
.trim_start_match('.');
224+
.map_or("bzl", |x| x.strip_prefix('.').unwrap_or(x.as_str()));
226225
let mut ctx = Context::new(
227226
if args.check {
228227
ContextMode::Check

starlark/src/analysis/names.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use std::collections::HashMap;
1919
use std::collections::HashSet;
2020

21-
use gazebo::prelude::*;
2221
use gazebo::variants::VariantName;
2322
use thiserror::Error;
2423

@@ -279,7 +278,7 @@ fn use_ignored(
279278
let defined_at_root =
280279
|| root.bound.contains_key(&x.node) && scope.free.contains_key(&x.node);
281280
let shadows = || {
282-
let suffix = x.trim_start_match('_');
281+
let suffix = &x[1..];
283282
scope.free.contains_key(suffix) || scope.bound.contains_key(suffix)
284283
};
285284
if !defined_at_root() && !shadows() {
@@ -300,6 +299,8 @@ fn use_ignored(
300299

301300
#[cfg(test)]
302301
mod tests {
302+
use gazebo::prelude::*;
303+
303304
use super::*;
304305
use crate::syntax::Dialect;
305306

starlark/src/assert/conformance.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
// We want to carefully control the panic message.
2424
#![allow(clippy::if_then_panic)]
2525

26-
use gazebo::prelude::*;
2726
use itertools::Itertools;
2827

2928
use crate::assert::assert::Assert;
@@ -78,7 +77,12 @@ impl ConformanceTest {
7877
error: xs
7978
.iter()
8079
.find_position(|x| x.contains("###"))
81-
.map(|(i, x)| (i + 1, (**x).split1("###").1.trim_start().to_owned())),
80+
.map(|(i, x)| {
81+
(
82+
i + 1,
83+
(**x).split_once("###").unwrap().1.trim_start().to_owned(),
84+
)
85+
}),
8286
})
8387
.collect()
8488
}

0 commit comments

Comments
 (0)