]> git.proxmox.com Git - rustc.git/blob - tests/ui/higher-rank-trait-bounds/hrtb-malformed-lifetime-generics.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / higher-rank-trait-bounds / hrtb-malformed-lifetime-generics.rs
1 // Test that Fn-family traits with lifetime parameters shouldn't compile and
2 // we suggest the usage of higher-rank trait bounds instead.
3
4 fn fa(_: impl Fn<'a>(&'a str) -> bool) {}
5 //~^ ERROR `Fn` traits cannot take lifetime parameters
6
7 fn fb(_: impl FnMut<'a, 'b>(&'a str, &'b str) -> bool) {}
8 //~^ ERROR `Fn` traits cannot take lifetime parameters
9
10 fn fc(_: impl std::fmt::Display + FnOnce<'a>(&'a str) -> bool + std::fmt::Debug) {}
11 //~^ ERROR `Fn` traits cannot take lifetime parameters
12
13 use std::ops::Fn as AliasedFn;
14 fn fd(_: impl AliasedFn<'a>(&'a str) -> bool) {}
15 //~^ ERROR `Fn` traits cannot take lifetime parameters
16
17 fn fe<F>(_: F) where F: Fn<'a>(&'a str) -> bool {}
18 //~^ ERROR `Fn` traits cannot take lifetime parameters
19
20 fn main() {}