rust/tests/ui/lifetimes/issue-104432-unused-lifetimes-in-expansion.rs
Matthias Krüger a3637032db unused-lifetimes: don't warn about lifetimes originating from expanded code
previously, we would warn like this:

````
warning: lifetime parameter `'s` never used
 --> /tmp/unusedlif/code.rs:6:62
  |
5 | #[derive(Clone)]
  |          - help: elide the unused lifetime
6 | struct ShimMethod4<T: Trait2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::As));
  |                                                              ^^
  |
  = note: requested on the command line with `-W unused-lifetimes`
````

Fixes #104432
2023-02-03 21:18:34 +01:00

13 lines
287 B
Rust

// check-pass
#![deny(unused_lifetimes)]
trait Trait2 {
type As;
}
// we should not warn about an unused lifetime about code generated from this proc macro here
#[derive(Clone)]
struct ShimMethod4<T: Trait2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::As));
pub fn main() {}