(&mut self, attr: SpirvAttribute, span: Span)
| 175 | } |
| 176 | |
| 177 | fn try_insert_attr(&mut self, attr: SpirvAttribute, span: Span) -> Result<(), MultipleAttrs> { |
| 178 | fn try_insert<T>( |
| 179 | slot: &mut Option<Spanned<T>>, |
| 180 | value: T, |
| 181 | span: Span, |
| 182 | category: &'static str, |
| 183 | ) -> Result<(), MultipleAttrs> { |
| 184 | match slot { |
| 185 | Some(prev) => Err(MultipleAttrs { |
| 186 | prev_span: prev.span, |
| 187 | category, |
| 188 | }), |
| 189 | None => { |
| 190 | *slot = Some(Spanned { value, span }); |
| 191 | Ok(()) |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | use SpirvAttribute::*; |
| 197 | match attr { |
| 198 | IntrinsicType(value) => { |
| 199 | try_insert(&mut self.intrinsic_type, value, span, "intrinsic type") |
| 200 | } |
| 201 | Block => try_insert(&mut self.block, (), span, "#[spirv(block)]"), |
| 202 | Entry(value) => try_insert(&mut self.entry, value, span, "entry-point"), |
| 203 | StorageClass(value) => { |
| 204 | try_insert(&mut self.storage_class, value, span, "storage class") |
| 205 | } |
| 206 | Builtin(value) => try_insert(&mut self.builtin, value, span, "builtin"), |
| 207 | DescriptorSet(value) => try_insert( |
| 208 | &mut self.descriptor_set, |
| 209 | value, |
| 210 | span, |
| 211 | "#[spirv(descriptor_set)]", |
| 212 | ), |
| 213 | Binding(value) => try_insert(&mut self.binding, value, span, "#[spirv(binding)]"), |
| 214 | Flat => try_insert(&mut self.flat, (), span, "#[spirv(flat)]"), |
| 215 | Invariant => try_insert(&mut self.invariant, (), span, "#[spirv(invariant)]"), |
| 216 | InputAttachmentIndex(value) => try_insert( |
| 217 | &mut self.input_attachment_index, |
| 218 | value, |
| 219 | span, |
| 220 | "#[spirv(attachment_index)]", |
| 221 | ), |
| 222 | SpecConstant(value) => try_insert( |
| 223 | &mut self.spec_constant, |
| 224 | value, |
| 225 | span, |
| 226 | "#[spirv(spec_constant)]", |
| 227 | ), |
| 228 | BufferLoadIntrinsic => try_insert( |
| 229 | &mut self.buffer_load_intrinsic, |
| 230 | (), |
| 231 | span, |
| 232 | "#[spirv(buffer_load_intrinsic)]", |
| 233 | ), |
| 234 | BufferStoreIntrinsic => try_insert( |
no outgoing calls
no test coverage detected