Skip to content

Commit 63093c3

Browse files
authored
Merge pull request #1991 from GaloisInc/T1859-mir_enums
MIR enums
2 parents 9d68017 + 658f6fd commit 63093c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1873
-111
lines changed

crucible-mir-comp/src/Mir/Compositional/Builder.hs

+11
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ substMethodSpec sc sm ms = do
629629
MS.SetupStruct b svs -> MS.SetupStruct b <$> mapM goSetupValue svs
630630
MS.SetupTuple b svs -> MS.SetupTuple b <$> mapM goSetupValue svs
631631
MS.SetupSlice slice -> MS.SetupSlice <$> goSetupSlice slice
632+
MS.SetupEnum enum_ -> MS.SetupEnum <$> goSetupEnum enum_
632633
MS.SetupArray b svs -> MS.SetupArray b <$> mapM goSetupValue svs
633634
MS.SetupElem b sv idx -> MS.SetupElem b <$> goSetupValue sv <*> pure idx
634635
MS.SetupField b sv name -> MS.SetupField b <$> goSetupValue sv <*> pure name
@@ -644,6 +645,14 @@ substMethodSpec sc sm ms = do
644645
goSetupCondition (MS.SetupCond_Ghost loc gg tt) =
645646
MS.SetupCond_Ghost loc gg <$> goTypedTerm tt
646647

648+
goSetupEnum (MirSetupEnumVariant adt variant variantIdx svs) =
649+
MirSetupEnumVariant adt variant variantIdx <$>
650+
mapM goSetupValue svs
651+
goSetupEnum (MirSetupEnumSymbolic adt discr variants) =
652+
MirSetupEnumSymbolic adt <$>
653+
goSetupValue discr <*>
654+
mapM (mapM goSetupValue) variants
655+
647656
goSetupSlice (MirSetupSliceRaw ref len) =
648657
MirSetupSliceRaw <$> goSetupValue ref <*> goSetupValue len
649658
goSetupSlice (MirSetupSlice arr) =
@@ -742,6 +751,8 @@ regToSetup bak p eval shp rv = go shp rv
742751
refSV <- go refShp refRV
743752
lenSV <- go lenShp lenRV
744753
pure $ MS.SetupSlice $ MirSetupSliceRaw refSV lenSV
754+
go (EnumShape _ _ _ _ _) _ =
755+
error "Enums not currently supported in overrides"
745756
go (FnPtrShape _ _ _) _ =
746757
error "Function pointers not currently supported in overrides"
747758

crucible-mir-comp/src/Mir/Compositional/Clobber.hs

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ clobberSymbolic sym loc nameStr shp rv = go shp rv
6262
", but got Any wrapping " ++ show tpr
6363
where shpTpr = StructRepr $ fmapFC fieldShapeType flds
6464
go (TransparentShape _ shp) rv = go shp rv
65+
go (EnumShape _ _ _ _ _) _rv =
66+
error "Enums not currently supported in overrides"
6567
go (FnPtrShape _ _ _) _rv =
6668
error "Function pointers not currently supported in overrides"
6769
go (RefShape _ _ _ _) _rv = error "clobberSymbolic: RefShape NYI"
@@ -120,6 +122,8 @@ clobberImmutSymbolic sym loc nameStr shp rv = go shp rv
120122
ref' <- go refShp ref
121123
len' <- go lenShp len
122124
pure $ Ctx.Empty Ctx.:> RV ref' Ctx.:> RV len'
125+
go (EnumShape _ _ _ _ _) _rv =
126+
error "Enums not currently supported in overrides"
123127
go (FnPtrShape _ _ _) _rv =
124128
error "Function pointers not currently supported in overrides"
125129

crucible-mir-comp/src/Mir/Compositional/Override.hs

+2
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@ setupToReg sym sc termSub regMap allocMap shp sv = go shp sv
544544
refRV <- go refShp refSV
545545
lenRV <- go lenShp lenSV
546546
pure $ Ctx.Empty Ctx.:> RV refRV Ctx.:> RV lenRV
547+
go (EnumShape _ _ _ _ _) _ =
548+
error "Enums not currently supported in overrides"
547549
go (FnPtrShape _ _ _) _ =
548550
error "Function pointers not currently supported in overrides"
549551
go shp sv = error $ "setupToReg: type error: bad SetupValue for " ++ show (shapeType shp) ++

crux-mir-comp/src/Mir/Cryptol.hs

+2
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ munge sym shp rv = do
337337
AnyValue tpr <$> goFields flds rvs
338338
| otherwise = error $ "munge: StructShape AnyValue with NYI TypeRepr " ++ show tpr
339339
go (TransparentShape _ shp) rv = go shp rv
340+
go (EnumShape _ _ _ _ _) _ =
341+
error "Enums not currently supported in overrides"
340342
go (FnPtrShape _ _ _) _ =
341343
error "Function pointers not currently supported in overrides"
342344
-- TODO: RefShape

doc/manual/manual.md

+149-11
Original file line numberDiff line numberDiff line change
@@ -2117,12 +2117,9 @@ mir_verify :
21172117

21182118
### Running a MIR-based verification
21192119

2120-
`mir_verify` requires `enable_experimental` in order to be used. Moreover,
2121-
some parts of `mir_verify` are not currently implemented, so it is possible
2122-
that using `mir_verify` on some programs will fail. Features that are not yet
2123-
implemented include the following:
2124-
2125-
* The ability to construct MIR `enum` values in specifications
2120+
(Note: API functions involving MIR verification require `enable_experimental`
2121+
in order to be used. As such, some parts of this API may change before being
2122+
finalized.)
21262123

21272124
The `String` supplied as an argument to `mir_verify` is expected to be a
21282125
function _identifier_. An identifier is expected adhere to one of the following
@@ -2212,6 +2209,14 @@ internally. The second parameter is the LLVM, Java, or MIR type of the
22122209
variable. The resulting `Term` can be used in various subsequent
22132210
commands.
22142211

2212+
Note that the second parameter to `{llvm,jvm,mir}_fresh_var` must be a type
2213+
that has a counterpart in Cryptol. (For more information on this, refer to the
2214+
"Cryptol type correspondence" section.) If the type does not have a Cryptol
2215+
counterpart, the function will raise an error. If you do need to create a fresh
2216+
value of a type that cannot be represented in Cryptol, consider using a
2217+
function such as `llvm_fresh_expanded_val` (for LLVM verification) or
2218+
`mir_fresh_expanded_value` (for MIR verification).
2219+
22152220
LLVM types are built with this set of functions:
22162221

22172222
* `llvm_int : Int -> LLVMType`
@@ -2306,6 +2311,86 @@ The `llvm_term`, `jvm_term`, and `mir_term` functions create a `SetupValue`,
23062311
* `jvm_term : Term -> JVMValue`
23072312
* `mir_term : Term -> MIRValue`
23082313

2314+
The value that these functions return will have an LLVM, JVM, or MIR type
2315+
corresponding to the Cryptol type of the `Term` argument. (For more information
2316+
on this, refer to the "Cryptol type correspondence" section.) If the type does
2317+
not have a Cryptol counterpart, the function will raise an error.
2318+
2319+
### Cryptol type correspondence
2320+
2321+
The `{llvm,jvm,mir}_fresh_var` functions take an LLVM, JVM, or MIR type as an
2322+
argument and produces a `Term` variable of the corresponding Cryptol type as
2323+
output. Similarly, the `{llvm,jvm,mir}_term` functions take a Cryptol `Term` as
2324+
input and produce a value of the corresponding LLVM, JVM, or MIR type as
2325+
output. This section describes precisely which types can be converted to
2326+
Cryptol types (and vice versa) in this way.
2327+
2328+
#### LLVM verification
2329+
2330+
The following LLVM types correspond to Cryptol types:
2331+
2332+
* `llvm_alias <name>`: Corresponds to the same Cryptol type as the type used
2333+
in the definition of `<name>`.
2334+
* `llvm_array <n> <ty>`: Corresponds to the Cryptol sequence `[<n>][<cty>]`,
2335+
where `<cty>` is the Cryptol type corresponding to `<ty>`.
2336+
* `llvm_int <n>`: Corresponds to the Cryptol word `[<n>]`.
2337+
* `llvm_struct [<ty_1>, ..., <ty_n>]` and `llvm_packed_struct [<ty_1>, ..., <ty_n>]`:
2338+
Corresponds to the Cryptol tuple `(<cty_1>, ..., <cty_n>)`, where `<cty_i>`
2339+
is the Cryptol type corresponding to `<ty_i>` for each `i` ranging from `1`
2340+
to `n`.
2341+
2342+
The following LLVM types do _not_ correspond to Cryptol types:
2343+
2344+
* `llvm_double`
2345+
* `llvm_float`
2346+
* `llvm_pointer`
2347+
2348+
#### JVM verification
2349+
2350+
The following Java types correspond to Cryptol types:
2351+
2352+
* `java_array <n> <ty>`: Corresponds to the Cryptol sequence `[<n>][<cty>]`,
2353+
where `<cty>` is the Cryptol type corresponding to `<ty>`.
2354+
* `java_bool`: Corresponds to the Cryptol `Bit` type.
2355+
* `java_byte`: Corresponds to the Cryptol `[8]` type.
2356+
* `java_char`: Corresponds to the Cryptol `[16]` type.
2357+
* `java_int`: Corresponds to the Cryptol `[32]` type.
2358+
* `java_long`: Corresponds to the Cryptol `[64]` type.
2359+
* `java_short`: Corresponds to the Cryptol `[16]` type.
2360+
2361+
The following Java types do _not_ correspond to Cryptol types:
2362+
2363+
* `java_class`
2364+
* `java_double`
2365+
* `java_float`
2366+
2367+
#### MIR verification
2368+
2369+
The following MIR types correspond to Cryptol types:
2370+
2371+
* `mir_array <n> <ty>`: Corresponds to the Cryptol sequence `[<n>][<cty>]`,
2372+
where `<cty>` is the Cryptol type corresponding to `<ty>`.
2373+
* `mir_bool`: Corresponds to the Cryptol `Bit` type.
2374+
* `mir_char`: Corresponds to the Cryptol `[32]` type.
2375+
* `mir_i8` and `mir_u8`: Corresponds to the Cryptol `[8]` type.
2376+
* `mir_i16` and `mir_u16`: Corresponds to the Cryptol `[16]` type.
2377+
* `mir_i32` and `mir_u32`: Corresponds to the Cryptol `[32]` type.
2378+
* `mir_i64` and `mir_u64`: Corresponds to the Cryptol `[64]` type.
2379+
* `mir_i128` and `mir_u128`: Corresponds to the Cryptol `[128]` type.
2380+
* `mir_isize` and `mir_usize`: Corresponds to the Cryptol `[32]` type.
2381+
* `mir_tuple [<ty_1>, ..., <ty_n>]`: Corresponds to the Cryptol tuple
2382+
`(<cty_1>, ..., <cty_n>)`, where `<cty_i>` is the Cryptol type corresponding
2383+
to `<ty_i>` for each `i` ranging from `1` to `n`.
2384+
2385+
The following MIR types do _not_ correspond to Cryptol types:
2386+
2387+
* `mir_adt`
2388+
* `mir_f32`
2389+
* `mir_f64`
2390+
* `mir_ref` and `mir_ref_mut`
2391+
* `mir_slice`
2392+
* `mir_str`
2393+
23092394
## Executing
23102395

23112396
Once the initial state has been configured, the `{llvm,jvm,mir}_execute_func`
@@ -2926,14 +3011,23 @@ construct compound values:
29263011
* `mir_array_value : MIRType -> [MIRValue] -> MIRValue` constructs an array
29273012
of the given type whose elements consist of the given values. Supplying the
29283013
element type is necessary to support length-0 arrays.
3014+
* `mir_enum_value : MIRAdt -> String -> [MIRValue] -> MIRValue` constructs an
3015+
enum using a particular enum variant. The `MIRAdt` arguments determines what
3016+
enum type to create, the `String` value determines the name of the variant to
3017+
use, and the `[MIRValue]` list are the values to use as elements in the
3018+
variant.
3019+
3020+
See the "Finding MIR algebraic data types" section (as well as the "Enums"
3021+
subsection) for more information on how to compute a `MIRAdt` value to pass
3022+
to `mir_enum_value`.
29293023
* `mir_slice_value : MIRValue -> MIRValue`: see the "MIR slices" section below.
29303024
* `mir_slice_range_value : MIRValue -> Int -> Int -> MIRValue`: see the
29313025
"MIR slices" section below.
29323026
* `mir_struct_value : MIRAdt -> [MIRValue] -> MIRValue` construct a struct
29333027
with the given list of values as elements. The `MIRAdt` argument determines
29343028
what struct type to create.
29353029

2936-
See the "Finding MIR alegraic data types" section for more information on how
3030+
See the "Finding MIR algebraic data types" section for more information on how
29373031
to compute a `MIRAdt` value to pass to `mir_struct_value`.
29383032
* `mir_tuple_value : [MIRValue] -> MIRValue` construct a tuple with the given
29393033
list of values as elements.
@@ -3040,7 +3134,7 @@ SAW's support for slices is currently limited:
30403134
If either of these limitations prevent you from using SAW, please file an issue
30413135
[on GitHub](https://github.com/GaloisInc/saw-script/issues).
30423136

3043-
### Finding MIR alegraic data types
3137+
### Finding MIR algebraic data types
30443138

30453139
We collectively refer to MIR `struct`s and `enum`s together as _algebraic data
30463140
types_, or ADTs for short. ADTs have identifiers to tell them apart, and a
@@ -3102,9 +3196,53 @@ s_8_16 <- mir_find_adt m "example::S" [mir_u8, mir_u16];
31023196
s_32_64 <- mir_find_adt m "example::S" [mir_u32, mir_u64];
31033197
~~~~
31043198

3105-
The `mir_adt` command (for constructing a struct type) and `mir_struct_value`
3106-
(for constructing a struct value) commands in turn take a `MIRAdt` as an
3107-
argument.
3199+
The `mir_adt` command (for constructing a struct type), `mir_struct_value` (for
3200+
constructing a struct value), and `mir_enum_value` (for constructing an enum
3201+
value) commands in turn take a `MIRAdt` as an argument.
3202+
3203+
#### Enums
3204+
3205+
In addition to taking a `MIRAdt` as an argument, `mir_enum_value` also takes a
3206+
`String` representing the name of the variant to construct. The variant name
3207+
should be a short name such as `"None"` or `"Some"`, and not a full identifier
3208+
such as `"core::option::Option::None"` or `"core::option::Option::Some"`. This
3209+
is because the `MIRAdt` already contains the full identifiers for all of an
3210+
enum's variants, so SAW will use this information to look up a variant's
3211+
identifier from a short name. Here is an example of using `mir_enum_value` in
3212+
practice:
3213+
3214+
~~~~ .rs
3215+
pub fn n() -> Option<u32> {
3216+
None
3217+
}
3218+
3219+
pub fn s(x: u32) -> Option<u32> {
3220+
Some(x)
3221+
}
3222+
~~~~
3223+
~~~~
3224+
m <- mir_load_module "example.linked-mir.json";
3225+
3226+
option_u32 <- mir_find_adt m "core::option::Option" [mir_u32];
3227+
3228+
let n_spec = do {
3229+
mir_execute_func [];
3230+
3231+
mir_return (mir_enum_value option_u32 "None" []);
3232+
};
3233+
3234+
let s_spec = do {
3235+
x <- mir_fresh_var "x" mir_u32;
3236+
3237+
mir_execute_func [mir_term x];
3238+
3239+
mir_return (mir_enum_value option_u32 "Some" [mir_term x]);
3240+
};
3241+
~~~~
3242+
3243+
Note that `mir_enum_value` can only be used to construct a specific variant. If
3244+
you need to construct a symbolic enum value that can range over many potential
3245+
variants, use `mir_fresh_expanded_value` instead.
31083246

31093247
### Bitfields
31103248

doc/manual/manual.pdf

5.97 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
all: test.linked-mir.json
2+
3+
test.linked-mir.json: test.rs
4+
saw-rustc $<
5+
$(MAKE) remove-unused-build-artifacts
6+
7+
.PHONY: remove-unused-build-artifacts
8+
remove-unused-build-artifacts:
9+
rm -f test libtest.mir libtest.rlib
10+
11+
.PHONY: clean
12+
clean: remove-unused-build-artifacts
13+
rm -f test.linked-mir.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"fns":[{"abi":{"kind":"Rust"},"args":[{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::Adt::3fa7c2d95c7fce06"}],"body":{"blocks":[{"block":{"data":[{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_2","ty":"ty::isize"}},"pos":"test.rs:2:11: 2:12","rhs":{"kind":"Discriminant","ty":"ty::isize","val":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::Adt::3fa7c2d95c7fce06"}}}}],"terminator":{"discr":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_2","ty":"ty::isize"}},"kind":"Move"},"discr_span":"test.rs:3:9: 3:16","kind":"SwitchInt","pos":"test.rs:2:5: 2:12","switch_ty":"ty::isize","targets":["bb1","bb3","bb2"],"values":["0","1"]}},"blockid":"bb0"},{"block":{"data":[{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::u32"}},"pos":"test.rs:4:17: 4:19","rhs":{"kind":"Use","usevar":{"data":{"rendered":{"kind":"uint","size":4,"val":"27"},"ty":"ty::u32"},"kind":"Constant"}}}],"terminator":{"kind":"Goto","pos":"test.rs:4:17: 4:19","target":"bb4"}},"blockid":"bb1"},{"block":{"data":[],"terminator":{"kind":"Unreachable","pos":"test.rs:2:11: 2:12"}},"blockid":"bb2"},{"block":{"data":[{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Not"},"name":"_3","ty":"ty::u32"}},"pos":"test.rs:3:14: 3:15","rhs":{"kind":"Use","usevar":{"data":{"data":[{"kind":"Downcast","variant":1},{"field":0,"kind":"Field","ty":"ty::u32"}],"var":{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::Adt::3fa7c2d95c7fce06"}},"kind":"Copy"}}},{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::u32"}},"pos":"test.rs:3:20: 3:21","rhs":{"kind":"Use","usevar":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Not"},"name":"_3","ty":"ty::u32"}},"kind":"Copy"}}}],"terminator":{"kind":"Goto","pos":"test.rs:3:20: 3:21","target":"bb4"}},"blockid":"bb3"},{"block":{"data":[],"terminator":{"kind":"Return","pos":"test.rs:6:2: 6:2"}},"blockid":"bb4"}],"vars":[{"is_zst":false,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::u32"},{"is_zst":false,"mut":{"kind":"Mut"},"name":"_2","ty":"ty::isize"},{"is_zst":false,"mut":{"kind":"Not"},"name":"_3","ty":"ty::u32"}]},"name":"test/b38ac280::f","return_ty":"ty::u32","spread_arg":null},{"abi":{"kind":"Rust"},"args":[{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::Adt::3fa7c2d95c7fce06"}],"body":{"blocks":[{"block":{"data":[{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_3","ty":"ty::Adt::3fa7c2d95c7fce06"}},"pos":"test.rs:13:7: 13:8","rhs":{"kind":"Use","usevar":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::Adt::3fa7c2d95c7fce06"}},"kind":"Copy"}}}],"terminator":{"args":[{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_3","ty":"ty::Adt::3fa7c2d95c7fce06"}},"kind":"Move"}],"cleanup":null,"destination":[{"data":[],"var":{"is_zst":true,"mut":{"kind":"Not"},"name":"_2","ty":"ty::Tuple::e93222e871854c41"}},"bb1"],"from_hir_call":true,"func":{"data":{"rendered":{"kind":"zst"},"ty":"ty::FnDef::779a68152b60006a"},"kind":"Constant"},"kind":"Call","pos":"test.rs:13:5: 13:9"}},"blockid":"bb0"},{"block":{"data":[],"terminator":{"kind":"Return","pos":"test.rs:14:2: 14:2"}},"blockid":"bb1"}],"vars":[{"is_zst":true,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Tuple::e93222e871854c41"},{"is_zst":true,"mut":{"kind":"Not"},"name":"_2","ty":"ty::Tuple::e93222e871854c41"},{"is_zst":false,"mut":{"kind":"Mut"},"name":"_3","ty":"ty::Adt::3fa7c2d95c7fce06"}]},"name":"test/b38ac280::gg","return_ty":"ty::Tuple::e93222e871854c41","spread_arg":null},{"abi":{"kind":"Rust"},"args":[{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::Adt::3fa7c2d95c7fce06"}],"body":{"blocks":[{"block":{"data":[{"kind":"Assign","lhs":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_3","ty":"ty::Adt::3fa7c2d95c7fce06"}},"pos":"test.rs:9:7: 9:8","rhs":{"kind":"Use","usevar":{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Not"},"name":"_1","ty":"ty::Adt::3fa7c2d95c7fce06"}},"kind":"Copy"}}}],"terminator":{"args":[{"data":{"data":[],"var":{"is_zst":false,"mut":{"kind":"Mut"},"name":"_3","ty":"ty::Adt::3fa7c2d95c7fce06"}},"kind":"Move"}],"cleanup":null,"destination":[{"data":[],"var":{"is_zst":false,"mut":{"kind":"Not"},"name":"_2","ty":"ty::u32"}},"bb1"],"from_hir_call":true,"func":{"data":{"rendered":{"kind":"zst"},"ty":"ty::FnDef::946bbc4c46985e3c"},"kind":"Constant"},"kind":"Call","pos":"test.rs:9:5: 9:9"}},"blockid":"bb0"},{"block":{"data":[],"terminator":{"kind":"Return","pos":"test.rs:10:2: 10:2"}},"blockid":"bb1"}],"vars":[{"is_zst":true,"mut":{"kind":"Mut"},"name":"_0","ty":"ty::Tuple::e93222e871854c41"},{"is_zst":false,"mut":{"kind":"Not"},"name":"_2","ty":"ty::u32"},{"is_zst":false,"mut":{"kind":"Mut"},"name":"_3","ty":"ty::Adt::3fa7c2d95c7fce06"}]},"name":"test/b38ac280::g","return_ty":"ty::Tuple::e93222e871854c41","spread_arg":null}],"adts":[{"kind":{"discr_ty":"ty::isize","kind":"Enum"},"name":"core/73237d41::option::Option::_adtc5e93708b8ca6e2a[0]","orig_def_id":"core/73237d41::option::Option","orig_substs":["ty::u32"],"repr_transparent":false,"size":8,"variants":[{"ctor_kind":{"kind":"Const"},"discr":{"index":0,"kind":"Relative"},"discr_value":"0","fields":[],"inhabited":true,"name":"core/73237d41::option::Option::None"},{"ctor_kind":{"kind":"Fn"},"discr":{"index":1,"kind":"Relative"},"discr_value":"1","fields":[{"name":"core/73237d41::option::Option::Some::0","ty":"ty::u32"}],"inhabited":true,"name":"core/73237d41::option::Option::Some"}]}],"statics":[],"vtables":[],"traits":[],"intrinsics":[{"inst":{"def_id":"test/b38ac280::f","kind":"Item","substs":[]},"name":"test/b38ac280::f"},{"inst":{"def_id":"test/b38ac280::gg","kind":"Item","substs":[]},"name":"test/b38ac280::gg"},{"inst":{"def_id":"test/b38ac280::g","kind":"Item","substs":[]},"name":"test/b38ac280::g"}],"tys":[{"name":"ty::u32","ty":{"kind":"Uint","uintkind":{"kind":"U32"}}},{"name":"ty::Adt::3fa7c2d95c7fce06","ty":{"kind":"Adt","name":"core/73237d41::option::Option::_adtc5e93708b8ca6e2a[0]","orig_def_id":"core/73237d41::option::Option","substs":["ty::u32"]}},{"name":"ty::isize","ty":{"intkind":{"kind":"Isize"},"kind":"Int"}},{"name":"ty::Tuple::e93222e871854c41","ty":{"kind":"Tuple","tys":[]}},{"name":"ty::FnDef::779a68152b60006a","ty":{"defid":"test/b38ac280::g","kind":"FnDef"}},{"name":"ty::FnDef::946bbc4c46985e3c","ty":{"defid":"test/b38ac280::f","kind":"FnDef"}}],"roots":["test/b38ac280::f","test/b38ac280::g","test/b38ac280::gg"]}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn f(x: Option<u32>) -> u32 {
2+
match x {
3+
Some(x) => x,
4+
None => 27,
5+
}
6+
}
7+
8+
pub fn g(x: Option<u32>) {
9+
f(x);
10+
}
11+
12+
pub fn gg(x: Option<u32>) {
13+
g(x);
14+
}

0 commit comments

Comments
 (0)