@@ -35,9 +35,7 @@ class TypePath;
35
35
// A type generic parameter (as opposed to a lifetime generic parameter)
36
36
class TypeParam : public GenericParam
37
37
{
38
- // bool has_outer_attribute;
39
- // std::unique_ptr<Attribute> outer_attr;
40
- AST::Attribute outer_attr;
38
+ AST::AttrVec outer_attrs;
41
39
42
40
Identifier type_representation;
43
41
@@ -59,24 +57,24 @@ class TypeParam : public GenericParam
59
57
bool has_type_param_bounds () const { return !type_param_bounds.empty (); }
60
58
61
59
// Returns whether the type param has an outer attribute.
62
- bool has_outer_attribute () const { return !outer_attr. is_empty (); }
63
- AST::Attribute & get_outer_attribute () { return outer_attr ; }
60
+ bool has_outer_attribute () const override { return outer_attrs. size () > 0 ; }
61
+ AST::AttrVec & get_outer_attrs () override { return outer_attrs ; }
64
62
65
63
TypeParam (Analysis::NodeMapping mappings, Identifier type_representation,
66
64
location_t locus = UNDEF_LOCATION,
67
65
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds
68
66
= std::vector<std::unique_ptr<TypeParamBound>> (),
69
67
std::unique_ptr<Type> type = nullptr ,
70
- AST::Attribute outer_attr = AST::Attribute::create_empty ())
71
- : GenericParam (mappings), outer_attr (std::move (outer_attr )),
68
+ AST::AttrVec outer_attrs = std::vector<AST::Attribute> ())
69
+ : GenericParam (mappings), outer_attrs (std::move (outer_attrs )),
72
70
type_representation (std::move (type_representation)),
73
71
type_param_bounds (std::move (type_param_bounds)),
74
72
type (std::move (type)), locus (locus)
75
73
{}
76
74
77
75
// Copy constructor uses clone
78
76
TypeParam (TypeParam const &other)
79
- : GenericParam (other.mappings), outer_attr (other.outer_attr ),
77
+ : GenericParam (other.mappings), outer_attrs (other.outer_attrs ),
80
78
type_representation (other.type_representation), locus (other.locus)
81
79
{
82
80
// guard to prevent null pointer dereference
@@ -92,7 +90,7 @@ class TypeParam : public GenericParam
92
90
TypeParam &operator = (TypeParam const &other)
93
91
{
94
92
type_representation = other.type_representation ;
95
- outer_attr = other.outer_attr ;
93
+ outer_attrs = other.outer_attrs ;
96
94
locus = other.locus ;
97
95
mappings = other.mappings ;
98
96
@@ -2741,6 +2739,7 @@ class ImplBlock : public VisItem, public WithInnerAttrs
2741
2739
BoundPolarity polarity;
2742
2740
location_t locus;
2743
2741
std::vector<std::unique_ptr<ImplItem>> impl_items;
2742
+ bool unsafe;
2744
2743
2745
2744
public:
2746
2745
ImplBlock (Analysis::NodeMapping mappings,
@@ -2749,20 +2748,20 @@ class ImplBlock : public VisItem, public WithInnerAttrs
2749
2748
std::unique_ptr<Type> impl_type,
2750
2749
std::unique_ptr<TypePath> trait_ref, WhereClause where_clause,
2751
2750
BoundPolarity polarity, Visibility vis, AST::AttrVec inner_attrs,
2752
- AST::AttrVec outer_attrs, location_t locus)
2751
+ AST::AttrVec outer_attrs, location_t locus, bool unsafe = false )
2753
2752
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
2754
2753
WithInnerAttrs (std::move (inner_attrs)),
2755
2754
generic_params (std::move (generic_params)),
2756
2755
impl_type (std::move (impl_type)), trait_ref (std::move (trait_ref)),
2757
2756
where_clause (std::move (where_clause)), polarity (polarity),
2758
- locus (locus), impl_items (std::move (impl_items))
2757
+ locus (locus), impl_items (std::move (impl_items)), unsafe (unsafe)
2759
2758
{}
2760
2759
2761
2760
ImplBlock (ImplBlock const &other)
2762
2761
: VisItem (other), WithInnerAttrs (other.inner_attrs),
2763
2762
impl_type (other.impl_type->clone_type ()),
2764
2763
where_clause (other.where_clause), polarity (other.polarity),
2765
- locus (other.locus)
2764
+ locus (other.locus), unsafe (other.unsafe)
2766
2765
{
2767
2766
generic_params.reserve (other.generic_params .size ());
2768
2767
for (const auto &e : other.generic_params )
@@ -2781,6 +2780,7 @@ class ImplBlock : public VisItem, public WithInnerAttrs
2781
2780
polarity = other.polarity ;
2782
2781
inner_attrs = other.inner_attrs ;
2783
2782
locus = other.locus ;
2783
+ unsafe = other.unsafe ;
2784
2784
2785
2785
generic_params.reserve (other.generic_params .size ());
2786
2786
for (const auto &e : other.generic_params )
@@ -2801,6 +2801,8 @@ class ImplBlock : public VisItem, public WithInnerAttrs
2801
2801
// Returns whether inherent impl block has inherent impl items.
2802
2802
bool has_impl_items () const { return !impl_items.empty (); }
2803
2803
2804
+ bool is_unsafe () const { return unsafe; }
2805
+
2804
2806
void accept_vis (HIRFullVisitor &vis) override ;
2805
2807
void accept_vis (HIRStmtVisitor &vis) override ;
2806
2808
void accept_vis (HIRVisItemVisitor &vis) override ;
0 commit comments