|
| 1 | +// This is testing whether various builtin attributes signals an |
| 2 | +// error or warning when put in "weird" places. |
| 3 | +// |
| 4 | +// (This file sits on its own because it actually signals an error, |
| 5 | +// which would mess up the treatment of other cases in |
| 6 | +// issue-43106-gating-of-builtin-attrs.rs) |
| 7 | + |
| 8 | +// ignore-tidy-linelength |
| 9 | + |
| 10 | +// Crate-level is accepted, though it is almost certainly unused? |
| 11 | +#![inline] |
| 12 | + |
| 13 | +#[inline] |
| 14 | +//~^ ERROR attribute should be applied to function or closure |
| 15 | +mod inline { |
| 16 | + //~^ NOTE not a function or closure |
| 17 | + |
| 18 | + mod inner { #![inline] } |
| 19 | + //~^ ERROR attribute should be applied to function or closure |
| 20 | + //~| NOTE not a function or closure |
| 21 | + |
| 22 | + #[inline = "2100"] fn f() { } |
| 23 | + //~^ ERROR attribute must be of the form |
| 24 | + //~| WARN this was previously accepted |
| 25 | + //~| NOTE #[deny(ill_formed_attribute_input)]` on by default |
| 26 | + //~| NOTE for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> |
| 27 | + |
| 28 | + #[inline] struct S; |
| 29 | + //~^ ERROR attribute should be applied to function or closure |
| 30 | + //~| NOTE not a function or closure |
| 31 | + |
| 32 | + #[inline] type T = S; |
| 33 | + //~^ ERROR attribute should be applied to function or closure |
| 34 | + //~| NOTE not a function or closure |
| 35 | + |
| 36 | + #[inline] impl S { } |
| 37 | + //~^ ERROR attribute should be applied to function or closure |
| 38 | + //~| NOTE not a function or closure |
| 39 | +} |
| 40 | + |
| 41 | +#[no_link] |
| 42 | +//~^ ERROR attribute should be applied to an `extern crate` item |
| 43 | +mod no_link { |
| 44 | + //~^ NOTE not an `extern crate` item |
| 45 | + |
| 46 | + mod inner { #![no_link] } |
| 47 | + //~^ ERROR attribute should be applied to an `extern crate` item |
| 48 | + //~| NOTE not an `extern crate` item |
| 49 | + |
| 50 | + #[no_link] fn f() { } |
| 51 | + //~^ ERROR attribute should be applied to an `extern crate` item |
| 52 | + //~| NOTE not an `extern crate` item |
| 53 | + |
| 54 | + #[no_link] struct S; |
| 55 | + //~^ ERROR attribute should be applied to an `extern crate` item |
| 56 | + //~| NOTE not an `extern crate` item |
| 57 | + |
| 58 | + #[no_link]type T = S; |
| 59 | + //~^ ERROR attribute should be applied to an `extern crate` item |
| 60 | + //~| NOTE not an `extern crate` item |
| 61 | + |
| 62 | + #[no_link] impl S { } |
| 63 | + //~^ ERROR attribute should be applied to an `extern crate` item |
| 64 | + //~| NOTE not an `extern crate` item |
| 65 | +} |
| 66 | + |
| 67 | +#[cold] |
| 68 | +//~^ ERROR attribute should be applied to a function |
| 69 | +mod cold { |
| 70 | + //~^ NOTE not a function |
| 71 | + |
| 72 | + mod inner { #![cold] } |
| 73 | + //~^ ERROR attribute should be applied to a function |
| 74 | + //~| NOTE not a function |
| 75 | + |
| 76 | + #[cold] fn f() { } |
| 77 | + |
| 78 | + #[cold] struct S; |
| 79 | + //~^ ERROR attribute should be applied to a function |
| 80 | + //~| NOTE not a function |
| 81 | + |
| 82 | + #[cold] type T = S; |
| 83 | + //~^ ERROR attribute should be applied to a function |
| 84 | + //~| NOTE not a function |
| 85 | + |
| 86 | + #[cold] impl S { } |
| 87 | + //~^ ERROR attribute should be applied to a function |
| 88 | + //~| NOTE not a function |
| 89 | +} |
| 90 | + |
| 91 | +#[export_name = "2200"] |
| 92 | +//~^ ERROR attribute should be applied to a function or static |
| 93 | +mod export_name { |
| 94 | + //~^ NOTE not a function or static |
| 95 | + |
| 96 | + mod inner { #![export_name="2200"] } |
| 97 | + //~^ ERROR attribute should be applied to a function or static |
| 98 | + //~| NOTE not a function or static |
| 99 | + |
| 100 | + #[export_name = "2200"] fn f() { } |
| 101 | + |
| 102 | + #[export_name = "2200"] struct S; |
| 103 | + //~^ ERROR attribute should be applied to a function or static |
| 104 | + //~| NOTE not a function or static |
| 105 | + |
| 106 | + #[export_name = "2200"] type T = S; |
| 107 | + //~^ ERROR attribute should be applied to a function or static |
| 108 | + //~| NOTE not a function or static |
| 109 | + |
| 110 | + #[export_name = "2200"] impl S { } |
| 111 | + //~^ ERROR attribute should be applied to a function or static |
| 112 | + //~| NOTE not a function or static |
| 113 | +} |
| 114 | + |
| 115 | +#[link_name = "1900"] |
| 116 | +//~^ ERROR attribute should be applied to a foreign function or static |
| 117 | +mod link_name { |
| 118 | + //~^ NOTE not a foreign function or static |
| 119 | + |
| 120 | + #[link_name = "1900"] |
| 121 | + //~^ ERROR attribute should be applied to a foreign function or static |
| 122 | + //~| HELP try `#[link(name = "1900")]` instead |
| 123 | + extern { } |
| 124 | + //~^ NOTE not a foreign function or static |
| 125 | + |
| 126 | + mod inner { #![link_name="1900"] } |
| 127 | + //~^ ERROR attribute should be applied to a foreign function or static |
| 128 | + //~| NOTE not a foreign function or static |
| 129 | + |
| 130 | + #[link_name = "1900"] fn f() { } |
| 131 | + //~^ ERROR attribute should be applied to a foreign function or static |
| 132 | + //~| NOTE not a foreign function or static |
| 133 | + |
| 134 | + #[link_name = "1900"] struct S; |
| 135 | + //~^ ERROR attribute should be applied to a foreign function or static |
| 136 | + //~| NOTE not a foreign function or static |
| 137 | + |
| 138 | + #[link_name = "1900"] type T = S; |
| 139 | + //~^ ERROR attribute should be applied to a foreign function or static |
| 140 | + //~| NOTE not a foreign function or static |
| 141 | + |
| 142 | + #[link_name = "1900"] impl S { } |
| 143 | + //~^ ERROR attribute should be applied to a foreign function or static |
| 144 | + //~| NOTE not a foreign function or static |
| 145 | +} |
| 146 | + |
| 147 | +#[link_section = "1800"] |
| 148 | +//~^ ERROR attribute should be applied to a function or static |
| 149 | +mod link_section { |
| 150 | + //~^ NOTE not a function or static |
| 151 | + |
| 152 | + mod inner { #![link_section="1800"] } |
| 153 | + //~^ ERROR attribute should be applied to a function or static |
| 154 | + //~| NOTE not a function or static |
| 155 | + |
| 156 | + #[link_section = "1800"] fn f() { } |
| 157 | + |
| 158 | + #[link_section = "1800"] struct S; |
| 159 | + //~^ ERROR attribute should be applied to a function or static |
| 160 | + //~| NOTE not a function or static |
| 161 | + |
| 162 | + #[link_section = "1800"] type T = S; |
| 163 | + //~^ ERROR attribute should be applied to a function or static |
| 164 | + //~| NOTE not a function or static |
| 165 | + |
| 166 | + #[link_section = "1800"] impl S { } |
| 167 | + //~^ ERROR attribute should be applied to a function or static |
| 168 | + //~| NOTE not a function or static |
| 169 | +} |
| 170 | + |
| 171 | +fn main() {} |
0 commit comments