]> git.lizzy.rs Git - rust.git/blob - tests/ui/single-use-lifetime/one-use-in-trait-method-argument.rs
Rollup merge of #104012 - chenyukang:yukang/fix-103882-deli-indentation, r=petrochenkov
[rust.git] / tests / ui / single-use-lifetime / one-use-in-trait-method-argument.rs
1 // Test that we DO warn for a lifetime on an impl used only in `&self`
2 // in a trait method.
3
4 #![deny(single_use_lifetimes)]
5 #![allow(dead_code)]
6 #![allow(unused_variables)]
7
8 struct Foo<'f> {
9     data: &'f u32
10 }
11
12 impl<'f> Iterator for Foo<'f> {
13     type Item = &'f u32;
14
15     fn next<'g>(&'g mut self) -> Option<Self::Item> { //~ ERROR `'g` only used once
16         //~^ HELP elide the single-use lifetime
17         None
18     }
19 }
20
21 trait Bar<'a> {
22     // But we should not warn here.
23     fn bar(x: Foo<'a>);
24 }
25
26 fn main() {}