blob: 7926f00db16775454f0d322a537b681863783b5b [file] [log] [blame]
Bob Haarmanac82f6c2020-09-08 18:59:40 +00001mrustc-0.9.0 fails to compile out of the box:
2src/common.hpp:268:28: error: cannot increment value of type
3 'std::__1::__wrap_iter<const AST::Attribute *>'
4
5This patch fixes the code so that it compiles.
6
7diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp
8index 827ac2d..4cb0061 100644
9--- a/src/ast/ast.cpp
10+++ b/src/ast/ast.cpp
11@@ -47,6 +47,13 @@ const Attribute* AttributeList::get(const char *name) const
12 return 0;
13 }
14
15+::std::ostream& operator<<(::std::ostream& os, const AttributeList& x) {
16+ for(const auto& i : x.m_items) {
17+ os << "#[" << i << "]";
18+ }
19+ return os;
20+}
21+
22 Attribute Attribute::clone() const
23 {
24 TU_MATCHA( (m_data), (e),
25diff --git a/src/ast/attrs.hpp b/src/ast/attrs.hpp
26index 7a6ce86..452debb 100644
27--- a/src/ast/attrs.hpp
28+++ b/src/ast/attrs.hpp
29@@ -12,48 +12,6 @@
30
31 //
32 class Attribute;
33-::std::ostream& operator<<(::std::ostream& os, const Attribute& x);
34-
35-/// A list of attributes on an item (searchable by the attribute name)
36-class AttributeList
37-{
38-public:
39- ::std::vector<Attribute> m_items;
40-
41- AttributeList() {}
42- AttributeList(::std::vector<Attribute> items):
43- m_items( mv$(items) )
44- {
45- }
46-
47- // Move present
48- AttributeList(AttributeList&&) = default;
49- AttributeList& operator=(AttributeList&&) = default;
50- // No copy assign, but explicit copy
51- explicit AttributeList(const AttributeList&) = default;
52- AttributeList& operator=(const AttributeList&) = delete;
53- // Explicit clone
54- AttributeList clone() const;
55-
56- void push_back(Attribute i);
57-
58- const Attribute* get(const char *name) const;
59- Attribute* get(const char *name) {
60- return const_cast<Attribute*>( const_cast<const AttributeList*>(this)->get(name));
61- }
62- bool has(const char *name) const {
63- return get(name) != 0;
64- }
65-
66- friend ::std::ostream& operator<<(::std::ostream& os, const AttributeList& x) {
67- for(const auto& i : x.m_items) {
68- os << "#[" << i << "]";
69- }
70- return os;
71- }
72-};
73-
74-
75 TAGGED_UNION(AttributeData, None,
76 (None, struct {}),
77 (String, struct {
78@@ -153,7 +99,42 @@ public:
79 }
80 };
81
82+::std::ostream& operator<<(::std::ostream& os, const Attribute& x);
83+
84+/// A list of attributes on an item (searchable by the attribute name)
85+class AttributeList
86+{
87+public:
88+ ::std::vector<Attribute> m_items;
89+
90+ AttributeList() {}
91+ AttributeList(::std::vector<Attribute> items):
92+ m_items( mv$(items) )
93+ {
94+ }
95+
96+ // Move present
97+ AttributeList(AttributeList&&) = default;
98+ AttributeList& operator=(AttributeList&&) = default;
99+ // No copy assign, but explicit copy
100+ explicit AttributeList(const AttributeList&) = default;
101+ AttributeList& operator=(const AttributeList&) = delete;
102+ // Explicit clone
103+ AttributeList clone() const;
104+
105+ void push_back(Attribute i);
106+
107+ const Attribute* get(const char *name) const;
108+ Attribute* get(const char *name) {
109+ return const_cast<Attribute*>( const_cast<const AttributeList*>(this)->get(name));
110+ }
111+ bool has(const char *name) const {
112+ return get(name) != 0;
113+ }
114+};
115+
116+::std::ostream& operator<<(::std::ostream& os, const AttributeList& x);
117+
118 } // namespace AST
119
120 #endif
121-