|
| 1 | +//! Copies of the types related to attributes. |
| 2 | +//! Such types are mostly contained in the crate `rustc_attr_data_structures`. |
| 3 | +
|
| 4 | +use crate::prelude::*; |
| 5 | + |
| 6 | +/// Reflects [`rustc_attr_data_structures::AttributeKind`] |
| 7 | +#[derive(AdtInto)] |
| 8 | +#[args(<'tcx, S: BaseState<'tcx>>, from: rustc_attr_data_structures::AttributeKind, state: S as tcx)] |
| 9 | +#[derive_group(Serializers)] |
| 10 | +#[derive(Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 11 | +pub enum AttributeKind { |
| 12 | + Align { |
| 13 | + align: Align, |
| 14 | + span: Span, |
| 15 | + }, |
| 16 | + AllowConstFnUnstable(Vec<Symbol>, Span), |
| 17 | + AllowIncoherentImpl(Span), |
| 18 | + AllowInternalUnstable(Vec<(Symbol, Span)>, Span), |
| 19 | + AsPtr(Span), |
| 20 | + AutomaticallyDerived(Span), |
| 21 | + BodyStability { |
| 22 | + stability: DefaultBodyStability, |
| 23 | + span: Span, |
| 24 | + }, |
| 25 | + CoherenceIsCore, |
| 26 | + Coinductive(Span), |
| 27 | + Cold(Span), |
| 28 | + Confusables { |
| 29 | + symbols: Vec<Symbol>, |
| 30 | + first_span: Span, |
| 31 | + }, |
| 32 | + ConstContinue(Span), |
| 33 | + ConstStability { |
| 34 | + stability: PartialConstStability, |
| 35 | + span: Span, |
| 36 | + }, |
| 37 | + ConstStabilityIndirect, |
| 38 | + ConstTrait(Span), |
| 39 | + Coverage(Span, CoverageStatus), |
| 40 | + DenyExplicitImpl(Span), |
| 41 | + Deprecation { |
| 42 | + deprecation: Deprecation, |
| 43 | + span: Span, |
| 44 | + }, |
| 45 | + DoNotImplementViaObject(Span), |
| 46 | + DocComment { |
| 47 | + style: AttrStyle, |
| 48 | + kind: CommentKind, |
| 49 | + span: Span, |
| 50 | + comment: Symbol, |
| 51 | + }, |
| 52 | + Dummy, |
| 53 | + ExportName { |
| 54 | + name: Symbol, |
| 55 | + span: Span, |
| 56 | + }, |
| 57 | + ExportStable, |
| 58 | + FfiConst(Span), |
| 59 | + FfiPure(Span), |
| 60 | + Fundamental, |
| 61 | + Ignore { |
| 62 | + span: Span, |
| 63 | + reason: Option<Symbol>, |
| 64 | + }, |
| 65 | + Inline(InlineAttr, Span), |
| 66 | + LinkName { |
| 67 | + name: Symbol, |
| 68 | + span: Span, |
| 69 | + }, |
| 70 | + LinkOrdinal { |
| 71 | + ordinal: u16, |
| 72 | + span: Span, |
| 73 | + }, |
| 74 | + LinkSection { |
| 75 | + name: Symbol, |
| 76 | + span: Span, |
| 77 | + }, |
| 78 | + LoopMatch(Span), |
| 79 | + MacroTransparency(Transparency), |
| 80 | + Marker(Span), |
| 81 | + MayDangle(Span), |
| 82 | + MustUse { |
| 83 | + span: Span, |
| 84 | + reason: Option<Symbol>, |
| 85 | + }, |
| 86 | + Naked(Span), |
| 87 | + NoImplicitPrelude(Span), |
| 88 | + NoMangle(Span), |
| 89 | + NonExhaustive(Span), |
| 90 | + OmitGdbPrettyPrinterSection, |
| 91 | + Optimize(OptimizeAttr, Span), |
| 92 | + ParenSugar(Span), |
| 93 | + PassByValue(Span), |
| 94 | + Path(Symbol, Span), |
| 95 | + Pointee(Span), |
| 96 | + PubTransparent(Span), |
| 97 | + Repr { |
| 98 | + reprs: Vec<(ReprAttr, Span)>, |
| 99 | + first_span: Span, |
| 100 | + }, |
| 101 | + RustcLayoutScalarValidRangeEnd(u128, Span), |
| 102 | + RustcLayoutScalarValidRangeStart(u128, Span), |
| 103 | + RustcObjectLifetimeDefault, |
| 104 | + SkipDuringMethodDispatch { |
| 105 | + array: bool, |
| 106 | + boxed_slice: bool, |
| 107 | + span: Span, |
| 108 | + }, |
| 109 | + SpecializationTrait(Span), |
| 110 | + Stability { |
| 111 | + stability: Stability, |
| 112 | + span: Span, |
| 113 | + }, |
| 114 | + StdInternalSymbol(Span), |
| 115 | + TargetFeature(Vec<(Symbol, Span)>, Span), |
| 116 | + TrackCaller(Span), |
| 117 | + TypeConst(Span), |
| 118 | + UnsafeSpecializationMarker(Span), |
| 119 | + UnstableFeatureBound(Vec<(Symbol, Span)>), |
| 120 | + Used { |
| 121 | + used_by: UsedBy, |
| 122 | + span: Span, |
| 123 | + }, |
| 124 | +} |
| 125 | + |
| 126 | +/// Reflects [`rustc_span::hygiene::Transparency`] |
| 127 | +#[derive_group(Serializers)] |
| 128 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 129 | +#[args(<'tcx, S>, from: rustc_span::hygiene::Transparency, state: S as _s)] |
| 130 | +pub enum Transparency { |
| 131 | + Transparent, |
| 132 | + SemiOpaque, |
| 133 | + Opaque, |
| 134 | +} |
| 135 | + |
| 136 | +/// Reflects [`rustc_attr_data_structures::Stability`] |
| 137 | +#[derive_group(Serializers)] |
| 138 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 139 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::Stability, state: S as _s)] |
| 140 | +pub struct Stability { |
| 141 | + pub level: StabilityLevel, |
| 142 | + pub feature: Symbol, |
| 143 | +} |
| 144 | + |
| 145 | +/// Reflects [`rustc_attr_data_structures::DefaultBodyStability`] |
| 146 | +#[derive_group(Serializers)] |
| 147 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 148 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::DefaultBodyStability, state: S as _s)] |
| 149 | +pub struct DefaultBodyStability { |
| 150 | + pub level: StabilityLevel, |
| 151 | + pub feature: Symbol, |
| 152 | +} |
| 153 | + |
| 154 | +/// Reflects [`rustc_attr_data_structures::Deprecation`] |
| 155 | +#[derive_group(Serializers)] |
| 156 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 157 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::Deprecation, state: S as _s)] |
| 158 | +pub struct Deprecation { |
| 159 | + pub since: DeprecatedSince, |
| 160 | + pub note: Option<Symbol>, |
| 161 | + pub suggestion: Option<Symbol>, |
| 162 | +} |
| 163 | + |
| 164 | +/// Reflects [`rustc_attr_data_structures::DeprecatedSince`] |
| 165 | +#[derive_group(Serializers)] |
| 166 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 167 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::DeprecatedSince, state: S as _s)] |
| 168 | +pub enum DeprecatedSince { |
| 169 | + RustcVersion(RustcVersion), |
| 170 | + Future, |
| 171 | + NonStandard(Symbol), |
| 172 | + Unspecified, |
| 173 | + Err, |
| 174 | +} |
| 175 | + |
| 176 | +/// Reflects [`rustc_attr_data_structures::ReprAttr`] |
| 177 | +#[derive_group(Serializers)] |
| 178 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 179 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::ReprAttr, state: S as _s)] |
| 180 | +pub enum ReprAttr { |
| 181 | + ReprInt(IntType), |
| 182 | + ReprRust, |
| 183 | + ReprC, |
| 184 | + ReprPacked(Align), |
| 185 | + ReprSimd, |
| 186 | + ReprTransparent, |
| 187 | + ReprAlign(Align), |
| 188 | +} |
| 189 | + |
| 190 | +/// Reflects [`rustc_attr_data_structures::IntType`] |
| 191 | +#[derive_group(Serializers)] |
| 192 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 193 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::IntType, state: S as _s)] |
| 194 | +pub enum IntType { |
| 195 | + SignedInt(IntTy), |
| 196 | + UnsignedInt(UintTy), |
| 197 | +} |
| 198 | + |
| 199 | +/// Reflects [`rustc_attr_data_structures::UsedBy`] |
| 200 | +#[derive_group(Serializers)] |
| 201 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 202 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::UsedBy, state: S as _s)] |
| 203 | +pub enum UsedBy { |
| 204 | + Compiler, |
| 205 | + Linker, |
| 206 | +} |
| 207 | + |
| 208 | +/// Reflects [`rustc_attr_data_structures::StabilityLevel`] |
| 209 | +#[derive_group(Serializers)] |
| 210 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 211 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::StabilityLevel, state: S as _s)] |
| 212 | +pub enum StabilityLevel { |
| 213 | + Unstable { |
| 214 | + reason: UnstableReason, |
| 215 | + #[map(x.map(|x| x.get()))] |
| 216 | + issue: Option<u32>, |
| 217 | + is_soft: bool, |
| 218 | + implied_by: Option<Symbol>, |
| 219 | + old_name: Option<Symbol>, |
| 220 | + }, |
| 221 | + Stable { |
| 222 | + since: StableSince, |
| 223 | + allowed_through_unstable_modules: Option<Symbol>, |
| 224 | + }, |
| 225 | +} |
| 226 | + |
| 227 | +/// Reflects [`rustc_attr_data_structures::CoverageStatus`] |
| 228 | +#[derive_group(Serializers)] |
| 229 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 230 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::CoverageStatus, state: S as _s)] |
| 231 | +pub enum CoverageStatus { |
| 232 | + On, |
| 233 | + Off, |
| 234 | +} |
| 235 | + |
| 236 | +/// Reflects [`rustc_attr_data_structures::PartialConstStability`] |
| 237 | +#[derive_group(Serializers)] |
| 238 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 239 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::PartialConstStability, state: S as _s)] |
| 240 | +pub struct PartialConstStability { |
| 241 | + pub level: StabilityLevel, |
| 242 | + pub feature: Symbol, |
| 243 | + pub promotable: bool, |
| 244 | +} |
| 245 | + |
| 246 | +/// Reflects [`rustc_attr_data_structures::RustcVersion`] |
| 247 | +#[derive_group(Serializers)] |
| 248 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 249 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::RustcVersion, state: S as _s)] |
| 250 | +pub struct RustcVersion { |
| 251 | + pub major: u16, |
| 252 | + pub minor: u16, |
| 253 | + pub patch: u16, |
| 254 | +} |
| 255 | + |
| 256 | +/// Reflects [`rustc_attr_data_structures::StableSince`] |
| 257 | +#[derive_group(Serializers)] |
| 258 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 259 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::StableSince, state: S as _s)] |
| 260 | +pub enum StableSince { |
| 261 | + Version(RustcVersion), |
| 262 | + Current, |
| 263 | + #[custom_arm(rustc_attr_data_structures::StableSince::Err(_) => StableSince::Err,)] |
| 264 | + Err, |
| 265 | +} |
| 266 | + |
| 267 | +/// Reflects [`rustc_attr_data_structures::UnstableReason`] |
| 268 | +#[derive_group(Serializers)] |
| 269 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 270 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::UnstableReason, state: S as _s)] |
| 271 | +pub enum UnstableReason { |
| 272 | + None, |
| 273 | + Default, |
| 274 | + Some(Symbol), |
| 275 | +} |
| 276 | + |
| 277 | +/// Reflects [`rustc_attr_data_structures::OptimizeAttr`] |
| 278 | +#[derive_group(Serializers)] |
| 279 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 280 | +#[args(<'tcx, S>, from: rustc_attr_data_structures::OptimizeAttr, state: S as _s)] |
| 281 | +pub enum OptimizeAttr { |
| 282 | + Default, |
| 283 | + DoNotOptimize, |
| 284 | + Speed, |
| 285 | + Size, |
| 286 | +} |
| 287 | + |
| 288 | +/// Reflects [`rustc_attr_data_structures::InlineAttr`] |
| 289 | +#[derive_group(Serializers)] |
| 290 | +#[derive(AdtInto, Clone, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)] |
| 291 | +#[args(<'tcx, S: BaseState<'tcx>>, from: rustc_attr_data_structures::InlineAttr, state: S as _s)] |
| 292 | +pub enum InlineAttr { |
| 293 | + None, |
| 294 | + Hint, |
| 295 | + Always, |
| 296 | + Never, |
| 297 | + Force { |
| 298 | + attr_span: Span, |
| 299 | + reason: Option<Symbol>, |
| 300 | + }, |
| 301 | +} |
0 commit comments