Merge pull request #1333 from tmccombs/rust-170
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Rust 1.70 upgrade
authored by Thayne McCombs · committed by GitHub · parents d6e9cbf, 740edeb · Browse files · 6 files·+17 added−39 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+17 added−39 removed
- other:+17 added−39 removed
Provenance
- Commit
a0370aa- Tree
bde6642- Author
Thayne McCombs <astrothayne@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
d6e9cbf- Parent 2
740edeb
6 files changed+17 added−39 removed
modified:src/exec/mod.rs+6 added-5 removed
7 unmodified lines8 use std::io;9 use std::iter;10 use std::path::{Component, Path, PathBuf, Prefix};11 use std::process::Stdio;12-use std::sync::Mutex;12+use std::sync::{Mutex, OnceLock};13 14 use anyhow::{bail, Result};15 use argmax::Command;16-use once_cell::sync::Lazy;16 use regex::Regex;17 18 use crate::exit_codes::{merge_exitcodes, ExitCode};19 209 unmodified lines229 where230 I: IntoIterator<Item = S>,231 S: AsRef<str>,232 {234- static PLACEHOLDER_PATTERN: Lazy<Regex> =235- Lazy::new(|| Regex::new(r"\{(/?\.?|//)\}").unwrap());233+ static PLACEHOLDER_PATTERN: OnceLock<Regex> = OnceLock::new();234 235 let mut args = Vec::new();236 let mut has_placeholder = false;237 2 unmodified lines240 241 let mut tokens = Vec::new();242 let mut start = 0;243 244+ let pattern =245+ PLACEHOLDER_PATTERN.get_or_init(|| Regex::new(r"\{(/?\.?|//)\}").unwrap());246+246- for placeholder in PLACEHOLDER_PATTERN.find_iter(arg) {247+ for placeholder in pattern.find_iter(arg) {248 // Leading text before the placeholder.249 if placeholder.start() > start {250 tokens.push(Token::Text(arg[start..placeholder.start()].to_owned()));251 }346 unmodified linesmodified:src/filter/size.rs+7 added-5 removed
1+use std::sync::OnceLock;2+3 use anyhow::anyhow;2-use once_cell::sync::Lazy;4 use regex::Regex;5 5-static SIZE_CAPTURES: Lazy<Regex> =6- Lazy::new(|| Regex::new(r"(?i)^([+-]?)(\d+)(b|[kmgt]i?b?)$").unwrap());6+static SIZE_CAPTURES: OnceLock<Regex> = OnceLock::new();7 8 #[derive(Clone, Copy, Debug, PartialEq, Eq)]9 pub enum SizeFilter {10 Max(u64),19 unmodified lines30 .ok_or_else(|| anyhow!("'{}' is not a valid size constraint. See 'fd --help'.", s))31 }32 33 fn parse_opt(s: &str) -> Option<Self> {34+ let pattern =35+ SIZE_CAPTURES.get_or_init(|| Regex::new(r"(?i)^([+-]?)(\d+)(b|[kmgt]i?b?)$").unwrap());34- if !SIZE_CAPTURES.is_match(s) {36+ if !pattern.is_match(s) {37 return None;38 }39 38- let captures = SIZE_CAPTURES.captures(s)?;40+ let captures = pattern.captures(s)?;41 let limit_kind = captures.get(1).map_or("+", |m| m.as_str());42 let quantity = captures43 .get(2)44 .and_then(|v| v.as_str().parse::<u64>().ok())?;175 unmodified linesmodified:src/dir_entry.rs+1 added-2 removed
1+use std::cell::OnceCell;2 use std::ffi::OsString;3 use std::fs::{FileType, Metadata};4 use std::path::{Path, PathBuf};5 6 use lscolors::{Colorable, LsColors, Style};7 7-use once_cell::unsync::OnceCell;8-8 use crate::config::Config;9 use crate::filesystem::strip_current_dir;10 11 enum DirEntryInner {142 unmodified linesmodified:src/main.rs+2 added-2 removed
10 unmodified lines11 mod regex_helper;12 mod walk;13 14 use std::env;15+use std::io::IsTerminal;16 use std::path::Path;17 use std::sync::Arc;18 use std::time;19 20 use anyhow::{anyhow, bail, Context, Result};20-use atty::Stream;21 use clap::{CommandFactory, Parser};22 use globset::GlobBuilder;23 use lscolors::LsColors;24 use regex::bytes::{Regex, RegexBuilder, RegexSetBuilder};191 unmodified lines216 nu_ansi_term::enable_ansi_support().is_ok() || std::env::var_os("TERM").is_some();217 #[cfg(not(windows))]218 let ansi_colors_support = true;219 220- let interactive_terminal = atty::is(Stream::Stdout);220+ let interactive_terminal = std::io::stdout().is_terminal();221 let colored_output = match opts.color {222 ColorWhen::Always => true,223 ColorWhen::Never => false,224 ColorWhen::Auto => {247 unmodified linesmodified:Cargo.lock-22 removed
36 unmodified lines37 "nix 0.24.3",38 ]39 40 [[package]]41-name = "atty"42-version = "0.2.14"43-source = "registry+https://github.com/rust-lang/crates.io-index"44-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"45-dependencies = [46- "hermit-abi 0.1.19",47- "libc",48- "winapi",49-]50-51-[[package]]41 name = "autocfg"42 version = "1.1.0"43 source = "registry+https://github.com/rust-lang/crates.io-index"44 checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"270 unmodified lines315 version = "8.7.0"316 dependencies = [317 "anyhow",318 "argmax",330- "atty",319 "chrono",320 "clap",321 "clap_complete",322 "crossbeam-channel",11 unmodified lines334 "nix 0.26.2",335 "normpath",336 "nu-ansi-term",337 "num_cpus",350- "once_cell",338 "regex",339 "regex-syntax",340 "tempfile",341 "test-case",50 unmodified lines392 checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"393 394 [[package]]395 name = "hermit-abi"409-version = "0.1.19"410-source = "registry+https://github.com/rust-lang/crates.io-index"411-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"412-dependencies = [413- "libc",414-]415-416-[[package]]417-name = "hermit-abi"396 version = "0.2.6"397 source = "registry+https://github.com/rust-lang/crates.io-index"398 checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"399 dependencies = [784 unmodified linesmodified:Cargo.toml+1 added-3 removed
16 unmodified lines171819202121222324259 unmodified lines3536373839394041422 unmodified lines45464748504950515243 unmodified lines16 unmodified linesreadme = "README.md"repository = "https://github.com/sharkdp/fd"version = "8.7.0"edition= "2021"rust-version = "1.67.0"rust-version = "1.70.0"
[badges.appveyor]repository = "sharkdp/fd"
9 unmodified lines
[dependencies]nu-ansi-term = "0.47"argmax = "0.3.1"atty = "0.2"ignore = "0.4.20"num_cpus = "1.15"regex = "1.7.3"regex-syntax = "0.6"2 unmodified linesglobset = "0.4"anyhow = "1.0"dirs-next = "2.0"normpath = "1.1.1"once_cell = "1.17.2"crossbeam-channel = "0.5.8"clap_complete = {version = "4.3.0", optional = true}faccess = "0.2.4"
43 unmodified lines