|
23 | 23 | //! becomes stable.
|
24 | 24 |
|
25 | 25 | use self::Status::*;
|
| 26 | +use self::AttributeType::*; |
26 | 27 |
|
27 | 28 | use abi::RustIntrinsic;
|
28 | 29 | use ast::NodeId;
|
@@ -152,6 +153,74 @@ enum Status {
|
152 | 153 | Accepted,
|
153 | 154 | }
|
154 | 155 |
|
| 156 | +// Attributes that have a special meaning to rustc or rustdoc |
| 157 | +pub static KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[ |
| 158 | + |
| 159 | + // FIXME: #14408 whitelist docs since rustdoc looks at them |
| 160 | + ("doc", Whitelisted), |
| 161 | + |
| 162 | + // FIXME: #14406 these are processed in trans, which happens after the |
| 163 | + // lint pass |
| 164 | + ("cold", Whitelisted), |
| 165 | + ("export_name", Whitelisted), |
| 166 | + ("inline", Whitelisted), |
| 167 | + ("link", Whitelisted), |
| 168 | + ("link_name", Whitelisted), |
| 169 | + ("link_section", Whitelisted), |
| 170 | + ("linkage", Whitelisted), |
| 171 | + ("no_builtins", Whitelisted), |
| 172 | + ("no_mangle", Whitelisted), |
| 173 | + ("no_split_stack", Whitelisted), |
| 174 | + ("no_stack_check", Whitelisted), |
| 175 | + ("packed", Whitelisted), |
| 176 | + ("static_assert", Whitelisted), |
| 177 | + ("thread_local", Whitelisted), |
| 178 | + ("no_debug", Whitelisted), |
| 179 | + ("omit_gdb_pretty_printer_section", Whitelisted), |
| 180 | + ("unsafe_no_drop_flag", Whitelisted), |
| 181 | + |
| 182 | + // used in resolve |
| 183 | + ("prelude_import", Whitelisted), |
| 184 | + |
| 185 | + // FIXME: #14407 these are only looked at on-demand so we can't |
| 186 | + // guarantee they'll have already been checked |
| 187 | + ("deprecated", Whitelisted), |
| 188 | + ("must_use", Whitelisted), |
| 189 | + ("stable", Whitelisted), |
| 190 | + ("unstable", Whitelisted), |
| 191 | + ("rustc_on_unimplemented", Whitelisted), |
| 192 | + ("rustc_error", Whitelisted), |
| 193 | + |
| 194 | + // FIXME: #19470 this shouldn't be needed forever |
| 195 | + ("old_orphan_check", Whitelisted), |
| 196 | + ("old_impl_check", Whitelisted), |
| 197 | + ("rustc_paren_sugar", Whitelisted), // FIXME: #18101 temporary unboxed closure hack |
| 198 | + |
| 199 | + // Crate level attributes |
| 200 | + ("crate_name", CrateLevel), |
| 201 | + ("crate_type", CrateLevel), |
| 202 | + ("feature", CrateLevel), |
| 203 | + ("no_start", CrateLevel), |
| 204 | + ("no_main", CrateLevel), |
| 205 | + ("no_std", CrateLevel), |
| 206 | + ("no_builtins", CrateLevel), |
| 207 | +]; |
| 208 | + |
| 209 | +#[derive(PartialEq, Copy)] |
| 210 | +pub enum AttributeType { |
| 211 | + /// Normal, builtin attribute that is consumed |
| 212 | + /// by the compiler before the unused_attribute check |
| 213 | + Normal, |
| 214 | + |
| 215 | + /// Builtin attribute that may not be consumed by the compiler |
| 216 | + /// before the unused_attribute check. These attributes |
| 217 | + /// will be ignored by the unused_attribute lint |
| 218 | + Whitelisted, |
| 219 | + |
| 220 | + /// Builtin attribute that is only allowed at the crate level |
| 221 | + CrateLevel, |
| 222 | +} |
| 223 | + |
155 | 224 | /// A set of features to be used by later passes.
|
156 | 225 | pub struct Features {
|
157 | 226 | pub unboxed_closures: bool,
|
|
0 commit comments