From b05b617601f577b31305358a3f96c767558274d4 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Fri, 2 Jun 2023 15:24:40 +0200 Subject: [PATCH] Bump Rust version to 1.70.0 (#11344) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * `cargo clippy --fix` * use `map_while` instead of `filter_map` - `filter_map()` will run forever if the iterator repeatedly produces an `Err` ``` ❯ cargo clippy Checking tailwindcss-oxide v0.1.0 (/Users/robin/github.com/tailwindlabs/tailwindcss/oxide/crates/cli) warning: `filter_map()` will run forever if the iterator repeatedly produces an `Err` --> crates/cli/src/main.rs:108:14 | 108 | .filter_map(Result::ok) | ^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error --> crates/cli/src/main.rs:106:9 | 106 | / read_lines(path) 107 | | .unwrap() | |_____________________^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#lines_filter_map_ok = note: `#[warn(clippy::lines_filter_map_ok)]` on by default warning: `tailwindcss-oxide` (bin "tailwindcss-oxide") generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 0.13s ``` * log used versions of all the tools we are using * ensure we install Rust --- .github/workflows/ci.yml | 14 ++++++++++++++ .github/workflows/integration-tests.yml | 14 ++++++++++++++ .github/workflows/prepare-release.yml | 14 ++++++++++++++ oxide/crates/cli/src/main.rs | 2 +- .../crates/core/benches/parse_candidate_strings.rs | 1 - oxide/crates/core/src/candidate.rs | 1 - oxide/crates/core/src/glob.rs | 1 - oxide/crates/core/src/lib.rs | 4 ++-- oxide/crates/core/src/parser.rs | 4 ++-- 9 files changed, 47 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5488096e3..0241a67b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,20 @@ jobs: - name: Install dependencies run: npm install + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + + - name: Check versions + run: | + echo "Node:" `node --version` + echo "NPM:" `npm --version` + echo "Rust:" `rustc --version` + echo "Cargo:" `cargo --version` + - name: Build Tailwind CSS run: npx turbo run build --filter=// diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 722a08ad3..3fd0f3f33 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -73,6 +73,20 @@ jobs: - name: Install dependencies run: npm install + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + + - name: Check versions + run: | + echo "Node:" `node --version` + echo "NPM:" `npm --version` + echo "Rust:" `rustc --version` + echo "Cargo:" `cargo --version` + - name: Build Tailwind CSS run: npx turbo run build --filter=// diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 2ad36d3dd..af5ef0be7 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -53,6 +53,20 @@ jobs: - name: Install dependencies run: npm install + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + + - name: Check versions + run: | + echo "Node:" `node --version` + echo "NPM:" `npm --version` + echo "Rust:" `rustc --version` + echo "Cargo:" `cargo --version` + - name: Build Tailwind CSS run: npm run build diff --git a/oxide/crates/cli/src/main.rs b/oxide/crates/cli/src/main.rs index cda7c48aa..767d440ae 100644 --- a/oxide/crates/cli/src/main.rs +++ b/oxide/crates/cli/src/main.rs @@ -105,7 +105,7 @@ fn main() -> Result<(), std::io::Error> { let candidates = content_paths.par_bridge().flat_map(|path| { read_lines(path) .unwrap() - .filter_map(Result::ok) + .map_while(Result::ok) .par_bridge() .flat_map_iter(|line| { Extractor::unique(line.as_bytes(), Default::default()) diff --git a/oxide/crates/core/benches/parse_candidate_strings.rs b/oxide/crates/core/benches/parse_candidate_strings.rs index 7db451000..16672f058 100644 --- a/oxide/crates/core/benches/parse_candidate_strings.rs +++ b/oxide/crates/core/benches/parse_candidate_strings.rs @@ -11,7 +11,6 @@ pub fn criterion_benchmark(c: &mut Criterion) { let mut all_files: Vec<(u64, PathBuf)> = std::fs::read_dir(fixtures_path) .unwrap() - .into_iter() .filter_map(Result::ok) .map(|dir_entry| dir_entry.path()) .filter(|path| path.is_file()) diff --git a/oxide/crates/core/src/candidate.rs b/oxide/crates/core/src/candidate.rs index b77ace8b2..3a608a152 100644 --- a/oxide/crates/core/src/candidate.rs +++ b/oxide/crates/core/src/candidate.rs @@ -22,7 +22,6 @@ impl Candidate { x == ':' && !in_arbitrary } }) - .into_iter() .collect::>(); let utility = match parts.pop() { diff --git a/oxide/crates/core/src/glob.rs b/oxide/crates/core/src/glob.rs index f9e355075..f0ed8ab71 100644 --- a/oxide/crates/core/src/glob.rs +++ b/oxide/crates/core/src/glob.rs @@ -12,7 +12,6 @@ pub fn fast_glob( .follow_links(true) .build() .unwrap() - .into_iter() .filter_map(Result::ok) .map(|file| file.path().to_path_buf()) })) diff --git a/oxide/crates/core/src/lib.rs b/oxide/crates/core/src/lib.rs index 6d6202895..858e17a2d 100644 --- a/oxide/crates/core/src/lib.rs +++ b/oxide/crates/core/src/lib.rs @@ -43,7 +43,7 @@ pub fn resolve_content_paths(args: ContentPathInfo) -> Vec { let root = Path::new(&args.base); let allowed_paths = FxHashSet::from_iter( - WalkBuilder::new(&root) + WalkBuilder::new(root) .hidden(false) .filter_entry(|entry| match entry.file_type() { Some(file_type) if file_type.is_dir() => entry @@ -94,7 +94,7 @@ pub fn resolve_content_paths(args: ContentPathInfo) -> Vec { // Collect all valid paths from the root. This will already filter out ignored files, unknown // extensions and binary files. - let mut it = WalkDir::new(&root) + let mut it = WalkDir::new(root) // Sorting to make sure that we always see the directories before the files. Also sorting // alphabetically by default. .sort_by( diff --git a/oxide/crates/core/src/parser.rs b/oxide/crates/core/src/parser.rs index 372758e8e..acee57022 100644 --- a/oxide/crates/core/src/parser.rs +++ b/oxide/crates/core/src/parser.rs @@ -31,13 +31,13 @@ pub struct Extractor<'a> { impl<'a> Extractor<'a> { pub fn all(input: &'a [u8], opts: ExtractorOptions) -> Vec<&'a [u8]> { - Self::new(input, opts).into_iter().collect() + Self::new(input, opts).collect() } pub fn unique(input: &'a [u8], opts: ExtractorOptions) -> FxHashSet<&'a [u8]> { let mut candidates: FxHashSet<&[u8]> = Default::default(); candidates.reserve(100); - candidates.extend(Self::new(input, opts).into_iter()); + candidates.extend(Self::new(input, opts)); candidates }