1 // compile-flags:--cfg yes
2 
f_lt<#[cfg(yes)] 'a: 'a, #[cfg(no)] T>()3 fn f_lt<#[cfg(yes)] 'a: 'a, #[cfg(no)] T>() {}
f_ty<#[cfg(no)] 'a: 'a, #[cfg(yes)] T>()4 fn f_ty<#[cfg(no)] 'a: 'a, #[cfg(yes)] T>() {}
5 
6 type FnGood = for<#[cfg(yes)] 'a, #[cfg(no)] T> fn(); // OK
7 type FnBad = for<#[cfg(no)] 'a, #[cfg(yes)] T> fn();
8 //~^ ERROR only lifetime parameters can be used in this context
9 
10 type PolyGood = dyn for<#[cfg(yes)] 'a, #[cfg(no)] T> Copy; // OK
11 type PolyBad = dyn for<#[cfg(no)] 'a, #[cfg(yes)] T> Copy;
12 //~^ ERROR only lifetime parameters can be used in this context
13 
14 struct WhereGood where for<#[cfg(yes)] 'a, #[cfg(no)] T> u8: Copy; // OK
15 struct WhereBad where for<#[cfg(no)] 'a, #[cfg(yes)] T> u8: Copy;
16 //~^ ERROR only lifetime parameters can be used in this context
17 
f_lt_no<#[cfg_attr(no, unknown)] 'a>()18 fn f_lt_no<#[cfg_attr(no, unknown)] 'a>() {} // OK
f_lt_yes<#[cfg_attr(yes, unknown)] 'a>()19 fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {}
20 //~^ ERROR cannot find attribute `unknown` in this scope
f_ty_no<#[cfg_attr(no, unknown)] T>()21 fn f_ty_no<#[cfg_attr(no, unknown)] T>() {} // OK
f_ty_yes<#[cfg_attr(yes, unknown)] T>()22 fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {}
23 //~^ ERROR cannot find attribute `unknown` in this scope
24 
25 type FnNo = for<#[cfg_attr(no, unknown)] 'a> fn(); // OK
26 type FnYes = for<#[cfg_attr(yes, unknown)] 'a> fn();
27 //~^ ERROR cannot find attribute `unknown` in this scope
28 
29 type PolyNo = dyn for<#[cfg_attr(no, unknown)] 'a> Copy; // OK
30 type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy;
31 //~^ ERROR cannot find attribute `unknown` in this scope
32 
33 struct WhereNo where for<#[cfg_attr(no, unknown)] 'a> u8: Copy; // OK
34 struct WhereYes where for<#[cfg_attr(yes, unknown)] 'a> u8: Copy;
35 //~^ ERROR cannot find attribute `unknown` in this scope
36 
main()37 fn main() {
38     f_lt::<'static>();
39     f_ty::<u8>();
40 }
41