(
&self,
cx: &CodegenCx<'tcx>,
span: Span,
pointee: PointeeTy<'tcx>,
pointee_spv: Word,
)
| 223 | } |
| 224 | |
| 225 | fn end( |
| 226 | &self, |
| 227 | cx: &CodegenCx<'tcx>, |
| 228 | span: Span, |
| 229 | pointee: PointeeTy<'tcx>, |
| 230 | pointee_spv: Word, |
| 231 | ) -> Word { |
| 232 | match self.map.borrow_mut().entry(pointee) { |
| 233 | // We should have hit begin() on this type already, which always inserts an entry. |
| 234 | Entry::Vacant(_) => { |
| 235 | span_bug!(span, "RecursivePointeeCache::end should always have entry") |
| 236 | } |
| 237 | Entry::Occupied(mut entry) => match *entry.get() { |
| 238 | // State: There have been no recursive references to this type while defining it, and so no |
| 239 | // OpTypeForwardPointer has been emitted. This is the most common case. |
| 240 | PointeeDefState::Defining => { |
| 241 | let id = SpirvType::Pointer { |
| 242 | pointee: pointee_spv, |
| 243 | } |
| 244 | .def(span, cx); |
| 245 | entry.insert(PointeeDefState::Defined(id)); |
| 246 | id |
| 247 | } |
| 248 | // State: There was a recursive reference to this type, and so an OpTypeForwardPointer has been emitted. |
| 249 | // Make sure to use the same ID. |
| 250 | PointeeDefState::DefiningWithForward(id) => { |
| 251 | entry.insert(PointeeDefState::Defined(id)); |
| 252 | SpirvType::Pointer { |
| 253 | pointee: pointee_spv, |
| 254 | } |
| 255 | .def_with_id(cx, span, id) |
| 256 | } |
| 257 | PointeeDefState::Defined(_) => { |
| 258 | span_bug!(span, "RecursivePointeeCache::end defined pointer twice") |
| 259 | } |
| 260 | }, |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | #[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)] |
no test coverage detected