@@ -79,46 +79,38 @@ type Hint = attr::ReprAttr;
79
79
pub enum Repr < ' tcx > {
80
80
/// C-like enums; basically an int.
81
81
CEnum ( IntType , Disr , Disr ) , // discriminant range (signedness based on the IntType)
82
- /**
83
- * Single-case variants, and structs/tuples/records.
84
- *
85
- * Structs with destructors need a dynamic destroyedness flag to
86
- * avoid running the destructor too many times; this is included
87
- * in the `Struct` if present.
88
- */
82
+ /// Single-case variants, and structs/tuples/records.
83
+ ///
84
+ /// Structs with destructors need a dynamic destroyedness flag to
85
+ /// avoid running the destructor too many times; this is included
86
+ /// in the `Struct` if present.
89
87
Univariant ( Struct < ' tcx > , bool ) ,
90
- /**
91
- * General-case enums: for each case there is a struct, and they
92
- * all start with a field for the discriminant.
93
- *
94
- * Types with destructors need a dynamic destroyedness flag to
95
- * avoid running the destructor too many times; the last argument
96
- * indicates whether such a flag is present.
97
- */
88
+ /// General-case enums: for each case there is a struct, and they
89
+ /// all start with a field for the discriminant.
90
+ ///
91
+ /// Types with destructors need a dynamic destroyedness flag to
92
+ /// avoid running the destructor too many times; the last argument
93
+ /// indicates whether such a flag is present.
98
94
General ( IntType , Vec < Struct < ' tcx > > , bool ) ,
99
- /**
100
- * Two cases distinguished by a nullable pointer: the case with discriminant
101
- * `nndiscr` must have single field which is known to be nonnull due to its type.
102
- * The other case is known to be zero sized. Hence we represent the enum
103
- * as simply a nullable pointer: if not null it indicates the `nndiscr` variant,
104
- * otherwise it indicates the other case.
105
- */
95
+ /// Two cases distinguished by a nullable pointer: the case with discriminant
96
+ /// `nndiscr` must have single field which is known to be nonnull due to its type.
97
+ /// The other case is known to be zero sized. Hence we represent the enum
98
+ /// as simply a nullable pointer: if not null it indicates the `nndiscr` variant,
99
+ /// otherwise it indicates the other case.
106
100
RawNullablePointer {
107
101
nndiscr : Disr ,
108
102
nnty : Ty < ' tcx > ,
109
103
nullfields : Vec < Ty < ' tcx > >
110
104
} ,
111
- /**
112
- * Two cases distinguished by a nullable pointer: the case with discriminant
113
- * `nndiscr` is represented by the struct `nonnull`, where the `ptrfield`th
114
- * field is known to be nonnull due to its type; if that field is null, then
115
- * it represents the other case, which is inhabited by at most one value
116
- * (and all other fields are undefined/unused).
117
- *
118
- * For example, `std::option::Option` instantiated at a safe pointer type
119
- * is represented such that `None` is a null pointer and `Some` is the
120
- * identity function.
121
- */
105
+ /// Two cases distinguished by a nullable pointer: the case with discriminant
106
+ /// `nndiscr` is represented by the struct `nonnull`, where the `ptrfield`th
107
+ /// field is known to be nonnull due to its type; if that field is null, then
108
+ /// it represents the other case, which is inhabited by at most one value
109
+ /// (and all other fields are undefined/unused).
110
+ ///
111
+ /// For example, `std::option::Option` instantiated at a safe pointer type
112
+ /// is represented such that `None` is a null pointer and `Some` is the
113
+ /// identity function.
122
114
StructWrappedNullablePointer {
123
115
nonnull : Struct < ' tcx > ,
124
116
nndiscr : Disr ,
@@ -139,11 +131,9 @@ pub struct Struct<'tcx> {
139
131
pub fields : Vec < Ty < ' tcx > >
140
132
}
141
133
142
- /**
143
- * Convenience for `represent_type`. There should probably be more or
144
- * these, for places in trans where the `Ty` isn't directly
145
- * available.
146
- */
134
+ /// Convenience for `represent_type`. There should probably be more or
135
+ /// these, for places in trans where the `Ty` isn't directly
136
+ /// available.
147
137
pub fn represent_node < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
148
138
node : ast:: NodeId ) -> Rc < Repr < ' tcx > > {
149
139
represent_type ( bcx. ccx ( ) , node_id_type ( bcx, node) )
@@ -514,16 +504,14 @@ fn ensure_enum_fits_in_address_space<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
514
504
}
515
505
516
506
517
- /**
518
- * LLVM-level types are a little complicated.
519
- *
520
- * C-like enums need to be actual ints, not wrapped in a struct,
521
- * because that changes the ABI on some platforms (see issue #10308).
522
- *
523
- * For nominal types, in some cases, we need to use LLVM named structs
524
- * and fill in the actual contents in a second pass to prevent
525
- * unbounded recursion; see also the comments in `trans::type_of`.
526
- */
507
+ /// LLVM-level types are a little complicated.
508
+ ///
509
+ /// C-like enums need to be actual ints, not wrapped in a struct,
510
+ /// because that changes the ABI on some platforms (see issue #10308).
511
+ ///
512
+ /// For nominal types, in some cases, we need to use LLVM named structs
513
+ /// and fill in the actual contents in a second pass to prevent
514
+ /// unbounded recursion; see also the comments in `trans::type_of`.
527
515
pub fn type_of < ' a , ' tcx > ( cx : & CrateContext < ' a , ' tcx > , r : & Repr < ' tcx > ) -> Type {
528
516
generic_type_of ( cx, r, None , false , false )
529
517
}
@@ -620,12 +608,10 @@ fn struct_llfields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, st: &Struct<'tcx>,
620
608
}
621
609
}
622
610
623
- /**
624
- * Obtain a representation of the discriminant sufficient to translate
625
- * destructuring; this may or may not involve the actual discriminant.
626
- *
627
- * This should ideally be less tightly tied to `_match`.
628
- */
611
+ /// Obtain a representation of the discriminant sufficient to translate
612
+ /// destructuring; this may or may not involve the actual discriminant.
613
+ ///
614
+ /// This should ideally be less tightly tied to `_match`.
629
615
pub fn trans_switch < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
630
616
r : & Repr < ' tcx > , scrutinee : ValueRef )
631
617
-> ( _match:: BranchKind , Option < ValueRef > ) {
@@ -713,12 +699,10 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
713
699
}
714
700
}
715
701
716
- /**
717
- * Yield information about how to dispatch a case of the
718
- * discriminant-like value returned by `trans_switch`.
719
- *
720
- * This should ideally be less tightly tied to `_match`.
721
- */
702
+ /// Yield information about how to dispatch a case of the
703
+ /// discriminant-like value returned by `trans_switch`.
704
+ ///
705
+ /// This should ideally be less tightly tied to `_match`.
722
706
pub fn trans_case < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > , r : & Repr , discr : Disr )
723
707
-> _match:: OptResult < ' blk , ' tcx > {
724
708
match * r {
@@ -741,10 +725,8 @@ pub fn trans_case<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr, discr: Disr)
741
725
}
742
726
}
743
727
744
- /**
745
- * Set the discriminant for a new value of the given case of the given
746
- * representation.
747
- */
728
+ /// Set the discriminant for a new value of the given case of the given
729
+ /// representation.
748
730
pub fn trans_set_discr < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > , r : & Repr < ' tcx > ,
749
731
val : ValueRef , discr : Disr ) {
750
732
match * r {
@@ -799,10 +781,8 @@ fn assert_discr_in_range(ity: IntType, min: Disr, max: Disr, discr: Disr) {
799
781
}
800
782
}
801
783
802
- /**
803
- * The number of fields in a given case; for use when obtaining this
804
- * information from the type or definition is less convenient.
805
- */
784
+ /// The number of fields in a given case; for use when obtaining this
785
+ /// information from the type or definition is less convenient.
806
786
pub fn num_args ( r : & Repr , discr : Disr ) -> uint {
807
787
match * r {
808
788
CEnum ( ..) => 0 ,
@@ -946,27 +926,25 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr<'tcx
946
926
}
947
927
}
948
928
949
- /**
950
- * Construct a constant value, suitable for initializing a
951
- * GlobalVariable, given a case and constant values for its fields.
952
- * Note that this may have a different LLVM type (and different
953
- * alignment!) from the representation's `type_of`, so it needs a
954
- * pointer cast before use.
955
- *
956
- * The LLVM type system does not directly support unions, and only
957
- * pointers can be bitcast, so a constant (and, by extension, the
958
- * GlobalVariable initialized by it) will have a type that can vary
959
- * depending on which case of an enum it is.
960
- *
961
- * To understand the alignment situation, consider `enum E { V64(u64),
962
- * V32(u32, u32) }` on Windows. The type has 8-byte alignment to
963
- * accommodate the u64, but `V32(x, y)` would have LLVM type `{i32,
964
- * i32, i32}`, which is 4-byte aligned.
965
- *
966
- * Currently the returned value has the same size as the type, but
967
- * this could be changed in the future to avoid allocating unnecessary
968
- * space after values of shorter-than-maximum cases.
969
- */
929
+ /// Construct a constant value, suitable for initializing a
930
+ /// GlobalVariable, given a case and constant values for its fields.
931
+ /// Note that this may have a different LLVM type (and different
932
+ /// alignment!) from the representation's `type_of`, so it needs a
933
+ /// pointer cast before use.
934
+ ///
935
+ /// The LLVM type system does not directly support unions, and only
936
+ /// pointers can be bitcast, so a constant (and, by extension, the
937
+ /// GlobalVariable initialized by it) will have a type that can vary
938
+ /// depending on which case of an enum it is.
939
+ ///
940
+ /// To understand the alignment situation, consider `enum E { V64(u64),
941
+ /// V32(u32, u32) }` on Windows. The type has 8-byte alignment to
942
+ /// accommodate the u64, but `V32(x, y)` would have LLVM type `{i32,
943
+ /// i32, i32}`, which is 4-byte aligned.
944
+ ///
945
+ /// Currently the returned value has the same size as the type, but
946
+ /// this could be changed in the future to avoid allocating unnecessary
947
+ /// space after values of shorter-than-maximum cases.
970
948
pub fn trans_const < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > , r : & Repr < ' tcx > , discr : Disr ,
971
949
vals : & [ ValueRef ] ) -> ValueRef {
972
950
match * r {
@@ -1019,9 +997,7 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>, discr
1019
997
}
1020
998
}
1021
999
1022
- /**
1023
- * Compute struct field offsets relative to struct begin.
1024
- */
1000
+ /// Compute struct field offsets relative to struct begin.
1025
1001
fn compute_struct_field_offsets < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1026
1002
st : & Struct < ' tcx > ) -> Vec < u64 > {
1027
1003
let mut offsets = vec ! ( ) ;
@@ -1040,16 +1016,14 @@ fn compute_struct_field_offsets<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1040
1016
offsets
1041
1017
}
1042
1018
1043
- /**
1044
- * Building structs is a little complicated, because we might need to
1045
- * insert padding if a field's value is less aligned than its type.
1046
- *
1047
- * Continuing the example from `trans_const`, a value of type `(u32,
1048
- * E)` should have the `E` at offset 8, but if that field's
1049
- * initializer is 4-byte aligned then simply translating the tuple as
1050
- * a two-element struct will locate it at offset 4, and accesses to it
1051
- * will read the wrong memory.
1052
- */
1019
+ /// Building structs is a little complicated, because we might need to
1020
+ /// insert padding if a field's value is less aligned than its type.
1021
+ ///
1022
+ /// Continuing the example from `trans_const`, a value of type `(u32,
1023
+ /// E)` should have the `E` at offset 8, but if that field's
1024
+ /// initializer is 4-byte aligned then simply translating the tuple as
1025
+ /// a two-element struct will locate it at offset 4, and accesses to it
1026
+ /// will read the wrong memory.
1053
1027
fn build_const_struct < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1054
1028
st : & Struct < ' tcx > , vals : & [ ValueRef ] )
1055
1029
-> Vec < ValueRef > {
@@ -1130,13 +1104,11 @@ pub fn const_get_discrim(ccx: &CrateContext, r: &Repr, val: ValueRef)
1130
1104
}
1131
1105
}
1132
1106
1133
- /**
1134
- * Extract a field of a constant value, as appropriate for its
1135
- * representation.
1136
- *
1137
- * (Not to be confused with `common::const_get_elt`, which operates on
1138
- * raw LLVM-level structs and arrays.)
1139
- */
1107
+ /// Extract a field of a constant value, as appropriate for its
1108
+ /// representation.
1109
+ ///
1110
+ /// (Not to be confused with `common::const_get_elt`, which operates on
1111
+ /// raw LLVM-level structs and arrays.)
1140
1112
pub fn const_get_field ( ccx : & CrateContext , r : & Repr , val : ValueRef ,
1141
1113
_discr : Disr , ix : uint ) -> ValueRef {
1142
1114
match * r {
0 commit comments