.githooks/ compiler/ kernel/ lib/ scripts/ seed/ sublime/ test/ boot/ bootstrap/ compiler/ cycles/ dispatch/ format/ host/ integration/ kernel/ loader/ manifests/ mmio/ native/ packages/ runtime/ scheduling/ shared/ slots/ smp/ std/ sync/ termination/ tests/ asm.link/ asm.rodata.prefix/ assign.qualified.static/ entry.storage.start/ fn.unsafe.callbacks/ method.module/ optional.union.const.match/ record.opaque/ ref.qualified.static/ return.never/ stack.limit.ok/ stack.limit.trap/ start.default/ start.exit/ wildcard.import.owner/ abi.sizes.rad 3.5 KiB addfn.rad 52 B addfn.ril 76 B address.literal.aggregate.rad 6.2 KiB address.literal.escape.reject.rad 1.4 KiB address.literal.local.mutable.reject.rad 293 B address.literal.local.reject.rad 336 B address.literal.mutable.rad 1.3 KiB address.literal.shared.rad 734 B address.literal.shared.ril 1.0 KiB address.value.escape.reject.rad 2.5 KiB address.value.linear.field.reject.rad 297 B address.value.linear.mutable.reject.rad 262 B address.value.linear.reject.rad 303 B address.value.local.mutable.reject.rad 361 B address.value.local.reject.rad 322 B address.value.rad 6.7 KiB address.value.temporary.rad 1.2 KiB address.value.temporary.ril 1.6 KiB aggregate.return.rad 4.1 KiB alloc.arena.trait.rad 2.7 KiB alloc.new.arena.rad 1.8 KiB alloc.new.rad 1.0 KiB arena.static.rad 1.1 KiB arith.assignment.rad 631 B arith.basic.rad 189 B arith.modulo.rad 109 B arith.subword.rad 3.9 KiB arith.subword.ril 4.3 KiB arith.sum.rad 192 B arith.w64.rad 4.1 KiB arith.w64.ril 5.2 KiB array.aggregate.stride.rad 773 B array.aggregate.stride.ril 697 B array.assign.rad 225 B array.assign.ril 570 B array.bound.signature.rad 695 B array.bounds.check.rad 321 B array.fn.assign.rad 265 B array.index.assign.rad 422 B array.index.rad 278 B array.index.ril 520 B array.len.const.rad 348 B array.len.const.ril 333 B array.length.rad 281 B array.literal.rad 136 B array.literal.ril 376 B array.math.rad 1.2 KiB array.nested.assign.rad 320 B array.nested.rad 318 B array.nested.ril 995 B array.pointer.rad 2.5 KiB array.record.elements.rad 1.7 KiB array.repeat.edge.rad 548 B array.repeat.element.type.rad 1.2 KiB array.repeat.loop.lower.rad 1.5 KiB array.repeat.loop.lower.ril 2.1 KiB array.repeat.loop.rad 52.3 KiB array.repeat.rad 831 B array.repeat.ril 2.4 KiB array.repeat.word.aggregate.lower.rad 2.0 KiB array.repeat.word.aggregate.lower.ril 3.7 KiB array.repeat.word.aggregate.rad 4.6 KiB array.repeat.word.lower.rad 2.3 KiB array.repeat.word.lower.ril 4.8 KiB array.repeat.word.rad 53.8 KiB array.return.rad 344 B array.slice.empty.rad 127 B array.slice.full.rad 124 B array.slice.full.ril 253 B array.slice.gen.end.rad 156 B array.slice.gen.index.rad 167 B array.slice.gen.open.rad 154 B array.slice.gen.start.end.rad 158 B array.slice.gen.start.rad 156 B array.slice.openend.rad 149 B array.slice.openend.ril 436 B array.slice.openstart.rad 149 B array.slice.openstart.ril 373 B array.slice.rad 816 B as.precedence.rad 224 B asm.arithmetic.spacing.ras 537 B asm.atomic.reserve.ras 1.1 KiB asm.basic.text.program.ras 191 B asm.bleu.ras 251 B asm.branch.comparisons.ras 652 B asm.call.return.flow.ras 205 B asm.compare.set.logic.ras 613 B asm.csr.system.instructions.ras 223 B asm.data.directives.ras 441 B asm.data.symbol.fixup.ras 229 B asm.directive.boundary.values.ras 813 B asm.divrem.edges.ras 2.5 KiB asm.fence.ras 78 B asm.global.scoped.symbols.ras 211 B asm.instruction.matrix.alu.ras 568 B asm.instruction.matrix.mem.control.ras 357 B asm.instruction.matrix.system.ras 117 B asm.label.fixups.ras 237 B asm.li.expressions.ras 214 B asm.li.wide.ras 578 B asm.load.store.widths.ras 713 B asm.mul.div.rem.ras 773 B asm.mulh.ras 2.3 KiB asm.scoped.symbols.la.ras 152 B asm.scoped.symbols.tail.ras 161 B asm.section.switching.ras 177 B asm.space.constant.expressions.ras 360 B asm.string.directive.lists.ras 328 B asm.vector.integer.ras 633 B asm.word.dword.constants.ras 375 B asm.word.shift.ops.ras 872 B assert.basic.rad 398 B assert.basic.ril 623 B assert.fail.rad 138 B assert.false.rad 140 B assert.message.rad 123 B assert.message.ril 141 B assert.true.rad 115 B assign.loop.rad 213 B assign.loop.ril 242 B assign.multi.var.rad 194 B assign.multi.var.ril 73 B assign.mutable.rad 6.2 KiB assign.param.rad 150 B assign.param.ril 96 B assign.rad 156 B assign.self.ref.rad 161 B assign.self.ref.ril 92 B assign.sequential.rad 163 B assign.sequential.ril 52 B assign.shadow.mutable.rad 489 B assign.use.intermediate.rad 191 B assign.use.intermediate.ril 99 B average.rad 189 B average.ril 447 B binding.storage.rad 962 B binop.arith.rad 479 B binop.arith.ril 389 B binop.bitwise.rad 1.2 KiB binop.bitwise.ril 1.2 KiB binop.cmp.rad 425 B binop.logical.rad 216 B binop.logical.ril 373 B binop.shift.rad 197 B binop.shift.ril 149 B binop.unsigned.rad 317 B binop.unsigned.ril 236 B bitmanip.rad 4.5 KiB bool.comparison.array.rad 691 B bool.comparison.nested.gen.rad 1.0 KiB bool.comparison.opt.rad 865 B bool.comparison.record.gen.rad 1.0 KiB bool.comparison.record.rad 1.1 KiB bool.comparison.slice.gen.rad 157 B bool.comparison.slice.rad 4.4 KiB bool.comparison.slice.record.gen.rad 2.0 KiB bool.comparison.slice.union.gen.rad 2.6 KiB bool.comparison.union.ctor.rad 711 B bool.comparison.union.gen.rad 1.2 KiB bool.comparison.union.record.gen.rad 1.5 KiB bool.comparison.union.simple.gen.rad 302 B bool.operators.complex.rad 368 B bool.operators.rad 824 B bool.short.circuit.rad 2.4 KiB bool.simple.rad 202 B bool.values.rad 787 B borrow.fields.calls.rad 1.3 KiB borrow.fields.calls.ril 1.1 KiB borrow.fields.pattern.rad 594 B borrow.fields.pattern.ril 362 B borrow.index.disjoint.rad 2.9 KiB borrow.index.overlap.reject.rad 611 B builtin.alignof.rad 698 B builtin.alignof.ril 287 B builtin.memory.fence.rad 108 B builtin.size.align.rad 1.2 KiB builtin.sizeof.rad 656 B builtin.sizeof.ril 282 B builtin.sliceof.invalid.cap.rad 271 B builtin.sliceof.limit.rad 479 B builtin.sliceof.mut.rad 672 B builtin.sliceof.rad 542 B byte.load.store.rad 380 B byte.load.store.ril 687 B call.aggregate.arg.snapshot.rad 520 B call.arg.clobber.rad 732 B call.basic.rad 256 B call.clobber.rad 509 B call.stack.args.aggregate.rad 603 B call.stack.args.fnptr.rad 1.4 KiB call.stack.args.method.rad 1.4 KiB call.stack.args.mixed.rad 1.6 KiB call.stack.args.recursive.rad 1.0 KiB call.stack.args.spill.rad 1.9 KiB call.stack.args.survive.rad 2.9 KiB call.stack.args.throws.rad 861 B call.tests.rad 764 B call.tests.ril 605 B cast.basic.rad 855 B cast.basic.ril 681 B cast.narrow.rad 583 B cast.narrow.ril 557 B cast.same.size.rad 1.0 KiB cast.same.size.ril 1.1 KiB casting.numbers.rad 1.5 KiB char.literal.rad 180 B cmp.extension.rad 3.1 KiB cmp.narrow.live.rad 1.5 KiB cmp.narrow.live.ril 2.2 KiB cmp.rel.rad 733 B cmp.rel.ril 467 B cmp.unsigned.rad 733 B cmp.unsigned.ril 467 B coercion.implicit.rad 941 B coercion.implicit.ril 1.0 KiB compare.literal.first.u64.rad 301 B compound.assign.field.rad 318 B compound.assign.index.once.rad 431 B compound.assign.rad 1.2 KiB compound.assign.ril 2.0 KiB cond.assign.merge.basic.rad 221 B cond.assign.merge.basic.ril 172 B cond.assign.merge.rad 214 B cond.assign.merge.ril 169 B cond.assign.rad 766 B cond.elseif.rad 204 B cond.elseif.ril 181 B cond.expr.aggregate.rad 1.2 KiB cond.expr.literal-first.rad 326 B cond.expr.rad 1.9 KiB cond.expr.ril 3.5 KiB cond.for.else.break.rad 343 B cond.for.indexed.rad 255 B cond.for.rad 180 B cond.for.range.indexed.rad 549 B cond.for.range.rad 190 B cond.for.unsigned.range.rad 677 B cond.forever.break.continue.rad 197 B cond.forever.break.rad 251 B cond.fused.rad 939 B cond.if.case.rad 2.2 KiB cond.if.else.min.rad 152 B cond.if.else.rad 233 B cond.if.elseif.rad 418 B cond.if.noelse.rad 134 B cond.if.rad 840 B cond.ifelse.rad 104 B cond.ifelse.ril 117 B cond.iflet.case.rad 170 B cond.iflet.case.ril 114 B cond.iflet.guard.rad 182 B cond.iflet.guard.ril 165 B cond.iflet.mut.rad 195 B cond.iflet.mut.ril 223 B cond.iflet.noelse.rad 156 B cond.iflet.noelse.ril 231 B cond.iflet.optional.rad 184 B cond.iflet.optional.ril 197 B cond.iflet.optional.value.rad 194 B cond.iflet.optional.value.ril 212 B cond.letelse.case.rad 158 B cond.letelse.case.ril 149 B cond.letelse.guard.rad 172 B cond.letelse.guard.ril 200 B cond.letelse.mut.rad 185 B cond.letelse.mut.ril 258 B cond.letelse.optional.rad 172 B cond.letelse.optional.ril 232 B cond.match.fallthrough.rad 418 B cond.match.guard.rad 1.4 KiB cond.match.guard.regalloc.rad 1.4 KiB cond.nested.rad 138 B cond.nested.ril 185 B cond.optional.annotation.rad 867 B cond.shortcircuit.eval.rad 1006 B cond.shortcircuit.rad 418 B cond.shortcircuit.ril 484 B cond.simple.rad 86 B cond.simple.ril 118 B cond.while.else.break.rad 299 B cond.while.rad 134 B const-cast-wrap.rad 442 B const-expr-array-size.rad 391 B const-expr-cast.rad 1.1 KiB const-expr-literal.rad 673 B const-expr-refs.rad 872 B const.array.copy.mutate.rad 397 B const.array.ident.rad 247 B const.array.ident.ril 208 B const.array.rad 213 B const.array.record.ident.rad 396 B const.array.record.ident.ril 293 B const.array.repeat.record.rad 225 B const.array.repeat.record.ril 211 B const.array.repeat.string.slice.rad 303 B const.array.repeat.string.slice.ril 1.1 KiB const.array.ril 437 B const.array.strings.slice.rad 274 B const.array.strings.slice.ril 781 B const.basic.rad 341 B const.char.rad 174 B const.fn.array.rad 670 B const.i32.shift.right.rad 244 B const.local.duplicate.rad 474 B const.local.duplicate.ril 866 B const.negative.rad 331 B const.negative.ril 380 B const.record.array.rad 1.2 KiB const.record.array.simple.rad 554 B const.record.ctor.rad 194 B const.record.ctor.ril 448 B const.record.fn.rad 362 B const.record.mutcopy.rad 1.0 KiB const.record.mutcopy.ril 1.4 KiB const.record.nested.rad 408 B const.record.nested.ril 312 B const.record.packed.rad 275 B const.record.packed.ril 204 B const.record.padded.rad 275 B const.record.padded.ril 237 B const.record.rad 204 B const.record.ril 164 B const.record.union.rad 612 B const.record.union.ril 883 B const.scalar.rad 105 B const.scalar.ril 116 B const.shift.negative.count.rad 305 B const.slice.of.slices.rad 238 B const.slice.of.slices.ril 1.2 KiB const.slice.param.rad 339 B const.string.rad 114 B const.string.ril 401 B const.string.scoped.names.rad 263 B const.string.scoped.names.ril 1.0 KiB const.u32.shift.mask.rad 249 B const.u64.compare.rad 188 B const.u64.divide.rad 174 B const.union.nested.mixed.rad 889 B const.union.payload.ctor.rad 376 B const.union.payload.ctor.ril 504 B const.union.payload.fn.array.rad 1.1 KiB const.union.payload.record.array.rad 1.5 KiB const.union.record.literal.rad 383 B const.union.record.literal.ril 550 B constant.mutable.pointer.reject.rad 416 B constant.projections.rad 1.8 KiB data.array.rad 803 B data.bool.rad 237 B data.i16.rad 288 B data.i32.rad 308 B data.i8.rad 275 B data.optional.nil.rad 935 B data.optional.value.rad 2.5 KiB data.record.rad 597 B data.simple.rad 492 B data.u16.rad 244 B data.u32.rad 264 B data.u8.rad 232 B data.union.rad 1.0 KiB debug.tag.rad 563 B definit.aggregates.rad 1.9 KiB definit.branches.rad 3.5 KiB definit.loops.rad 1.9 KiB div.u8.immediate.wrap.rad 213 B ecall.i64.rad 535 B edge.cases.2.rad 361 B edge.cases.3.rad 606 B edge.cases.4.rad 1.3 KiB edge.cases.5.rad 1.1 KiB edge.cases.6.rad 3.0 KiB edge.cases.7.addr.bug.rad 246 B edge.cases.8.bug.rad 553 B edge.cases.rad 246 B entry.storage.call.rad 635 B entry.storage.dict.rad 1.6 KiB entry.storage.noenv.rad 1.6 KiB entry.storage.rad 2.3 KiB entry.storage.record.rad 5.5 KiB entry.storage.reject.rad 4.9 KiB entry.storage.slices.index.rad 346 B entry.storage.slices.lower.rad 616 B entry.storage.slices.lower.ril 904 B entry.storage.slices.rad 4.7 KiB entry.storage.slices.range.rad 441 B entry.storage.small.rad 446 B entry.storage.small.record.rad 432 B entry.storage.small.record.ril 367 B entry.storage.small.ril 641 B entry.storage.split.rad 2.5 KiB error.basic.rad 185 B error.catch.discard.pointer.rad 1.0 KiB error.catch.rad 1.6 KiB error.catch.return.rad 414 B error.catch.return.ril 511 B error.division.zero.rad 164 B error.match.discard.rad 533 B error.modulo.zero.rad 162 B error.multi.basic.rad 721 B error.multi.catch.rad 870 B error.multi.catch.typed.binding.rad 840 B error.multi.catch.typed.catchall.rad 1.1 KiB error.multi.catch.typed.rad 1.1 KiB error.multi.mixed.union.rad 3.0 KiB error.multi.propagate.multi.rad 1010 B error.multi.propagate.rad 874 B error.multi.try.optional.rad 544 B error.slice.bounds.rad 233 B error.throw.coercion.rad 318 B error.try.bang.success.rad 381 B error.try.catch.binding.rad 2.0 KiB error.try.optional.rad 1.9 KiB error.try.rad 4.1 KiB extern.inferred.rad 70 B externfn.rad 32 B externfn.ril 37 B fibonacci.rad 120 B fibonacci.ril 247 B field.aggregate.rad 842 B field.aggregate.ril 934 B fn.block.scope.rad 508 B fn.callback.nested.rad 1.6 KiB fn.default.rad 144 B fn.local.rad 153 B fn.ptr.assign.rad 277 B fn.ptr.assign.ril 180 B fn.ptr.call.rad 258 B fn.ptr.call.ril 217 B fn.ptr.param.rad 356 B fn.ptr.param.ril 319 B fn.recursion.2.rad 237 B fn.void.rad 163 B for.else.continue.rad 1.1 KiB for.record.inner.loop.rad 713 B frame.large.rad 614 B generic.function.growth.reject.rad 284 B generic.function.rad 1.5 KiB generic.layout.overflow.reject.rad 211 B generic.layout.rad 875 B heap.allocator.slots.reject.rad 630 B heap.constant.rad 1.2 KiB heap.forge.handle.reject.rad 440 B heap.forge.local.reject.rad 499 B heap.forge.param.reject.rad 316 B heap.forge.static.reject.rad 351 B heap.rewind.static.rad 328 B heap.static.rad 2.8 KiB if-let-mut.rad 1.2 KiB iflet.shadow.else.rad 408 B iflet.shadow.leak.rad 316 B index.eval.order.rad 395 B index.u8.rad 616 B infer.empty.array.reject.rad 197 B infer.nested.integer.reject.rad 366 B int.default.i64.rad 1.1 KiB integer.bitwise.basic.rad 738 B integer.overflow.rad 1.8 KiB intrinsic.bits.rad 239 B intrinsic.bytes.load16.end.rad 406 B intrinsic.bytes.load16.overflow.rad 415 B intrinsic.bytes.load16.short.rad 406 B intrinsic.bytes.load32.end.rad 406 B intrinsic.bytes.load32.overflow.rad 415 B intrinsic.bytes.load32.short.rad 406 B intrinsic.bytes.load64.end.rad 406 B intrinsic.bytes.load64.overflow.rad 415 B intrinsic.bytes.load64.short.rad 406 B intrinsic.bytes.rad 389 B intrinsic.bytes.store16.end.rad 391 B intrinsic.bytes.store16.overflow.rad 400 B intrinsic.bytes.store16.short.rad 391 B intrinsic.bytes.store32.end.rad 391 B intrinsic.bytes.store32.overflow.rad 400 B intrinsic.bytes.store32.short.rad 391 B intrinsic.bytes.store64.end.rad 391 B intrinsic.bytes.store64.overflow.rad 400 B intrinsic.bytes.store64.short.rad 391 B intrinsic.ebreak.rad 90 B intrinsic.ebreak.ril 51 B intrinsic.ecall.buffer.rad 1.1 KiB intrinsic.ecall.buffer.ril 730 B intrinsic.ecall.rad 171 B intrinsic.ecall.ril 70 B intrinsic.page.heap.rad 1.6 KiB large.blit.store.rad 2.1 KiB layout.fn.rad 771 B layout.fn.ril 1.1 KiB layout.optional.rad 698 B layout.optional.ril 1.1 KiB layout.recursive.rad 816 B layout.recursive.ril 409 B layout.result.rad 782 B layout.result.ril 1.5 KiB layout.slice.rad 1.0 KiB layout.slice.ril 2.1 KiB layout.union.rad 996 B layout.union.ril 1.1 KiB let.case.ref.binding.rad 2.7 KiB let.copy.semantics.rad 883 B let.copy.semantics.ril 1.0 KiB let.guard.rad 1.9 KiB let.placeholder.rad 291 B let.placeholder.ril 262 B linear.let-else.rad 402 B linear.ownership.rad 395 B linear.ownership.ril 362 B linear.reference.rad 663 B linear.reference.ril 736 B linear.unsafe.rad 531 B linear.unsafe.ril 318 B literal.char.rad 209 B literal.char.ril 127 B literal.slice.bytes.rad 124 B literal.slice.bytes.ril 351 B literal.slice.dedup.rad 199 B literal.slice.dedup.ril 485 B literal.slice.empty.rad 100 B literal.slice.empty.ril 212 B literal.slice.multi.rad 170 B literal.slice.multi.ril 580 B literal.slice.rad 123 B literal.slice.record.rad 217 B literal.slice.record.ril 495 B literal.slice.ril 361 B literal.string.dedup.rad 179 B literal.string.dedup.ril 472 B literal.string.empty.rad 93 B literal.string.empty.ril 336 B literal.string.fns.rad 180 B literal.string.fns.ril 524 B literal.string.multi.rad 153 B literal.string.multi.ril 534 B literal.string.rad 108 B literal.string.ril 335 B literal.w64.rad 1.7 KiB load.u32.high.rad 1.8 KiB loc.addr.offset.bug.rad 453 B loc.addr.opt.to.opt.rad 454 B loc.addr.optional.assign.rad 429 B loc.addr.record.assign.rad 497 B local.multi.rad 85 B local.multi.ril 67 B local.mut.rad 79 B local.mut.ril 45 B local.simple.rad 60 B local.simple.ril 45 B loop.break.rad 156 B loop.break.ril 228 B loop.complex.flow.rad 1.0 KiB loop.continue.rad 219 B loop.continue.ril 327 B loop.for.array.rad 223 B loop.for.array.ril 371 B loop.for.break.bound.rad 163 B loop.for.break.bound.ril 264 B loop.for.continue.rad 405 B loop.for.continue.ril 797 B loop.for.indexed.rad 151 B loop.for.indexed.ril 285 B loop.for.placeholder.rad 323 B loop.for.placeholder.ril 502 B loop.for.pointer.rad 1.5 KiB loop.for.rad 122 B loop.for.ril 220 B loop.for.slice.indexed.offset.bounds.rad 275 B loop.for.slice.indexed.other.bounds.rad 345 B loop.for.slice.indexed.rad 209 B loop.for.slice.indexed.ril 446 B loop.for.slice.indexed.runtime.rad 1.2 KiB loop.for.slice.indexed.shadow.bounds.rad 296 B loop.for.slice.indexed.source.shadow.bounds.rad 346 B loop.for.slice.pointer.bound.rad 190 B loop.for.slice.pointer.bound.ril 415 B loop.for.slice.rad 216 B loop.for.slice.ril 431 B loop.for.unsigned.range.rad 321 B loop.for.unsigned.range.ril 481 B loop.infinite.rad 41 B loop.infinite.ril 105 B loop.mutable.rad 377 B loop.mutable.ril 569 B loop.nested.break.rad 392 B loop.nested.break.ril 461 B loop.nested.continue.rad 418 B loop.nested.continue.ril 581 B loop.return.rad 141 B loop.return.ril 206 B loop.sealblock.rad 946 B loop.while.false.noparams.rad 170 B loop.while.false.noparams.ril 171 B loop.while.nested.shortcircuit.rad 872 B loop.while.nested.shortcircuit.ril 429 B loop.while.rad 164 B loop.while.ril 241 B loop.whilelet.case.rad 259 B loop.whilelet.case.ril 204 B loop.whilelet.guard.rad 265 B loop.whilelet.guard.ril 256 B loop.whilelet.optional.rad 212 B loop.whilelet.optional.ril 293 B loop.whilelet.union.rad 387 B loop.whilelet.union.ril 444 B lower.const.record.ident.rad 291 B lower.const.record.ident.ril 635 B lower.private.union.const.rad 259 B lower.private.union.const.ril 528 B lower.record.scalar.record.const.rad 244 B lower.record.scalar.record.const.ril 561 B lower.slice.strings.names.rad 462 B match.alternatives.il.rad 1.1 KiB match.alternatives.il.ril 2.0 KiB match.alternatives.nested.rad 9.2 KiB match.alternatives.subject.rad 10.1 KiB match.array.rad 3.5 KiB match.borrow.scope.rad 797 B match.byref.scalar.rad 5.9 KiB match.catchall.reject.rad 660 B match.char.rad 1.7 KiB match.last.prong.il.rad 1.5 KiB match.last.prong.il.ril 1.6 KiB match.last.prong.rad 4.0 KiB match.many.rad 1.6 KiB match.more.rad 667 B match.more.ril 778 B match.multi.seal.rad 1011 B match.multi.seal.ril 848 B match.multi.survive.rad 1.6 KiB match.mutref.push.rad 1.1 KiB match.mutref.union.rad 691 B match.nested.call.rad 1.8 KiB match.nested.deep.rad 2.2 KiB match.nested.deref.rad 3.8 KiB match.nested.enum.byref.rad 27.3 KiB match.nested.guard.field.rad 1.0 KiB match.nested.guard.field.safe.rad 1.9 KiB match.nested.guard.rad 1.6 KiB match.nested.iflet.guard.rad 1.6 KiB match.nested.iflet.rad 1.4 KiB match.nested.iflet.ril 2.3 KiB match.nested.letelse.rad 848 B match.nested.letelse.union.rad 1.4 KiB match.nested.literal.rad 3.1 KiB match.nested.multi.rad 2.5 KiB match.nested.pattern.rad 5.3 KiB match.nested.pattern.ril 8.1 KiB match.nested.record.rad 2.1 KiB match.nested.record.ril 3.4 KiB match.nested.scalar.byref.rad 15.3 KiB match.nested.union.rad 2.3 KiB match.nested.union.ril 4.5 KiB match.nested.whilelet.rad 2.4 KiB match.optional.aggregate.rad 230 B match.optional.aggregate.ril 607 B match.optional.rad 190 B match.optional.record.pattern.rad 14.1 KiB match.optional.record.rad 294 B match.optional.record.ril 369 B match.optional.ref.rad 215 B match.optional.ref.ril 328 B match.optional.ril 268 B match.optional.union.variant.rad 303 B match.optional.union.variant.ril 385 B match.optional.wildcard.rad 282 B match.record.pattern.rad 349 B match.record.pattern.ril 302 B match.record.positional.fields.rad 5.1 KiB match.scalar.extension.rad 1.6 KiB match.simple.rad 375 B match.simple.ril 392 B match.string.rad 1.9 KiB match.subject.inplace.eval.rad 1.9 KiB match.subject.inplace.rad 1.6 KiB match.subject.inplace.ril 2.4 KiB match.switch.dense.rad 3.6 KiB match.switch.rad 219 B match.switch.ril 207 B match.union.switch.rad 3.8 KiB match.value.copy.rad 2.0 KiB match.variant.fields.bind.rad 6.3 KiB match.variant.fields.deref.rad 1.6 KiB match.variant.fields.literal.rad 5.0 KiB match.variant.fields.nested.rad 7.0 KiB match.variant.fields.optional.rad 4.6 KiB match.variant.fields.rad 459 B match.variant.fields.ref.rad 3.2 KiB match.variant.fields.reject.rad 372 B match.variant.fields.ril 835 B match.void.then.or.rad 1.6 KiB match.wildcard.literal.rad 3.5 KiB match.wildcard.switch.rad 403 B match.wildcard.switch.ril 297 B match.wildcard.union.rad 1.7 KiB memzero.result.bug.rad 820 B memzero.union.bug.rad 617 B method.basic.rad 590 B method.eight.params.rad 1.4 KiB method.eight.params.throws.rad 2.3 KiB method.multiple.rad 945 B method.ptr.rad 717 B method.pub.rad 247 B method.return.rad 472 B method.scalar.receiver.rad 920 B method.throws.rad 849 B method.union.rad 447 B method.with.trait.rad 706 B mixedtypes.rad 79 B mixedtypes.ril 82 B multi.throw.basic.rad 294 B multi.throw.basic.ril 395 B multi.throw.catch.typed.rad 466 B multi.throw.catch.typed.ril 830 B multi.throw.propagate.rad 357 B multi.throw.propagate.ril 697 B multiplefns.rad 109 B multiplefns.ril 147 B mutable.data.plain.rad 1.7 KiB mutable.data.slice.reject.rad 992 B mutable.static.slice.reject.rad 404 B mutref.call.result.rad 350 B mutref.loop.bug.rad 1.9 KiB mutref.loop.rad 324 B mutref.loop.ril 412 B mutref.scalar.rad 232 B mutref.scalar.ril 366 B nil.cmp.rad 622 B nil.cmp.ril 556 B noparams.rad 38 B noparams.ril 43 B opt.array.hint.rad 951 B opt.assignment.bug.rad 1.3 KiB opt.bug.test.rad 1.4 KiB opt.if.let.complex.rad 6.1 KiB opt.if.let.guard.rad 801 B opt.if.let.rad 948 B opt.nil.check.rad 1.6 KiB opt.ptr.return.nil.rad 85 B opt.ptr.return.nil.ril 104 B opt.record.eq.rad 864 B opt.record.eq.rev.rad 313 B opt.record.eq.rev.ril 593 B opt.record.eq.ril 3.5 KiB opt.record.rad 677 B opt.return.array.rad 289 B opt.return.nested.rad 803 B opt.return.nil.rad 82 B opt.return.nil.ril 156 B opt.return.record.rad 351 B opt.return.value.rad 91 B opt.return.value.ril 180 B opt.slice.npo.rad 3.0 KiB opt.slice.npo.ril 6.8 KiB opt.type.rad 227 B opt.while.let.complex.rad 411 B optional.aggregate.eq.rad 292 B optional.aggregate.eq.ril 825 B optional.array.repeat.rad 2.9 KiB optional.array.repeat.static.rad 833 B optional.const.scalar.rad 2.6 KiB optional.const.string.rad 340 B optional.eq.rad 131 B optional.eq.ril 311 B optional.field.value.match.rad 628 B optional.let.literal.rad 1.5 KiB optional.pointer.wide.rad 875 B optional.pointer.wide.ril 1.1 KiB optional.ptr.eq.rad 313 B optional.ptr.eq.ril 477 B optional.record.value.match.rad 645 B optional.union.eq.rad 1.5 KiB optional.union.init.rad 2.5 KiB optional.union.let.rad 2.9 KiB optional.union.variant.cond.rad 2.5 KiB optional.union.variant.exhaustive.rad 2.0 KiB optional.union.variant.match.rad 2.4 KiB optional.union.variant.nested.rad 1.5 KiB optional.union.variant.owned.rad 1.3 KiB optional.union.variant.placeholder.rad 408 B optional.union.variant.record.rad 2.9 KiB optional.union.variant.ref.rad 1.4 KiB optional.union.variant.void.rad 1.3 KiB owned.root.fields.rad 1.8 KiB panic.basic.rad 70 B panic.basic.ril 46 B panic.rad 111 B param.address.loop.rad 423 B parser.call.record.argument.rad 209 B parser.condition.array.record.rad 232 B parser.condition.subscript.record.rad 278 B parser.keyword.reject.rad 206 B placeholder.basic.rad 147 B placeholder.comprehensive.rad 578 B placeholder.value.reject.rad 510 B pointer.arithmetic.unsafe.rad 465 B pointer.borrow.unsafe.rad 1.7 KiB pointer.cast.unsafe.rad 475 B pointer.copy.edge.case.rad 1.5 KiB pointer.move.record.rad 570 B pointer.nonnull.rad 1.7 KiB pointer.nonnull.ril 3.3 KiB pointer.slice.index.rad 302 B pointer.slice.store.rad 1005 B pointer.stack.borrow.rad 954 B pointer.stack.unsafe.rad 517 B pointer.zero.trap.rad 407 B pointerfn.rad 50 B pointerfn.ril 112 B prog.ackermann.rad 5.0 KiB prog.bignum.rad 9.7 KiB prog.binsearch.rad 2.5 KiB prog.bubblesort.rad 2.0 KiB prog.cordic.rad 6.9 KiB prog.crc32.rad 2.8 KiB prog.dijkstra.rad 8.0 KiB prog.eval.rad 6.3 KiB prog.hanoi.rad 3.8 KiB prog.huffman.rad 9.8 KiB prog.hybridsort.rad 3.1 KiB prog.linkedlist.rad 5.9 KiB prog.lzw.rad 7.2 KiB prog.matmul.rad 3.0 KiB prog.mersenne.rad 5.5 KiB prog.nqueens.rad 3.6 KiB prog.rbtree.rad 8.8 KiB prog.regex.rad 11.0 KiB prog.sha256.rad 7.2 KiB prog.sieve.rad 2.8 KiB prog.symtab.rad 10.3 KiB prog.tokenizer.rad 14.8 KiB prog.vm.rad 18.2 KiB ptr.addressof.field.rad 138 B ptr.addressof.field.ril 163 B ptr.addressof.local.rad 501 B ptr.addressof.local.ril 353 B ptr.addressof.rad 133 B ptr.addressof.ril 163 B ptr.assign.rad 155 B ptr.assign.ril 159 B ptr.deref.rad 720 B ptr.deref.record.rad 288 B ptr.deref.record.ril 250 B ptr.deref.ril 1.1 KiB ptr.eq.rad 1.1 KiB ptr.mutate.rad 256 B ptr.opaque.rad 1.6 KiB ptr.subscript.assign.rad 133 B ptr.subscript.assign.ril 229 B range.arithmetic.rad 897 B record.access.rad 304 B record.alignment.rad 200 B record.array.elements.rad 1.7 KiB record.assign.blit.rad 121 B record.assign.blit.ril 193 B record.copy.rad 2.1 KiB record.ctor.tuple.rad 75 B record.ctor.tuple.ril 248 B record.empty.eq.rad 278 B record.empty.eq.ril 312 B record.eq.rad 229 B record.eq.ril 272 B record.field.assign.rad 215 B record.field.assign.ril 337 B record.literal.labeled.rad 109 B record.literal.labeled.ril 157 B record.mixed.layout.rad 122 B record.mixed.layout.ril 179 B record.nested.calls.2.rad 622 B record.nested.calls.3.rad 755 B record.nested.eq.rad 258 B record.nested.eq.ril 638 B record.nested.lit.rad 182 B record.nested.lit.ril 249 B record.nodeid.cheap.rad 1.1 KiB record.nodeid.cheap.ril 1.5 KiB record.param.lit.rad 379 B record.positional.destructure.rad 1.1 KiB record.ptr.access.rad 260 B record.ptr.access.ril 227 B record.ptr.mutate.rad 249 B record.scalar.rad 10.7 KiB record.shorthand.rad 1.5 KiB record.single.deref.rad 1.6 KiB record.unlabeled.deref.rad 1.4 KiB record.unlabeled.rad 419 B ref.if.bug.rad 527 B ref.immut.loop.bug.rad 674 B ref.local.bindings.rad 1.5 KiB ref.local.bindings.ril 1.2 KiB ref.local.fields.rad 1.8 KiB ref.local.never.rad 269 B ref.local.never.ril 124 B ref.local.scopes.rad 1.1 KiB ref.local.scopes.ril 1023 B ref.local.slice.release.rad 288 B ref.local.slice.release.ril 654 B ref.mut.ptr.rad 291 B reference.array.repeat.rad 133 B reference.array.repeat.ril 360 B regalloc.callee.save.rad 1.5 KiB regalloc.spill.reuse.rad 488 B region.buffered.rad 6.1 KiB region.cursor.implicit.rad 1.1 KiB region.empty.rad 1.4 KiB region.heap.rad 2.1 KiB region.http.rad 5.9 KiB region.iterator.rad 2.5 KiB region.mutable.views.escape.reject.rad 463 B region.mutable.views.rad 588 B region.nested.rad 2.7 KiB region.record.rad 4.4 KiB region.return.rad 5.4 KiB region.slice.rad 1.5 KiB region.sources.rad 3.6 KiB region.stores.rad 2.8 KiB region.union.variants.rad 1.3 KiB region.unknown.join.reject.rad 456 B region.unnamed.optional.reject.rad 230 B region.unnamed.rad 1.5 KiB region.unnamed.slice.reject.rad 234 B region.writer.rad 2.8 KiB reserve.loop.rad 421 B reserve.loop.ril 502 B reserve.zeroed.rad 1.2 KiB result.slice.rad 1.7 KiB result.void.success.rad 699 B return.lit.rad 45 B return.lit.ril 50 B return.never.catch.rad 794 B return.never.flow.rad 647 B return.never.flow.ril 607 B return.param.rad 48 B return.param.ril 54 B rv64.u32.compare.rad 2.1 KiB scope.local.overflow.reject.rad 842 B scratch.forge.opaque.rad 698 B scratch.frame.rad 3.3 KiB scratch.slots.reject.rad 650 B scratch.stale.values.rad 1.7 KiB set.keyword.rad 446 B simplefn.rad 45 B simplefn.ril 51 B slice.alloc.loop.rad 850 B slice.append.failure.rad 1.1 KiB slice.append.limit.rad 915 B slice.append.limit.trap.rad 369 B slice.append.rad 586 B slice.append.ril 1.5 KiB slice.append.values.rad 3.4 KiB slice.append.zero.rad 1.3 KiB slice.assign.mismatch.rad 220 B slice.assign.rad 2.2 KiB slice.basic.rad 763 B slice.basic.ril 1.3 KiB slice.borrow.coerce.rad 1.4 KiB slice.cap.rad 996 B slice.construct.unsafe.rad 468 B slice.delete.bounds.rad 288 B slice.delete.owned.rad 420 B slice.delete.rad 1009 B slice.delete.ril 4.4 KiB slice.delete.slots.rad 1.2 KiB slice.elem.bounds.rad 271 B slice.empty.nonnull.rad 1.9 KiB slice.empty.suffix.rad 599 B slice.eq.rad 126 B slice.eq.ril 330 B slice.extend.borrowed.rad 6.7 KiB slice.extend.bytes.rad 892 B slice.extend.bytes.ril 3.2 KiB slice.extend.copy.rad 24.0 KiB slice.extend.overflow.rad 1.1 KiB slice.extend.overflow.words.rad 1.1 KiB slice.failure.rad 2.6 KiB slice.grow.rad 6.7 KiB slice.header.unsafe.rad 629 B slice.index.rad 104 B slice.index.ril 220 B slice.mutable.rad 297 B slice.mutable.ril 696 B slice.mutator.place.reject.rad 1.3 KiB slice.new.bounds.rad 258 B slice.new.order.rad 258 B slice.of.rad 560 B slice.owned.return.const.rad 1.5 KiB slice.param.grow.rad 4.0 KiB slice.param.lent.rad 1.6 KiB slice.ptr.checked.bounds.rad 228 B slice.ptr.unsafe.rad 680 B slice.range.bounds.check.rad 301 B slice.range.capacity.bounds.rad 349 B slice.range.capacity.rad 1.8 KiB slice.range.dynamic.rad 883 B slice.range.order.check.rad 300 B slice.range.rad 682 B slice.range.ril 2.2 KiB slice.reserve.limit.rad 722 B slice.reserve.overflow.rad 1.6 KiB slice.reserve.rad 2.2 KiB slice.reserve.result.rad 634 B slice.reserve.result.ril 1.1 KiB slice.resize.extend.rad 793 B slice.resize.extend.ril 2.8 KiB slice.resize.fill.snapshot.rad 1.5 KiB slice.runtime.i32.rad 279 B slice.runtime.i32.ril 873 B slice.runtime.literal.rad 271 B slice.runtime.literal.ril 564 B slice.sizes.rad 13.1 KiB slice.sub.bounds.rad 407 B slice.sub.order.rad 357 B slice.sub.values.rad 1.1 KiB slice.subslice.rad 1.5 KiB slice.take.control.rad 1.4 KiB slice.take.lower.rad 410 B slice.take.lower.ril 351 B slice.take.neighbors.rad 1.8 KiB slice.take.rad 1.9 KiB slice.take.sizes.rad 2.7 KiB slice.zero-sized.limit.rad 345 B slice.zero-sized.rad 1.6 KiB spill.blockarg.clobber.rad 3.6 KiB spill.loop.rad 1.7 KiB stack.local.corrupt.rad 335 B static.array.mutate.rad 441 B static.assign.rad 138 B static.assign.ril 278 B static.basic.rad 361 B static.empty.slice.optional.rad 902 B static.fn.array.rad 628 B static.local.decl.rad 208 B static.local.decl.ril 458 B static.move.reject.rad 566 B static.mutation.reject.rad 3.4 KiB static.optional.nil.rad 1.0 KiB static.owned.alias.reject.rad 499 B static.record.array.rad 546 B static.reference.call.reject.rad 984 B static.scalar.rad 109 B static.scalar.ril 169 B static.slice.empty.rad 375 B static.slice.empty.record.table.rad 2.4 KiB static.slice.empty.ril 729 B static.slice.empty.table.rad 1.6 KiB static.slice.index.assign.rad 450 B static.slice.offset.rad 719 B static.zero.bss.rad 1.1 KiB static.zero.record.repeat.rad 759 B static.zero.record.repeat.ril 581 B string.basic.rad 162 B string.escape.rad 364 B string.index.rad 129 B switch.blockargs.clobber.rad 1.4 KiB trait.aggregate.ret.rad 1.7 KiB trait.array.optional.rad 1.8 KiB trait.basic.rad 632 B trait.control.flow.rad 1.2 KiB trait.dispatch.rad 333 B trait.dispatch.ril 801 B trait.fn.param.rad 1.8 KiB trait.multiple.methods.rad 1.3 KiB trait.multiple.traits.rad 1.3 KiB trait.multiple.types.rad 1.4 KiB trait.object.narrow.rad 1.7 KiB trait.object.rad 408 B trait.object.ril 642 B trait.optional.coerce.rad 1.0 KiB trait.param.names.shared.rad 759 B trait.supertrait.forward.rad 693 B trait.supertrait.rad 2.7 KiB trait.supertrait.ril 4.0 KiB trait.throws.rad 1.0 KiB trait.type.local.reject.rad 357 B trait.type.scoped.reject.rad 333 B trait.writer.rad 2.8 KiB trivial.phi.rad 1.1 KiB trivial.phi.ril 512 B try.basic.rad 402 B try.basic.ril 702 B try.catch.rad 350 B try.catch.ril 637 B try.optional.rad 374 B try.optional.ril 736 B try.panic.rad 362 B try.panic.ril 516 B try.reference.rad 911 B try.reference.ril 2.0 KiB type.unify.rad 4.7 KiB undefined.aggregate.rad 165 B undefined.aggregate.ril 114 B undefined.bitvalid.rad 2.7 KiB undefined.merge.dominance.rad 1.1 KiB undefined.merge.dominance.ril 934 B undefined.merge.one.path.rad 197 B undefined.merge.one.path.ril 119 B undefined.merge.pointer.rad 661 B undefined.merge.rad 1.9 KiB undefined.primitive.rad 122 B undefined.primitive.ril 48 B undefined.rad 459 B undefined.record.field.rad 1.6 KiB undefined.record.field.ril 849 B undefined.unsafe.rad 868 B union-tag.rad 967 B union.bitfield.rad 1.2 KiB union.ctor.rad 574 B union.ctor.ril 509 B union.discriminant.cast.rad 391 B union.edge.case.2.rad 699 B union.edge.case.3.rad 674 B union.eq.rad 827 B union.eq.ril 1.5 KiB union.eq.void.ctor.rad 389 B union.eq.void.ctor.ril 131 B union.eq.void.rad 189 B union.eq.void.ril 75 B union.match.bind.rad 275 B union.match.bind.ril 256 B union.match.ref.rad 1.1 KiB union.match.ref.ril 1.3 KiB union.match.tag.rad 910 B union.match.tag.ril 821 B union.mixed.alias.rad 1.1 KiB union.mixed.assign.rad 1002 B union.mixed.rad 9.9 KiB union.mixed.snapshot.rad 1.7 KiB union.payload.mutref.rad 1.5 KiB union.payload.rad 666 B union.payload.record.eq.rad 304 B union.payload.record.eq.ril 1.0 KiB union.record.forward.rad 1.3 KiB union.record.literal.rad 457 B union.record.literal.ril 418 B union.variant.access.rad 753 B union.variant.access.ril 692 B union.variants.limit.reject.rad 1.4 KiB union.variants.max.rad 1.3 KiB union.void.call.rad 1.5 KiB union.void.match.rad 427 B union.void.rad 969 B unop.rad 701 B unop.ril 506 B unsafe.block.bounds.rad 268 B unsafe.block.rad 866 B unsafe.static.rad 535 B unsigned.compare.rad 1.8 KiB var.align.rad 996 B var.infer.rad 574 B var.shadow.rad 244 B var.shadow.ril 145 B void.throw.rad 281 B void.throw.ril 601 B voidfn.rad 18 B voidfn.ril 44 B trap/ verify/ Makefile 9.2 KiB kernel.rad 776 B runner.rad 11.6 KiB vim/ .gitignore 333 B .gitsigners 224 B AGENTS.md 8.3 KiB CONTRIBUTING 2.1 KiB LICENSE 1.1 KiB Makefile 2.5 KiB README 3.4 KiB STYLE 3.2 KiB std.lib 2.1 KiB std.lib.test 1.1 KiB
test/tests/match.nested.enum.byref.rad 27.3 KiB raw
1
//! returns: 0
2
//! Nested enum patterns (unions without payloads) test the same values when the
3
//! subject is matched by reference, pointer, or value, in every position a
4
//! nested pattern can take: record variant fields, positional fields, optional
5
//! fields, nested records, alternatives, guards, and the conditional forms.
6
7
union Class: Copy {
8
    Owned, Ref, Raw,
9
}
10
11
/// Enum with explicit discriminants, including one above the signed byte range.
12
union Level: Copy {
13
    Low = 5, Mid = 7, High = 200,
14
}
15
16
union Ty: Copy {
17
    Ptr { class: Class },
18
    Sl { class: Class, level: Level },
19
    Pos(Class, Level),
20
    Opt { class: ?Class },
21
    Other,
22
}
23
24
record Rec: Copy { class: Class, n: u32 }
25
record Deep: Copy { inner: Rec, tag: u8 }
26
27
union Wrap: Copy {
28
    Deep { d: Deep },
29
    Rec { r: Rec },
30
    None,
31
}
32
33
/// A record whose only field is an enum, which lowers as the enum itself.
34
record Cell: Copy { class: Class }
35
36
union CellBox: Copy {
37
    Item { cell: Cell, n: u32 }, None,
38
}
39
40
// Record variant field //
41
42
fn recordField(t: &Ty) -> u32 {
43
    match t {
44
        case Ty::Ptr { class: Class::Ref }                    => return 1,
45
        case Ty::Ptr { class: Class::Owned }                  => return 2,
46
        case Ty::Ptr { class: _ }                             => return 3,
47
        case Ty::Sl { class: Class::Raw, level: Level::High } => return 4,
48
        case Ty::Sl { class: Class::Ref, level: Level::Low }  => return 5,
49
        case Ty::Sl { class: _, level: Level::Mid }           => return 6,
50
        else                                                  => return 7,
51
    }
52
}
53
54
fn recordFieldMut(t: &mut Ty) -> u32 {
55
    match t {
56
        case Ty::Ptr { class: Class::Ref }                    => return 1,
57
        case Ty::Ptr { class: Class::Owned }                  => return 2,
58
        case Ty::Sl { class: Class::Raw, level: Level::High } => return 4,
59
        else                                                  => return 7,
60
    }
61
}
62
63
fn recordFieldValue(t: Ty) -> u32 {
64
    match t {
65
        case Ty::Ptr { class: Class::Ref }                    => return 1,
66
        case Ty::Ptr { class: Class::Owned }                  => return 2,
67
        case Ty::Ptr { class: _ }                             => return 3,
68
        case Ty::Sl { class: Class::Raw, level: Level::High } => return 4,
69
        case Ty::Sl { class: Class::Ref, level: Level::Low }  => return 5,
70
        case Ty::Sl { class: _, level: Level::Mid }           => return 6,
71
        else                                                  => return 7,
72
    }
73
}
74
75
fn recordFieldAddress(t: Ty) -> u32 {
76
    match &t {
77
        case Ty::Ptr { class: Class::Ref }                    => return 1,
78
        case Ty::Ptr { class: Class::Owned }                  => return 2,
79
        case Ty::Ptr { class: _ }                             => return 3,
80
        case Ty::Sl { class: Class::Raw, level: Level::High } => return 4,
81
        case Ty::Sl { class: Class::Ref, level: Level::Low }  => return 5,
82
        case Ty::Sl { class: _, level: Level::Mid }           => return 6,
83
        else                                                  => return 7,
84
    }
85
}
86
87
fn recordFieldMutAddress(t: Ty) -> u32 {
88
    let mut m = t;
89
    match &mut m {
90
        case Ty::Ptr { class: Class::Ref }                    => return 1,
91
        case Ty::Sl { class: Class::Raw, level: Level::High } => return 4,
92
        else                                                  => return 7,
93
    }
94
}
95
96
// Positional fields //
97
98
fn positional(t: &Ty) -> u32 {
99
    match t {
100
        case Ty::Pos(Class::Raw, Level::Mid)  => return 1,
101
        case Ty::Pos(Class::Ref, Level::High) => return 2,
102
        case Ty::Pos(Class::Owned, _)         => return 3,
103
        case Ty::Pos(_, Level::Low)           => return 4,
104
        else                                  => return 7,
105
    }
106
}
107
108
fn positionalValue(t: Ty) -> u32 {
109
    match t {
110
        case Ty::Pos(Class::Raw, Level::Mid)  => return 1,
111
        case Ty::Pos(Class::Ref, Level::High) => return 2,
112
        case Ty::Pos(Class::Owned, _)         => return 3,
113
        case Ty::Pos(_, Level::Low)           => return 4,
114
        else                                  => return 7,
115
    }
116
}
117
118
// Optional fields //
119
120
fn optionalField(t: &Ty) -> u32 {
121
    match t {
122
        case Ty::Opt { class: Class::Ref } => return 1,
123
        case Ty::Opt { class: nil }        => return 2,
124
        case Ty::Opt { class: _ }          => return 3,
125
        else                               => return 7,
126
    }
127
}
128
129
fn optionalFieldValue(t: Ty) -> u32 {
130
    match t {
131
        case Ty::Opt { class: Class::Ref } => return 1,
132
        case Ty::Opt { class: nil }        => return 2,
133
        case Ty::Opt { class: _ }          => return 3,
134
        else                               => return 7,
135
    }
136
}
137
138
// Nested records //
139
140
fn deep(w: &Wrap) -> u32 {
141
    match w {
142
        case Wrap::Deep { d: Deep { inner: Rec { class: Class::Ref, n: 1 }, tag: 3 } } => return 1,
143
        case Wrap::Deep { d: Deep { inner: Rec { class: Class::Raw, n: _ }, tag: _ } } => return 2,
144
        case Wrap::Deep { d: Deep { inner: Rec { class: _, n: 9 }, tag: 200 } } => return 3,
145
        case Wrap::Rec { r: Rec { class: Class::Owned, n } } => return 10 + *n,
146
        case Wrap::Rec { r: Rec { class: Class::Ref, n: _ } } => return 4,
147
        else => return 7,
148
    }
149
}
150
151
fn deepValue(w: Wrap) -> u32 {
152
    match w {
153
        case Wrap::Deep { d: Deep { inner: Rec { class: Class::Ref, n: 1 }, tag: 3 } } => return 1,
154
        case Wrap::Deep { d: Deep { inner: Rec { class: Class::Raw, n: _ }, tag: _ } } => return 2,
155
        case Wrap::Deep { d: Deep { inner: Rec { class: _, n: 9 }, tag: 200 } } => return 3,
156
        case Wrap::Rec { r: Rec { class: Class::Owned, n } } => return 10 + n,
157
        case Wrap::Rec { r: Rec { class: Class::Ref, n: _ } } => return 4,
158
        else => return 7,
159
    }
160
}
161
162
/// A record subject has the enum in a field.
163
fn recordSubject(r: &Rec) -> u32 {
164
    match r {
165
        case Rec { class: Class::Ref, n: 1 } => return 1,
166
        case Rec { class: Class::Raw, n: _ } => return 2,
167
        case Rec { class: _, n: 5 }          => return 3,
168
        else                                 => return 7,
169
    }
170
}
171
172
fn recordSubjectValue(r: Rec) -> u32 {
173
    match r {
174
        case Rec { class: Class::Ref, n: 1 } => return 1,
175
        case Rec { class: Class::Raw, n: _ } => return 2,
176
        case Rec { class: _, n: 5 }          => return 3,
177
        else                                 => return 7,
178
    }
179
}
180
181
/// A scalar record subject is the enum itself.
182
fn cellSubject(c: &Cell) -> u32 {
183
    match c {
184
        case Cell { class: Class::Ref } => return 1,
185
        case Cell { class: Class::Raw } => return 2,
186
        else                            => return 7,
187
    }
188
}
189
190
fn cellSubjectValue(c: Cell) -> u32 {
191
    match c {
192
        case Cell { class: Class::Ref } => return 1,
193
        case Cell { class: Class::Raw } => return 2,
194
        else                            => return 7,
195
    }
196
}
197
198
fn cellPositional(c: &Cell) -> u32 {
199
    match c {
200
        case Cell(Class::Ref) => return 1,
201
        case Cell(Class::Raw) => return 2,
202
        else                  => return 7,
203
    }
204
}
205
206
fn cellPositionalValue(c: Cell) -> u32 {
207
    match c {
208
        case Cell(Class::Ref) => return 1,
209
        case Cell(Class::Raw) => return 2,
210
        else                  => return 7,
211
    }
212
}
213
214
/// A scalar record in a variant field.
215
fn cellField(b: &CellBox) -> u32 {
216
    match b {
217
        case CellBox::Item { cell: Cell { class: Class::Ref }, n: 1 } => return 1,
218
        case CellBox::Item { cell: Cell(Class::Raw), n: _ }           => return 2,
219
        case CellBox::Item { cell: Cell { class: _ }, n: 3 }          => return 3,
220
        else                                                          => return 7,
221
    }
222
}
223
224
fn cellFieldValue(b: CellBox) -> u32 {
225
    match b {
226
        case CellBox::Item { cell: Cell { class: Class::Ref }, n: 1 } => return 1,
227
        case CellBox::Item { cell: Cell(Class::Raw), n: _ }           => return 2,
228
        case CellBox::Item { cell: Cell { class: _ }, n: 3 }          => return 3,
229
        else                                                          => return 7,
230
    }
231
}
232
233
/// A subject that is an enum.
234
fn enumSubject(c: &Class) -> u32 {
235
    match c {
236
        case Class::Ref => return 1,
237
        case Class::Raw => return 2,
238
        else            => return 7,
239
    }
240
}
241
242
fn levelSubject(l: &Level) -> u32 {
243
    match l {
244
        case Level::Low  => return 1,
245
        case Level::High => return 2,
246
        else             => return 7,
247
    }
248
}
249
250
// Alternatives and guards //
251
252
fn alternatives(t: &Ty) -> u32 {
253
    match t {
254
        case Ty::Ptr { class: Class::Ref }, Ty::Ptr { class: Class::Raw } => return 1,
255
        case
256
            Ty::Sl { class: Class::Ref, level: Level::High },
257
            Ty::Pos(Class::Ref, Level::High),
258
            Ty::Other => return 2,
259
        else => return 7,
260
    }
261
}
262
263
fn alternativesValue(t: Ty) -> u32 {
264
    match t {
265
        case Ty::Ptr { class: Class::Ref }, Ty::Ptr { class: Class::Raw } => return 1,
266
        case
267
            Ty::Sl { class: Class::Ref, level: Level::High },
268
            Ty::Pos(Class::Ref, Level::High),
269
            Ty::Other => return 2,
270
        else => return 7,
271
    }
272
}
273
274
fn guards(t: &Ty, n: u32) -> u32 {
275
    match t {
276
        case Ty::Ptr { class: Class::Ref } if n > 2                      => return 1,
277
        case Ty::Ptr { class: Class::Ref }                               => return 2,
278
        case Ty::Sl { class: Class::Owned, level: Level::Mid } if n == 0 => return 3,
279
        case Ty::Sl { class: _, level: Level::Mid } if n == 1            => return 4,
280
        else                                                             => return 7,
281
    }
282
}
283
284
fn guardsValue(t: Ty, n: u32) -> u32 {
285
    match t {
286
        case Ty::Ptr { class: Class::Ref } if n > 2                      => return 1,
287
        case Ty::Ptr { class: Class::Ref }                               => return 2,
288
        case Ty::Sl { class: Class::Owned, level: Level::Mid } if n == 0 => return 3,
289
        case Ty::Sl { class: _, level: Level::Mid } if n == 1            => return 4,
290
        else                                                             => return 7,
291
    }
292
}
293
294
// Conditional forms //
295
296
fn ifLet(t: &Ty) -> u32 {
297
    if let case Ty::Ptr { class: Class::Ref } = t {
298
        return 1;
299
    }
300
    return 7;
301
}
302
303
fn ifLetValue(t: Ty) -> u32 {
304
    if let case Ty::Ptr { class: Class::Ref } = t {
305
        return 1;
306
    }
307
    return 7;
308
}
309
310
fn ifLetAddress(t: Ty) -> u32 {
311
    if let case Ty::Sl { class: Class::Raw, level: Level::High } = &t {
312
        return 1;
313
    }
314
    return 7;
315
}
316
317
fn ifLetElse(t: &Ty) -> u32 {
318
    if let case Ty::Pos(Class::Raw, Level::Mid) = t {
319
        return 1;
320
    } else {
321
        return 7;
322
    }
323
}
324
325
fn letElse(t: &Ty) -> u32 {
326
    let case Ty::Ptr { class: Class::Ref } = t else {
327
        return 7;
328
    };
329
    return 1;
330
}
331
332
fn letElseValue(t: Ty) -> u32 {
333
    let case Ty::Ptr { class: Class::Ref } = t else {
334
        return 7;
335
    };
336
    return 1;
337
}
338
339
fn letElseMut(t: &mut Ty) -> u32 {
340
    let case Ty::Sl { class: Class::Raw, level: Level::High } = t else {
341
        return 7;
342
    };
343
    return 1;
344
}
345
346
/// Count the leading items that match, by reference.
347
fn whileLet(items: &[Ty]) -> u32 {
348
    let mut i: u32 = 0;
349
    while i < items.len {
350
        let case Ty::Ptr { class: Class::Ref } = &items[i] else {
351
            break;
352
        };
353
        set i = i + 1;
354
    }
355
    return i;
356
}
357
358
fn whileLetCase(items: &[Ty]) -> u32 {
359
    let mut i: u32 = 0;
360
    while let case Ty::Ptr { class: Class::Ref } = &items[i] {
361
        set i = i + 1;
362
        if i == items.len {
363
            break;
364
        }
365
    }
366
    return i;
367
}
368
369
fn whileLetCaseValue(items: &[Ty]) -> u32 {
370
    let mut i: u32 = 0;
371
    while let case Ty::Ptr { class: Class::Ref } = items[i] {
372
        set i = i + 1;
373
        if i == items.len {
374
            break;
375
        }
376
    }
377
    return i;
378
}
379
380
// Pointer subjects and fields //
381
382
record Holder: Copy { class: *unsafe Class, n: u32 }
383
record Boxed: Copy { rec: *unsafe Rec, n: u32 }
384
385
unsafe fn throughPointerField(h: &Holder) -> u32 {
386
    match h {
387
        case Holder { class: Class::Ref, n: 1 } => return 1,
388
        case Holder { class: Class::Raw, n: _ } => return 2,
389
        else                                    => return 7,
390
    }
391
}
392
393
unsafe fn throughPointerFieldValue(h: Holder) -> u32 {
394
    match h {
395
        case Holder { class: Class::Ref, n: 1 } => return 1,
396
        case Holder { class: Class::Raw, n: _ } => return 2,
397
        else                                    => return 7,
398
    }
399
}
400
401
unsafe fn autoDeref(b: &Boxed) -> u32 {
402
    match b {
403
        case Boxed { rec: Rec { class: Class::Ref, n: 1 }, n: _ } => return 1,
404
        case Boxed { rec: Rec { class: Class::Raw, n: _ }, n: _ } => return 2,
405
        else                                                      => return 7,
406
    }
407
}
408
409
unsafe fn autoDerefValue(b: Boxed) -> u32 {
410
    match b {
411
        case Boxed { rec: Rec { class: Class::Ref, n: 1 }, n: _ } => return 1,
412
        case Boxed { rec: Rec { class: Class::Raw, n: _ }, n: _ } => return 2,
413
        else                                                      => return 7,
414
    }
415
}
416
417
unsafe fn pointerSubject(t: *unsafe Ty) -> u32 {
418
    match t {
419
        case Ty::Ptr { class: Class::Ref }                    => return 1,
420
        case Ty::Ptr { class: Class::Owned }                  => return 2,
421
        case Ty::Sl { class: Class::Raw, level: Level::High } => return 4,
422
        else                                                  => return 7,
423
    }
424
}
425
426
unsafe fn pointerSubjectMut(t: *unsafe mut Ty) -> u32 {
427
    match t {
428
        case Ty::Ptr { class: Class::Ref }                    => return 1,
429
        case Ty::Ptr { class: Class::Owned }                  => return 2,
430
        case Ty::Sl { class: Class::Raw, level: Level::High } => return 4,
431
        else                                                  => return 7,
432
    }
433
}
434
435
// Optional subjects //
436
437
fn optionalSubject(t: ?Ty) -> u32 {
438
    match t {
439
        case Ty::Ptr { class: Class::Ref }                    => return 1,
440
        case Ty::Sl { class: Class::Raw, level: Level::High } => return 4,
441
        case nil                                              => return 5,
442
        else                                                  => return 7,
443
    }
444
}
445
446
fn optionalSubjectRef(t: &?Ty) -> u32 {
447
    match t {
448
        case Ty::Ptr { class: Class::Ref }                    => return 1,
449
        case Ty::Sl { class: Class::Raw, level: Level::High } => return 4,
450
        case nil                                              => return 5,
451
        else                                                  => return 7,
452
    }
453
}
454
455
// Tests //
456
457
fn testRecordFields() {
458
    let ptrRef = Ty::Ptr { class: Class::Ref };
459
    let ptrOwned = Ty::Ptr { class: Class::Owned };
460
    let ptrRaw = Ty::Ptr { class: Class::Raw };
461
    let slRawHigh = Ty::Sl { class: Class::Raw, level: Level::High };
462
    let slRefLow = Ty::Sl { class: Class::Ref, level: Level::Low };
463
    let slOwnedMid = Ty::Sl { class: Class::Owned, level: Level::Mid };
464
    let slRefMid = Ty::Sl { class: Class::Ref, level: Level::Mid };
465
    let slRefHigh = Ty::Sl { class: Class::Ref, level: Level::High };
466
    let slOwnedHigh = Ty::Sl { class: Class::Owned, level: Level::High };
467
    let posRawMid = Ty::Pos(Class::Raw, Level::Mid);
468
    let other = Ty::Other;
469
470
    assert recordField(&ptrRef) == 1;
471
    assert recordField(&ptrOwned) == 2;
472
    assert recordField(&ptrRaw) == 3;
473
    assert recordField(&slRawHigh) == 4;
474
    assert recordField(&slRefLow) == 5;
475
    assert recordField(&slOwnedMid) == 6;
476
    assert recordField(&slRefMid) == 6;
477
    assert recordField(&slRefHigh) == 7;
478
    assert recordField(&other) == 7;
479
    assert recordField(&posRawMid) == 7;
480
481
    let mut m = ptrRef;
482
    assert recordFieldMut(&mut m) == 1;
483
    set m = ptrOwned;
484
    assert recordFieldMut(&mut m) == 2;
485
    set m = slRawHigh;
486
    assert recordFieldMut(&mut m) == 4;
487
    set m = slOwnedHigh;
488
    assert recordFieldMut(&mut m) == 7;
489
    set m = ptrRaw;
490
    assert recordFieldMut(&mut m) == 7;
491
492
    assert recordFieldValue(ptrRef) == 1;
493
    assert recordFieldValue(ptrOwned) == 2;
494
    assert recordFieldValue(ptrRaw) == 3;
495
    assert recordFieldValue(slRawHigh) == 4;
496
    assert recordFieldValue(slRefLow) == 5;
497
    assert recordFieldValue(slOwnedMid) == 6;
498
    assert recordFieldValue(slRefHigh) == 7;
499
    assert recordFieldValue(other) == 7;
500
501
    assert recordFieldAddress(ptrRef) == 1;
502
    assert recordFieldAddress(ptrOwned) == 2;
503
    assert recordFieldAddress(ptrRaw) == 3;
504
    assert recordFieldAddress(slRawHigh) == 4;
505
    assert recordFieldAddress(slRefLow) == 5;
506
    assert recordFieldAddress(slOwnedMid) == 6;
507
    assert recordFieldAddress(slRefHigh) == 7;
508
    assert recordFieldAddress(other) == 7;
509
510
    assert recordFieldMutAddress(ptrRef) == 1;
511
    assert recordFieldMutAddress(slRawHigh) == 4;
512
    assert recordFieldMutAddress(ptrRaw) == 7;
513
    assert recordFieldMutAddress(slRefHigh) == 7;
514
}
515
516
fn testPositionalAndOptional() {
517
    let posRawMid = Ty::Pos(Class::Raw, Level::Mid);
518
    let posRefHigh = Ty::Pos(Class::Ref, Level::High);
519
    let posOwnedHigh = Ty::Pos(Class::Owned, Level::High);
520
    let posRefLow = Ty::Pos(Class::Ref, Level::Low);
521
    let posRawHigh = Ty::Pos(Class::Raw, Level::High);
522
    let optRef = Ty::Opt { class: Class::Ref };
523
    let optNil = Ty::Opt { class: nil };
524
    let optRaw = Ty::Opt { class: Class::Raw };
525
    let other = Ty::Other;
526
527
    assert positional(&posRawMid) == 1;
528
    assert positional(&posRefHigh) == 2;
529
    assert positional(&posOwnedHigh) == 3;
530
    assert positional(&posRefLow) == 4;
531
    assert positional(&posRawHigh) == 7;
532
    assert positional(&other) == 7;
533
    assert positionalValue(posRawMid) == 1;
534
    assert positionalValue(posRefHigh) == 2;
535
    assert positionalValue(posOwnedHigh) == 3;
536
    assert positionalValue(posRefLow) == 4;
537
    assert positionalValue(posRawHigh) == 7;
538
    assert positionalValue(other) == 7;
539
540
    assert optionalField(&optRef) == 1;
541
    assert optionalField(&optNil) == 2;
542
    assert optionalField(&optRaw) == 3;
543
    assert optionalField(&other) == 7;
544
    assert optionalFieldValue(optRef) == 1;
545
    assert optionalFieldValue(optNil) == 2;
546
    assert optionalFieldValue(optRaw) == 3;
547
    assert optionalFieldValue(other) == 7;
548
}
549
550
fn testRecords() {
551
    let wDeepRef = Wrap::Deep { d: Deep { inner: Rec { class: Class::Ref, n: 1 }, tag: 3 } };
552
    let wDeepRefOther = Wrap::Deep { d: Deep { inner: Rec { class: Class::Ref, n: 2 }, tag: 3 } };
553
    let wDeepRaw = Wrap::Deep { d: Deep { inner: Rec { class: Class::Raw, n: 0 }, tag: 0 } };
554
    let wDeepNine = Wrap::Deep { d: Deep { inner: Rec { class: Class::Owned, n: 9 }, tag: 200 } };
555
    let wDeepNineLow = Wrap::Deep {
556
        d: Deep {
557
            inner: Rec { class: Class::Owned, n: 9 }, tag: 100
558
        },
559
    };
560
    let wRecOwned = Wrap::Rec { r: Rec { class: Class::Owned, n: 5 } };
561
    let wRecRef = Wrap::Rec { r: Rec { class: Class::Ref, n: 5 } };
562
    let wRecRaw = Wrap::Rec { r: Rec { class: Class::Raw, n: 5 } };
563
    let wNone = Wrap::None;
564
565
    assert deep(&wDeepRef) == 1;
566
    assert deep(&wDeepRefOther) == 7;
567
    assert deep(&wDeepRaw) == 2;
568
    assert deep(&wDeepNine) == 3;
569
    assert deep(&wDeepNineLow) == 7;
570
    assert deep(&wRecOwned) == 15;
571
    assert deep(&wRecRef) == 4;
572
    assert deep(&wRecRaw) == 7;
573
    assert deep(&wNone) == 7;
574
    assert deepValue(wDeepRef) == 1;
575
    assert deepValue(wDeepRefOther) == 7;
576
    assert deepValue(wDeepRaw) == 2;
577
    assert deepValue(wDeepNine) == 3;
578
    assert deepValue(wDeepNineLow) == 7;
579
    assert deepValue(wRecOwned) == 15;
580
    assert deepValue(wRecRef) == 4;
581
    assert deepValue(wRecRaw) == 7;
582
    assert deepValue(wNone) == 7;
583
584
    let rRef1 = Rec { class: Class::Ref, n: 1 };
585
    let rRef2 = Rec { class: Class::Ref, n: 2 };
586
    let rRaw = Rec { class: Class::Raw, n: 0 };
587
    let rOwned5 = Rec { class: Class::Owned, n: 5 };
588
589
    assert recordSubject(&rRef1) == 1;
590
    assert recordSubject(&rRef2) == 7;
591
    assert recordSubject(&rRaw) == 2;
592
    assert recordSubject(&rOwned5) == 3;
593
    assert recordSubjectValue(rRef1) == 1;
594
    assert recordSubjectValue(rRef2) == 7;
595
    assert recordSubjectValue(rRaw) == 2;
596
    assert recordSubjectValue(rOwned5) == 3;
597
}
598
599
fn testScalarRecords() {
600
    let cRef = Cell { class: Class::Ref };
601
    let cRaw = Cell { class: Class::Raw };
602
    let cOwned = Cell { class: Class::Owned };
603
604
    assert cellSubject(&cRef) == 1;
605
    assert cellSubject(&cRaw) == 2;
606
    assert cellSubject(&cOwned) == 7;
607
    assert cellSubjectValue(cRef) == 1;
608
    assert cellSubjectValue(cRaw) == 2;
609
    assert cellSubjectValue(cOwned) == 7;
610
    assert cellPositional(&cRef) == 1;
611
    assert cellPositional(&cRaw) == 2;
612
    assert cellPositional(&cOwned) == 7;
613
    assert cellPositionalValue(cRef) == 1;
614
    assert cellPositionalValue(cRaw) == 2;
615
    assert cellPositionalValue(cOwned) == 7;
616
617
    let bRef1 = CellBox::Item { cell: cRef, n: 1 };
618
    let bRef2 = CellBox::Item { cell: cRef, n: 2 };
619
    let bRaw = CellBox::Item { cell: cRaw, n: 0 };
620
    let bOwned3 = CellBox::Item { cell: cOwned, n: 3 };
621
    let bOwned4 = CellBox::Item { cell: cOwned, n: 4 };
622
    let bNone = CellBox::None;
623
624
    assert cellField(&bRef1) == 1;
625
    assert cellField(&bRef2) == 7;
626
    assert cellField(&bRaw) == 2;
627
    assert cellField(&bOwned3) == 3;
628
    assert cellField(&bOwned4) == 7;
629
    assert cellField(&bNone) == 7;
630
    assert cellFieldValue(bRef1) == 1;
631
    assert cellFieldValue(bRef2) == 7;
632
    assert cellFieldValue(bRaw) == 2;
633
    assert cellFieldValue(bOwned3) == 3;
634
    assert cellFieldValue(bOwned4) == 7;
635
    assert cellFieldValue(bNone) == 7;
636
637
    let owned = Class::Owned;
638
    let ref = Class::Ref;
639
    let raw = Class::Raw;
640
    assert enumSubject(&ref) == 1;
641
    assert enumSubject(&raw) == 2;
642
    assert enumSubject(&owned) == 7;
643
644
    let low = Level::Low;
645
    let mid = Level::Mid;
646
    let high = Level::High;
647
    assert levelSubject(&low) == 1;
648
    assert levelSubject(&high) == 2;
649
    assert levelSubject(&mid) == 7;
650
}
651
652
fn testAlternativesAndGuards() {
653
    let ptrRef = Ty::Ptr { class: Class::Ref };
654
    let ptrOwned = Ty::Ptr { class: Class::Owned };
655
    let ptrRaw = Ty::Ptr { class: Class::Raw };
656
    let slRawHigh = Ty::Sl { class: Class::Raw, level: Level::High };
657
    let slOwnedMid = Ty::Sl { class: Class::Owned, level: Level::Mid };
658
    let slRefMid = Ty::Sl { class: Class::Ref, level: Level::Mid };
659
    let slRefHigh = Ty::Sl { class: Class::Ref, level: Level::High };
660
    let posRawMid = Ty::Pos(Class::Raw, Level::Mid);
661
    let posRefHigh = Ty::Pos(Class::Ref, Level::High);
662
    let other = Ty::Other;
663
664
    assert alternatives(&ptrRef) == 1;
665
    assert alternatives(&ptrRaw) == 1;
666
    assert alternatives(&ptrOwned) == 7;
667
    assert alternatives(&slRefHigh) == 2;
668
    assert alternatives(&posRefHigh) == 2;
669
    assert alternatives(&other) == 2;
670
    assert alternatives(&slRawHigh) == 7;
671
    assert alternatives(&posRawMid) == 7;
672
    assert alternativesValue(ptrRef) == 1;
673
    assert alternativesValue(ptrRaw) == 1;
674
    assert alternativesValue(ptrOwned) == 7;
675
    assert alternativesValue(slRefHigh) == 2;
676
    assert alternativesValue(posRefHigh) == 2;
677
    assert alternativesValue(other) == 2;
678
    assert alternativesValue(slRawHigh) == 7;
679
    assert alternativesValue(posRawMid) == 7;
680
681
    assert guards(&ptrRef, 3) == 1;
682
    assert guards(&ptrRef, 2) == 2;
683
    assert guards(&ptrOwned, 3) == 7;
684
    assert guards(&slOwnedMid, 0) == 3;
685
    assert guards(&slOwnedMid, 1) == 4;
686
    assert guards(&slRefMid, 1) == 4;
687
    assert guards(&slRefMid, 0) == 7;
688
    assert guards(&slRefHigh, 1) == 7;
689
    assert guardsValue(ptrRef, 3) == 1;
690
    assert guardsValue(ptrRef, 2) == 2;
691
    assert guardsValue(ptrOwned, 3) == 7;
692
    assert guardsValue(slOwnedMid, 0) == 3;
693
    assert guardsValue(slOwnedMid, 1) == 4;
694
    assert guardsValue(slRefMid, 1) == 4;
695
    assert guardsValue(slRefMid, 0) == 7;
696
    assert guardsValue(slRefHigh, 1) == 7;
697
}
698
699
fn testConditionalForms() {
700
    let ptrRef = Ty::Ptr { class: Class::Ref };
701
    let ptrOwned = Ty::Ptr { class: Class::Owned };
702
    let ptrRaw = Ty::Ptr { class: Class::Raw };
703
    let slRawHigh = Ty::Sl { class: Class::Raw, level: Level::High };
704
    let slRefHigh = Ty::Sl { class: Class::Ref, level: Level::High };
705
    let posRawMid = Ty::Pos(Class::Raw, Level::Mid);
706
    let posRawHigh = Ty::Pos(Class::Raw, Level::High);
707
    let other = Ty::Other;
708
709
    assert ifLet(&ptrRef) == 1;
710
    assert ifLet(&ptrOwned) == 7;
711
    assert ifLet(&other) == 7;
712
    assert ifLetValue(ptrRef) == 1;
713
    assert ifLetValue(ptrOwned) == 7;
714
    assert ifLetAddress(slRawHigh) == 1;
715
    assert ifLetAddress(slRefHigh) == 7;
716
    assert ifLetAddress(ptrRaw) == 7;
717
    assert ifLetElse(&posRawMid) == 1;
718
    assert ifLetElse(&posRawHigh) == 7;
719
    assert letElse(&ptrRef) == 1;
720
    assert letElse(&ptrRaw) == 7;
721
    assert letElseValue(ptrRef) == 1;
722
    assert letElseValue(ptrRaw) == 7;
723
724
    let mut m = slRawHigh;
725
    assert letElseMut(&mut m) == 1;
726
    set m = ptrRaw;
727
    assert letElseMut(&mut m) == 7;
728
729
    let run = [ptrRef, ptrRef, ptrRaw, ptrRef];
730
    assert whileLet(&run[..]) == 2;
731
    assert whileLetCase(&run[..]) == 2;
732
    assert whileLetCaseValue(&run[..]) == 2;
733
    let allRef = [ptrRef, ptrRef];
734
    assert whileLet(&allRef[..]) == 2;
735
    assert whileLetCase(&allRef[..]) == 2;
736
    assert whileLetCaseValue(&allRef[..]) == 2;
737
}
738
739
unsafe fn testPointers() {
740
    let ptrRef = Ty::Ptr { class: Class::Ref };
741
    let ptrOwned = Ty::Ptr { class: Class::Owned };
742
    let ptrRaw = Ty::Ptr { class: Class::Raw };
743
    let slRawHigh = Ty::Sl { class: Class::Raw, level: Level::High };
744
    let rRef1 = Rec { class: Class::Ref, n: 1 };
745
    let rRef2 = Rec { class: Class::Ref, n: 2 };
746
    let rRaw = Rec { class: Class::Raw, n: 0 };
747
    let rOwned5 = Rec { class: Class::Owned, n: 5 };
748
749
    let mut cls = Class::Ref;
750
    let mut h = Holder { class: &cls, n: 1 };
751
    assert throughPointerField(&h) == 1;
752
    assert throughPointerFieldValue(h) == 1;
753
    set h.n = 2;
754
    assert throughPointerField(&h) == 7;
755
    assert throughPointerFieldValue(h) == 7;
756
    set cls = Class::Raw;
757
    assert throughPointerField(&h) == 2;
758
    assert throughPointerFieldValue(h) == 2;
759
    set cls = Class::Owned;
760
    assert throughPointerField(&h) == 7;
761
    assert throughPointerFieldValue(h) == 7;
762
763
    let mut bx = Boxed { rec: &rRef1, n: 0 };
764
    assert autoDeref(&bx) == 1;
765
    assert autoDerefValue(bx) == 1;
766
    set bx.rec = &rRef2;
767
    assert autoDeref(&bx) == 7;
768
    assert autoDerefValue(bx) == 7;
769
    set bx.rec = &rRaw;
770
    assert autoDeref(&bx) == 2;
771
    assert autoDerefValue(bx) == 2;
772
    set bx.rec = &rOwned5;
773
    assert autoDeref(&bx) == 7;
774
    assert autoDerefValue(bx) == 7;
775
776
    assert pointerSubject(&ptrRef) == 1;
777
    assert pointerSubject(&ptrOwned) == 2;
778
    assert pointerSubject(&slRawHigh) == 4;
779
    assert pointerSubject(&ptrRaw) == 7;
780
    let mut m = ptrRef;
781
    assert pointerSubjectMut(&mut m) == 1;
782
    set m = ptrOwned;
783
    assert pointerSubjectMut(&mut m) == 2;
784
    set m = slRawHigh;
785
    assert pointerSubjectMut(&mut m) == 4;
786
    set m = ptrRaw;
787
    assert pointerSubjectMut(&mut m) == 7;
788
}
789
790
fn testOptionalSubjects() {
791
    let ptrRef = Ty::Ptr { class: Class::Ref };
792
    let ptrRaw = Ty::Ptr { class: Class::Raw };
793
    let slRawHigh = Ty::Sl { class: Class::Raw, level: Level::High };
794
795
    let mut o: ?Ty = ptrRef;
796
    assert optionalSubject(o) == 1;
797
    assert optionalSubjectRef(&o) == 1;
798
    set o = slRawHigh;
799
    assert optionalSubject(o) == 4;
800
    assert optionalSubjectRef(&o) == 4;
801
    set o = nil;
802
    assert optionalSubject(o) == 5;
803
    assert optionalSubjectRef(&o) == 5;
804
    set o = ptrRaw;
805
    assert optionalSubject(o) == 7;
806
    assert optionalSubjectRef(&o) == 7;
807
}
808
809
@default unsafe fn main() -> i32 {
810
    testRecordFields();
811
    testPositionalAndOptional();
812
    testRecords();
813
    testScalarRecords();
814
    testAlternativesAndGuards();
815
    testConditionalForms();
816
    testPointers();
817
    testOptionalSubjects();
818
819
    return 0;
820
}