Change MSRV to 1.46.0 (#968)

This commit is contained in:
Casey Rodarmor 2021-09-16 17:51:45 +03:00 committed by GitHub
parent 629c75ff04
commit 09af9bb5e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 44 additions and 93 deletions

2
Cargo.lock generated
View File

@ -1,7 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "0.7.18"

View File

@ -11,7 +11,6 @@ edition = "2018"
autotests = false
categories = ["command-line-utilities", "development-tools"]
keywords = ["command-line", "task", "runner", "development", "utility"]
resolver = "2"
[workspace]
members = [".", "bin/ref-type"]

View File

@ -1661,6 +1661,10 @@ https://github.com/casey/janus[Janus] is a tool that collects and analyzes justf
Before merging a particularly large or gruesome change, Janus should be run to make sure that nothing breaks. Don't worry about running Janus yourself, Casey will happily run it for you on changes that need it.
=== Minimum Supported Rust Version
The minimum supported Rust version, or MSRV, can be found in link:rust-toolchain[].
== Frequently Asked Questions
=== What are the idiosyncrasies of Make that Just avoids?

View File

@ -1 +1 @@
1.52.1
1.46.0

View File

@ -466,10 +466,7 @@ impl Config {
overrides,
}
} else if let Some(values) = matches.values_of_os(cmd::COMMAND) {
let mut arguments = values
.into_iter()
.map(OsStr::to_owned)
.collect::<Vec<OsString>>();
let mut arguments = values.map(OsStr::to_owned).collect::<Vec<OsString>>();
Subcommand::Command {
binary: arguments.remove(0),
arguments,

View File

@ -257,12 +257,7 @@ impl<'src> Lexer<'src> {
/// True if `text` could be an identifier
pub(crate) fn is_identifier(text: &str) -> bool {
if !text
.chars()
.next()
.map(Self::is_identifier_start)
.unwrap_or(false)
{
if !text.chars().next().map_or(false, Self::is_identifier_start) {
return false;
}
@ -496,11 +491,9 @@ impl<'src> Lexer<'src> {
'}' => self.lex_delimiter(BraceR),
'+' => self.lex_single(Plus),
'#' => self.lex_comment(),
' ' => self.lex_whitespace(),
' ' | '\t' => self.lex_whitespace(),
'`' | '"' | '\'' => self.lex_string(),
'\n' => self.lex_eol(),
'\r' => self.lex_eol(),
'\t' => self.lex_whitespace(),
'\n' | '\r' => self.lex_eol(),
_ if Self::is_identifier_start(start) => self.lex_identifier(),
_ => {
self.advance()?;

View File

@ -1,43 +1,14 @@
#![deny(clippy::all, clippy::pedantic, clippy::restriction)]
#![deny(clippy::all, clippy::pedantic)]
#![allow(
clippy::blanket_clippy_restriction_lints,
clippy::comparison_chain,
clippy::create_dir,
clippy::default_numeric_fallback,
clippy::else_if_without_else,
clippy::enum_glob_use,
clippy::exhaustive_enums,
clippy::exhaustive_structs,
clippy::expect_used,
clippy::filter_map,
clippy::if_not_else,
clippy::implicit_return,
clippy::indexing_slicing,
clippy::integer_arithmetic,
clippy::let_underscore_must_use,
clippy::map_unwrap_or,
clippy::match_same_arms,
clippy::missing_docs_in_private_items,
clippy::missing_errors_doc,
clippy::missing_inline_in_public_items,
clippy::needless_lifetimes,
clippy::needless_pass_by_value,
clippy::non_ascii_literal,
clippy::option_if_let_else,
clippy::panic,
clippy::panic_in_result_fn,
clippy::pattern_type_mismatch,
clippy::print_stdout,
clippy::shadow_unrelated,
clippy::string_add,
clippy::struct_excessive_bools,
clippy::too_many_lines,
clippy::unnecessary_wraps,
clippy::unreachable,
clippy::unwrap_in_result,
clippy::unwrap_used,
clippy::use_debug,
clippy::wildcard_enum_match_arm,
clippy::wildcard_imports
)]

View File

@ -48,8 +48,7 @@ fn load_from_file(
&& config.dotenv_filename.is_none()
&& config.dotenv_path.is_none()
&& !std::env::var_os("JUST_SUPPRESS_DOTENV_LOAD_WARNING")
.map(|val| val.as_os_str().to_str() == Some("1"))
.unwrap_or(false)
.map_or(false, |val| val.as_os_str().to_str() == Some("1"))
{
eprintln!(
"{}",

View File

@ -637,7 +637,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
Ok(Recipe {
parameters: positional.into_iter().chain(variadic).collect(),
private: name.lexeme().starts_with('_'),
shebang: body.first().map(Line::is_shebang).unwrap_or(false),
shebang: body.first().map_or(false, Line::is_shebang),
priors,
body,
dependencies,
@ -700,7 +700,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
}
}
while lines.last().map(Line::is_empty).unwrap_or(false) {
while lines.last().map_or(false, Line::is_empty) {
lines.pop();
}

View File

@ -75,17 +75,15 @@ impl Positional {
/// Parse an override from a value of the form `NAME=.*`.
fn override_from_value(value: &str) -> Option<(String, String)> {
if let Some(equals) = value.find('=') {
let (identifier, equals_value) = value.split_at(equals);
let equals = value.find('=')?;
// exclude `=` from value
let value = &equals_value[1..];
let (identifier, equals_value) = value.split_at(equals);
if Lexer::is_identifier(identifier) {
Some((identifier.to_owned(), value.to_owned()))
} else {
None
}
// exclude `=` from value
let value = &equals_value[1..];
if Lexer::is_identifier(identifier) {
Some((identifier.to_owned(), value.to_owned()))
} else {
None
}

View File

@ -212,11 +212,8 @@ impl<'src, D> Recipe<'src, D> {
}
let mut evaluated = String::new();
let mut continued = false;
let quiet_command = lines.peek().map(|line| line.is_quiet()).unwrap_or(false);
let infallable_command = lines
.peek()
.map(|line| line.is_infallable())
.unwrap_or(false);
let quiet_command = lines.peek().map_or(false, |line| line.is_quiet());
let infallable_command = lines.peek().map_or(false, |line| line.is_infallable());
loop {
if lines.peek().is_none() {
break;

View File

@ -36,10 +36,8 @@ impl<'src, 'run> Scope<'src, 'run> {
pub(crate) fn value(&self, name: &str) -> Option<&str> {
if let Some(binding) = self.bindings.get(name) {
Some(binding.value.as_ref())
} else if let Some(parent) = self.parent {
parent.value(name)
} else {
None
self.parent?.value(name)
}
}

View File

@ -134,10 +134,10 @@ impl Search {
}
}
if candidates.len() == 1 {
return Ok(candidates.into_iter().next().unwrap());
} else if candidates.len() > 1 {
return Err(SearchError::MultipleCandidates { candidates });
match candidates.len() {
0 => {}
1 => return Ok(candidates.into_iter().next().unwrap()),
_ => return Err(SearchError::MultipleCandidates { candidates }),
}
}

View File

@ -17,9 +17,9 @@ pub(crate) struct Shell<'src> {
impl<'src> Display for Setting<'src> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
match self {
Setting::DotenvLoad(value) => write!(f, "{}", value),
Setting::Export(value) => write!(f, "{}", value),
Setting::PositionalArguments(value) => write!(f, "{}", value),
Setting::DotenvLoad(value) | Setting::Export(value) | Setting::PositionalArguments(value) => {
write!(f, "{}", value)
}
Setting::Shell(shell) => write!(f, "{}", shell),
}
}

View File

@ -33,8 +33,8 @@ impl<'line> Shebang<'line> {
fn interpreter_filename(&self) -> &str {
self
.interpreter
.rsplit_once(|c| matches!(c, '/' | '\\'))
.map(|(_path, filename)| filename)
.split(|c| matches!(c, '/' | '\\'))
.last()
.unwrap_or(self.interpreter)
}

View File

@ -73,9 +73,10 @@ impl Subcommand {
Choose { overrides, chooser } => {
Self::choose(config, justfile, &search, overrides, chooser.as_deref())?;
}
Command { overrides, .. } => justfile.run(config, &search, overrides, &[])?,
Command { overrides, .. } | Evaluate { overrides, .. } => {
justfile.run(config, &search, overrides, &[])?
}
Dump => Self::dump(ast),
Evaluate { overrides, .. } => justfile.run(config, &search, overrides, &[])?,
Format => Self::format(config, ast, &search)?,
List => Self::list(config, justfile),
Run {

View File

@ -43,11 +43,8 @@ impl<'key, V: Keyed<'key>> Table<'key, V> {
}
pub(crate) fn pop(&mut self) -> Option<V> {
if let Some(key) = self.map.keys().next().copied() {
self.map.remove(key)
} else {
None
}
let key = self.map.keys().next().copied()?;
self.map.remove(key)
}
pub(crate) fn remove(&mut self, key: &str) -> Option<V> {

View File

@ -33,8 +33,11 @@ impl<'src> Thunk<'src> {
name: Name<'src>,
mut arguments: Vec<Expression<'src>>,
) -> CompileResult<'src, Thunk<'src>> {
if let Some(function) = crate::function::TABLE.get(&name.lexeme()) {
match (function, arguments.len()) {
crate::function::TABLE.get(&name.lexeme()).map_or(
Err(name.error(CompileErrorKind::UnknownFunction {
function: name.lexeme(),
})),
|function| match (function, arguments.len()) {
(Function::Nullary(function), 0) => Ok(Thunk::Nullary {
function: *function,
name,
@ -68,12 +71,8 @@ impl<'src> Thunk<'src> {
found: arguments.len(),
expected: function.argc(),
})),
}
} else {
Err(name.error(CompileErrorKind::UnknownFunction {
function: name.lexeme(),
}))
}
},
)
}
}