Skip to content

Commit

Permalink
Make clippy happy (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko authored Dec 1, 2024
1 parent cb2acf1 commit fc15103
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion minijinja-autoreload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub struct EnvironmentGuard<'reloader> {
mutex_guard: MutexGuard<'reloader, Option<Environment<'static>>>,
}

impl<'reloader> Deref for EnvironmentGuard<'reloader> {
impl Deref for EnvironmentGuard<'_> {
type Target = Environment<'static>;

fn deref(&self) -> &Self::Target {
Expand Down
10 changes: 5 additions & 5 deletions minijinja/src/compiler/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub enum Stmt<'a> {
}

#[cfg(feature = "internal_debug")]
impl<'a> fmt::Debug for Stmt<'a> {
impl fmt::Debug for Stmt<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Stmt::Template(s) => fmt::Debug::fmt(s, f),
Expand Down Expand Up @@ -148,7 +148,7 @@ pub enum Expr<'a> {
}

#[cfg(feature = "internal_debug")]
impl<'a> fmt::Debug for Expr<'a> {
impl fmt::Debug for Expr<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Expr::Var(s) => fmt::Debug::fmt(s, f),
Expand All @@ -168,7 +168,7 @@ impl<'a> fmt::Debug for Expr<'a> {
}
}

impl<'a> Expr<'a> {
impl Expr<'_> {
pub fn description(&self) -> &'static str {
match self {
Expr::Var(_) => "variable",
Expand Down Expand Up @@ -494,7 +494,7 @@ pub struct List<'a> {
pub items: Vec<Expr<'a>>,
}

impl<'a> List<'a> {
impl List<'_> {
pub fn as_const(&self) -> Option<Value> {
if !self.items.iter().all(|x| matches!(x, Expr::Const(_))) {
return None;
Expand All @@ -518,7 +518,7 @@ pub struct Map<'a> {
pub values: Vec<Expr<'a>>,
}

impl<'a> Map<'a> {
impl Map<'_> {
pub fn as_const(&self) -> Option<Value> {
if !self.keys.iter().all(|x| matches!(x, Expr::Const(_)))
|| !self.values.iter().all(|x| matches!(x, Expr::Const(_)))
Expand Down
4 changes: 2 additions & 2 deletions minijinja/src/compiler/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,11 @@ impl<'source> Instructions<'source> {
}

#[cfg(feature = "internal_debug")]
impl<'source> fmt::Debug for Instructions<'source> {
impl fmt::Debug for Instructions<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
struct InstructionWrapper<'a>(usize, &'a Instruction<'a>, Option<usize>);

impl<'a> fmt::Debug for InstructionWrapper<'a> {
impl fmt::Debug for InstructionWrapper<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ok!(write!(f, "{:>05} | {:?}", self.0, self.1,));
if let Some(line) = self.2 {
Expand Down
2 changes: 1 addition & 1 deletion minijinja/src/compiler/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub enum Token<'a> {
BraceClose,
}

impl<'a> fmt::Display for Token<'a> {
impl fmt::Display for Token<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Token::TemplateData(_) => f.write_str("template-data"),
Expand Down
2 changes: 1 addition & 1 deletion minijinja/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) struct DebugInfo {

struct VarPrinter<'x>(&'x BTreeMap<String, Value>);

impl<'x> fmt::Debug for VarPrinter<'x> {
impl fmt::Debug for VarPrinter<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.0.is_empty() {
return f.write_str("No referenced variables");
Expand Down
6 changes: 3 additions & 3 deletions minijinja/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ pub struct Environment<'source> {
recursion_limit: usize,
}

impl<'source> Default for Environment<'source> {
impl Default for Environment<'_> {
fn default() -> Self {
Environment::empty()
}
}

impl<'source> fmt::Debug for Environment<'source> {
impl fmt::Debug for Environment<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Environment")
.field("globals", &self.globals)
Expand Down Expand Up @@ -820,7 +820,7 @@ mod basic_store {
map: BTreeMap<&'source str, Arc<CompiledTemplate<'source>>>,
}

impl<'source> fmt::Debug for BasicStore<'source> {
impl fmt::Debug for BasicStore<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
BTreeMapKeysDebug(&self.map).fmt(f)
}
Expand Down
2 changes: 1 addition & 1 deletion minijinja/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl Error {
pub fn display_debug_info(&self) -> impl fmt::Display + '_ {
struct Proxy<'a>(&'a Error);

impl<'a> fmt::Display for Proxy<'a> {
impl fmt::Display for Proxy<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(info) = self.0.debug_info() {
crate::debug::render_debug_info(
Expand Down
2 changes: 1 addition & 1 deletion minijinja/src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum ExpressionBacking<'source> {
Owned(crate::loader::OwnedInstructions),
}

impl<'env, 'source> fmt::Debug for Expression<'env, 'source> {
impl fmt::Debug for Expression<'_, '_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Expression")
.field("env", &self.env)
Expand Down
2 changes: 1 addition & 1 deletion minijinja/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) struct LoaderStore<'source> {
borrowed_templates: BTreeMap<&'source str, Arc<CompiledTemplate<'source>>>,
}

impl<'source> fmt::Debug for LoaderStore<'source> {
impl fmt::Debug for LoaderStore<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut l = f.debug_list();
for key in self.owned_templates.keys() {
Expand Down
6 changes: 3 additions & 3 deletions minijinja/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct Template<'env: 'source, 'source> {
pub(crate) compiled: CompiledTemplateRef<'env, 'source>,
}

impl<'env, 'source> fmt::Debug for Template<'env, 'source> {
impl fmt::Debug for Template<'_, '_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut ds = f.debug_struct("Template");
ds.field("name", &self.name());
Expand Down Expand Up @@ -320,7 +320,7 @@ pub(crate) enum CompiledTemplateRef<'env: 'source, 'source> {
Borrowed(&'env CompiledTemplate<'source>),
}

impl<'env, 'source> Deref for CompiledTemplateRef<'env, 'source> {
impl<'source> Deref for CompiledTemplateRef<'_, 'source> {
type Target = CompiledTemplate<'source>;

fn deref(&self) -> &Self::Target {
Expand All @@ -345,7 +345,7 @@ pub struct CompiledTemplate<'source> {
pub initial_auto_escape: AutoEscape,
}

impl<'env> fmt::Debug for CompiledTemplate<'env> {
impl fmt::Debug for CompiledTemplate<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut ds = f.debug_struct("CompiledTemplate");
#[cfg(feature = "internal_debug")]
Expand Down
4 changes: 2 additions & 2 deletions minijinja/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl UndefinedBehavior {
/// Helper to HTML escape a string.
pub struct HtmlEscape<'a>(pub &'a str);

impl<'a> fmt::Display for HtmlEscape<'a> {
impl fmt::Display for HtmlEscape<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cfg(feature = "v_htmlescape")]
{
Expand Down Expand Up @@ -319,7 +319,7 @@ pub fn unescape(s: &str) -> Result<String, Error> {

pub struct BTreeMapKeysDebug<'a, K: fmt::Debug, V>(pub &'a BTreeMap<K, V>);

impl<'a, K: fmt::Debug, V> fmt::Debug for BTreeMapKeysDebug<'a, K, V> {
impl<K: fmt::Debug, V> fmt::Debug for BTreeMapKeysDebug<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list().entries(self.0.iter().map(|x| x.0)).finish()
}
Expand Down
4 changes: 2 additions & 2 deletions minijinja/src/value/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ macro_rules! common_forward {
}

#[cfg_attr(docsrs, doc(cfg(feature = "deserialization")))]
impl<'de> IntoDeserializer<'de, Error> for Value {
impl IntoDeserializer<'_, Error> for Value {
type Deserializer = Value;

fn into_deserializer(self) -> Value {
Expand Down Expand Up @@ -343,7 +343,7 @@ impl<'de> VariantAccess<'de> for VariantDeserializer {
}

#[cfg_attr(docsrs, doc(cfg(feature = "deserialization")))]
impl<'de, 'v> Deserializer<'de> for &'v Value {
impl<'de> Deserializer<'de> for &Value {
type Error = Error;

#[inline]
Expand Down
4 changes: 2 additions & 2 deletions minijinja/src/vm/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<'env> Frame<'env> {
}

#[cfg(feature = "internal_debug")]
impl<'env> fmt::Debug for Frame<'env> {
impl fmt::Debug for Frame<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut m = f.debug_map();
m.entry(&"locals", &self.locals);
Expand Down Expand Up @@ -143,7 +143,7 @@ pub(crate) struct Context<'env> {
recursion_limit: usize,
}

impl<'env> fmt::Debug for Context<'env> {
impl fmt::Debug for Context<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn dump<'a>(
m: &mut std::fmt::DebugMap,
Expand Down
2 changes: 1 addition & 1 deletion minijinja/src/vm/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct State<'template, 'env> {
pub(crate) fuel_tracker: Option<std::sync::Arc<FuelTracker>>,
}

impl<'template, 'env> fmt::Debug for State<'template, 'env> {
impl fmt::Debug for State<'_, '_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut ds = f.debug_struct("State");
ds.field("name", &self.instructions.name());
Expand Down

0 comments on commit fc15103

Please sign in to comment.