Skip to content

Commit 0d6f912

Browse files
authored
Deny unreachable pub (#3080)
1 parent 3940d95 commit 0d6f912

19 files changed

Lines changed: 88 additions & 94 deletions

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ which = "8.0.0"
6666
[lints.rust]
6767
mismatched_lifetime_syntaxes = "allow"
6868
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
69+
unreachable_pub = "deny"
6970

7071
[lints.clippy]
7172
all = { level = "deny", priority = -1 }
72-
arbitrary-source-item-ordering = "deny"
73+
arbitrary_source_item_ordering = "deny"
7374
enum_glob_use = "allow"
7475
ignore_without_reason = "allow"
7576
needless_pass_by_value = "allow"

src/compile_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl<'src> CompileError<'src> {
1111
self.token
1212
}
1313

14-
pub(crate) fn new(token: Token<'src>, kind: CompileErrorKind<'src>) -> CompileError<'src> {
14+
pub(crate) fn new(token: Token<'src>, kind: CompileErrorKind<'src>) -> Self {
1515
Self {
1616
token,
1717
kind: kind.into(),

src/count.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::*;
22

3-
pub struct Count<T: Display>(pub T, pub usize);
3+
pub(crate) struct Count<T: Display>(pub T, pub usize);
44

55
impl<T: Display> Display for Count<T> {
66
fn fmt(&self, f: &mut Formatter) -> fmt::Result {

src/enclosure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use super::*;
22

3-
pub struct Enclosure<T: Display> {
3+
pub(crate) struct Enclosure<T: Display> {
44
enclosure: &'static str,
55
value: T,
66
}
77

88
impl<T: Display> Enclosure<T> {
9-
pub fn tick(value: T) -> Enclosure<T> {
9+
pub(crate) fn tick(value: T) -> Self {
1010
Self {
1111
enclosure: "`",
1212
value,

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ impl<'src> From<ConstError<'src>> for Error<'src> {
329329
}
330330
}
331331

332-
impl<'src> From<dotenvy::Error> for Error<'src> {
333-
fn from(dotenv_error: dotenvy::Error) -> Error<'src> {
332+
impl From<dotenvy::Error> for Error<'_> {
333+
fn from(dotenv_error: dotenvy::Error) -> Self {
334334
Self::Dotenv { dotenv_error }
335335
}
336336
}

src/expression.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ use super::*;
99
#[derive(PartialEq, Debug, Clone)]
1010
pub(crate) enum Expression<'src> {
1111
/// `lhs && rhs`
12-
And {
13-
lhs: Box<Expression<'src>>,
14-
rhs: Box<Expression<'src>>,
15-
},
12+
And { lhs: Box<Self>, rhs: Box<Self> },
1613
/// `assert(condition, error)`
1714
Assert {
1815
name: Name<'src>,
1916
condition: Condition<'src>,
20-
error: Box<Expression<'src>>,
17+
error: Box<Self>,
2118
},
2219
/// `contents`
2320
Backtick {
@@ -27,33 +24,27 @@ pub(crate) enum Expression<'src> {
2724
/// `name(arguments)`
2825
Call { thunk: Thunk<'src> },
2926
/// `lhs + rhs`
30-
Concatenation {
31-
lhs: Box<Expression<'src>>,
32-
rhs: Box<Expression<'src>>,
33-
},
27+
Concatenation { lhs: Box<Self>, rhs: Box<Self> },
3428
/// `if condition { then } else { otherwise }`
3529
Conditional {
3630
condition: Condition<'src>,
37-
then: Box<Expression<'src>>,
38-
otherwise: Box<Expression<'src>>,
31+
then: Box<Self>,
32+
otherwise: Box<Self>,
3933
},
4034
// `f"format string"`
4135
FormatString {
4236
start: StringLiteral<'src>,
43-
expressions: Vec<(Expression<'src>, StringLiteral<'src>)>,
37+
expressions: Vec<(Self, StringLiteral<'src>)>,
4438
},
4539
/// `(contents)`
46-
Group { contents: Box<Expression<'src>> },
40+
Group { contents: Box<Self> },
4741
/// `lhs / rhs`
4842
Join {
49-
lhs: Option<Box<Expression<'src>>>,
50-
rhs: Box<Expression<'src>>,
43+
lhs: Option<Box<Self>>,
44+
rhs: Box<Self>,
5145
},
5246
/// `lhs || rhs`
53-
Or {
54-
lhs: Box<Expression<'src>>,
55-
rhs: Box<Expression<'src>>,
56-
},
47+
Or { lhs: Box<Self>, rhs: Box<Self> },
5748
/// `"string_literal"` or `'string_literal'`
5849
StringLiteral { string_literal: StringLiteral<'src> },
5950
/// `variable`

src/justfile.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(crate) struct Justfile<'src> {
1212
pub(crate) loaded: Vec<PathBuf>,
1313
#[serde(skip)]
1414
pub(crate) module_path: String,
15-
pub(crate) modules: Table<'src, Justfile<'src>>,
15+
pub(crate) modules: Table<'src, Self>,
1616
#[serde(skip)]
1717
pub(crate) name: Option<Name<'src>>,
1818
#[serde(skip)]
@@ -80,7 +80,7 @@ impl<'src> Justfile<'src> {
8080
config: &'run Config,
8181
dotenv: &'run BTreeMap<String, String>,
8282
root: &'run Scope<'src, 'run>,
83-
scopes: &mut BTreeMap<String, (&'run Justfile<'src>, &'run Scope<'src, 'run>)>,
83+
scopes: &mut BTreeMap<String, (&'run Self, &'run Scope<'src, 'run>)>,
8484
search: &'run Search,
8585
) -> RunResult<'src> {
8686
let scope = Evaluator::evaluate_assignments(config, dotenv, self, root, search)?;
@@ -265,15 +265,19 @@ impl<'src> Justfile<'src> {
265265
is_dependency: bool,
266266
ran: &Ran,
267267
recipe: &Recipe<'src>,
268-
scopes: &BTreeMap<String, (&Justfile<'src>, &Scope<'src, '_>)>,
268+
scopes: &BTreeMap<String, (&Self, &Scope<'src, '_>)>,
269269
search: &Search,
270270
) -> RunResult<'src> {
271-
let mutex = ran.mutex(recipe, arguments);
271+
{
272+
let mutex = ran.mutex(recipe, arguments);
272273

273-
let mut guard = mutex.lock().unwrap();
274+
let mut guard = mutex.lock().unwrap();
274275

275-
if *guard {
276-
return Ok(());
276+
if *guard {
277+
return Ok(());
278+
}
279+
280+
*guard = true;
277281
}
278282

279283
if !config.yes && !recipe.confirm()? {
@@ -332,8 +336,6 @@ impl<'src> Justfile<'src> {
332336
search,
333337
)?;
334338

335-
*guard = true;
336-
337339
Ok(())
338340
}
339341

@@ -345,7 +347,7 @@ impl<'src> Justfile<'src> {
345347
evaluator: &mut Evaluator<'src, 'run>,
346348
ran: &Ran,
347349
recipe: &Recipe<'src>,
348-
scopes: &BTreeMap<String, (&Justfile<'src>, &Scope<'src, 'run>)>,
350+
scopes: &BTreeMap<String, (&Self, &Scope<'src, 'run>)>,
349351
search: &Search,
350352
) -> RunResult<'src> {
351353
if context.config.no_dependencies {

src/keyword.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(crate) enum Keyword {
3838
}
3939

4040
impl Keyword {
41-
pub(crate) fn from_lexeme(lexeme: &str) -> Option<Keyword> {
41+
pub(crate) fn from_lexeme(lexeme: &str) -> Option<Self> {
4242
lexeme.parse().ok()
4343
}
4444

src/list.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
use super::*;
22

3-
pub struct List<T: Display, I: Iterator<Item = T> + Clone> {
3+
pub(crate) struct List<T: Display, I: Iterator<Item = T> + Clone> {
44
conjunction: &'static str,
55
values: I,
66
}
77

88
impl<T: Display, I: Iterator<Item = T> + Clone> List<T, I> {
9-
pub fn or<II: IntoIterator<Item = T, IntoIter = I>>(values: II) -> Self {
9+
pub(crate) fn or<II: IntoIterator<Item = T, IntoIter = I>>(values: II) -> Self {
1010
Self {
1111
conjunction: "or",
1212
values: values.into_iter(),
1313
}
1414
}
1515

16-
pub fn and<II: IntoIterator<Item = T, IntoIter = I>>(values: II) -> Self {
16+
pub(crate) fn and<II: IntoIterator<Item = T, IntoIter = I>>(values: II) -> Self {
1717
Self {
1818
conjunction: "and",
1919
values: values.into_iter(),
2020
}
2121
}
2222

23-
pub fn or_ticked<II: IntoIterator<Item = T, IntoIter = I>>(
23+
pub(crate) fn or_ticked<II: IntoIterator<Item = T, IntoIter = I>>(
2424
values: II,
2525
) -> List<Enclosure<T>, impl Iterator<Item = Enclosure<T>> + Clone> {
2626
List::or(values.into_iter().map(Enclosure::tick))
2727
}
2828

29-
pub fn and_ticked<II: IntoIterator<Item = T, IntoIter = I>>(
29+
pub(crate) fn and_ticked<II: IntoIterator<Item = T, IntoIter = I>>(
3030
values: II,
3131
) -> List<Enclosure<T>, impl Iterator<Item = Enclosure<T>> + Clone> {
3232
List::and(values.into_iter().map(Enclosure::tick))

src/output_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) enum OutputError {
1717
}
1818

1919
impl OutputError {
20-
pub(crate) fn result_from_exit_status(exit_status: ExitStatus) -> Result<(), OutputError> {
20+
pub(crate) fn result_from_exit_status(exit_status: ExitStatus) -> Result<(), Self> {
2121
match exit_status.code() {
2222
Some(0) => Ok(()),
2323
Some(code) => Err(Self::Code(code)),

0 commit comments

Comments
 (0)