Skip to content

clippy::elidable_lifetime_names gets invalidly triggered on v0.15 #643

@m4tx

Description

@m4tx

Describe the bug
Structures that contain references that use the Template derive implementation trigger the clippy::elidable_lifetime_names lint.

To Reproduce
The following code:

#![deny(clippy::elidable_lifetime_names)]

use askama::Template;

#[derive(Debug, Template)]
#[template(source = "", ext = "txt")]
struct Test<'a> {
    _data: &'a (),
}

fn main() {}

produces the following error after running cargo clippy:

error: the following explicit lifetimes could be elided: 'a
 --> src/main.rs:7:13
  |
7 | struct Test<'a> {
  |             ^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names
help: elide the lifetimes
  |
7 - struct Test<'a> {
7 + struct Test'_> {
  |

However, the lifetime cannot be elided in this case.

Note that in addition to a regression in Askama itself, this might also qualify as a Clippy bug - see the suggestion produces an invalid Rust syntax!

Askama version
This is a regression introduced in v0.15. v0.14 doesn't trigger this.

Rust version

rustc 1.92.0 (ded5c06cf 2025-12-08)
clippy 0.1.92 (ded5c06cf2 2025-12-08)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions