Closed
Description
cargo.toml
cargo-features = ["edition"]
[package]
name = "warn"
version = "0.1.0"
authors = ["me"]
edition = "2018"
[dependencies]
src/main.rs
#![warn(single_use_lifetimes)]
mod a;
fn main() {}
src/a.rs
#[warn(single_use_lifetimes)]
#[derive(Debug)]
pub(crate) struct pathThing {
pub(crate) path: std::path::Path,
}
#[derive(Debug, Clone)]
pub(crate) struct DirSizes<'a> {
pub(crate) b: &'a pathThing,
}
impl<'a> DirSizes<'a> {
pub(crate) fn new(a: &'a pathThing) -> Self {
let b = &a;
Self { b }
}
}
impl<'a> std::fmt::Display for DirSizes<'a> {
fn fmt(&self, f: &'_ mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", "hello")?;
Ok(())
}
}
when building, I get
warning: lifetime parameter `'a` only used once
--> src/a.rs:19:6
|
19 | impl<'a> std::fmt::Display for DirSizes<'a> {
| ^^ this lifetime... -- ...is used only here
|
note: lint level defined here
--> src/main.rs:1:9
|
1 | #![warn(single_use_lifetimes)]
| ^^^^^^^^^^^^^^^^^^^^
warning: lifetime parameter `'a` only used once
--> src/a.rs:8:28
|
7 | #[derive(Debug, Clone)]
| ----- ...is used only here
8 | pub(crate) struct DirSizes<'a> {
| ^^ this lifetime...
warning: method is never used: `new`
--> src/a.rs:13:5
|
13 | pub(crate) fn new(a: &'a pathThing) -> Self {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
warning: type `pathThing` should have a camel case name such as `Paththing`
--> src/a.rs:3:1
|
3 | / pub(crate) struct pathThing {
4 | | pub(crate) path: std::path::Path,
5 | | }
| |_^
|
= note: #[warn(non_camel_case_types)] on by default
Finished dev [unoptimized + debuginfo] target(s) in 0.41
the
warning: lifetime parameter `'a` only used once
--> src/a.rs:8:28
|
7 | #[derive(Debug, Clone)]
| ----- ...is used only here
8 | pub(crate) struct DirSizes<'a> {
| ^^ this lifetime...
is what looks sorta wrong.
rustc 1.30.0-nightly (0198a1ea4 2018-09-08)