]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/attr-on-generic-formals.rs
Auto merge of #54265 - arielb1:civilize-proc-macros, r=alexcrichton
[rust.git] / src / test / run-pass / attr-on-generic-formals.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(unused_attributes)]
12
13 // This test ensures we can attach attributes to the formals in all
14 // places where generic parameter lists occur, assuming appropriate
15 // feature gates are enabled.
16 //
17 // (We are prefixing all tested features with `rustc_`, to ensure that
18 // the attributes themselves won't be rejected by the compiler when
19 // using `rustc_attrs` feature. There is a separate compile-fail/ test
20 // ensuring that the attribute feature-gating works in this context.)
21
22 #![feature(rustc_attrs)]
23 #![allow(dead_code)]
24
25 struct StLt<#[rustc_lt_struct] 'a>(&'a u32);
26 struct StTy<#[rustc_ty_struct] I>(I);
27
28 enum EnLt<#[rustc_lt_enum] 'b> { A(&'b u32), B }
29 enum EnTy<#[rustc_ty_enum] J> { A(J), B }
30
31 trait TrLt<#[rustc_lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; }
32 trait TrTy<#[rustc_ty_trait] K> { fn foo(&self, _: K); }
33
34 type TyLt<#[rustc_lt_type] 'd> = &'d u32;
35 type TyTy<#[rustc_ty_type] L> = (L, );
36
37 impl<#[rustc_lt_inherent] 'e> StLt<'e> { }
38 impl<#[rustc_ty_inherent] M> StTy<M> { }
39
40 impl<#[rustc_lt_impl_for] 'f> TrLt<'f> for StLt<'f> {
41     fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } }
42 }
43 impl<#[rustc_ty_impl_for] N> TrTy<N> for StTy<N> {
44     fn foo(&self, _: N) { }
45 }
46
47 fn f_lt<#[rustc_lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } }
48 fn f_ty<#[rustc_ty_fn] O>(_: O) { }
49
50 impl<I> StTy<I> {
51     fn m_lt<#[rustc_lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } }
52     fn m_ty<#[rustc_ty_meth] P>(_: P) { }
53 }
54
55 fn hof_lt<Q>(_: Q)
56     where Q: for <#[rustc_lt_hof] 'i> Fn(&'i [u32]) -> &'i u32
57 {
58 }
59
60 fn main() {
61
62 }