File tree 4 files changed +23
-9
lines changed
4 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -933,6 +933,11 @@ class Item : public Stmt
933
933
// behavior that we have items that can also be expressions?
934
934
bool is_item () const override { return true ; }
935
935
936
+ virtual std::vector<Attribute> &get_outer_attrs () = 0;
937
+ virtual const std::vector<Attribute> &get_outer_attrs () const = 0;
938
+
939
+ virtual bool has_outer_attrs () const { return !get_outer_attrs ().empty (); }
940
+
936
941
protected:
937
942
// Clone function implementation as pure virtual method
938
943
virtual Item *clone_item_impl () const = 0;
Original file line number Diff line number Diff line change @@ -2762,15 +2762,15 @@ class RangeExpr : public ExprWithoutBlock
2762
2762
public:
2763
2763
Location get_locus () const override final { return locus; }
2764
2764
2765
- // should never be called - error if called
2766
- void set_outer_attrs (std::vector<Attribute> /* new_attrs */ ) override
2765
+ std::vector<Attribute> &get_outer_attrs () override final
2767
2766
{
2767
+ // RangeExpr cannot have any outer attributes
2768
2768
rust_assert (false );
2769
2769
}
2770
2770
2771
- std::vector<Attribute> &get_outer_attrs () override
2771
+ // should never be called - error if called
2772
+ void set_outer_attrs (std::vector<Attribute> /* new_attrs */ ) override
2772
2773
{
2773
- // RangeExpr cannot have any outer attributes
2774
2774
rust_assert (false );
2775
2775
}
2776
2776
};
Original file line number Diff line number Diff line change @@ -979,8 +979,11 @@ class VisItem : public Item
979
979
Visibility &get_visibility () { return visibility; }
980
980
const Visibility &get_visibility () const { return visibility; }
981
981
982
- std::vector<Attribute> &get_outer_attrs () { return outer_attrs; }
983
- const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
982
+ std::vector<Attribute> &get_outer_attrs () override { return outer_attrs; }
983
+ const std::vector<Attribute> &get_outer_attrs () const override
984
+ {
985
+ return outer_attrs;
986
+ }
984
987
};
985
988
986
989
// Rust module item - abstract base class
Original file line number Diff line number Diff line change @@ -541,8 +541,11 @@ class MacroRulesDefinition : public VisItem
541
541
bool is_marked_for_strip () const override { return rule_name.empty (); }
542
542
543
543
// TODO: this mutable getter seems really dodgy. Think up better way.
544
- std::vector<Attribute> &get_outer_attrs () { return outer_attrs; }
545
- const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
544
+ std::vector<Attribute> &get_outer_attrs () override { return outer_attrs; }
545
+ const std::vector<Attribute> &get_outer_attrs () const override
546
+ {
547
+ return outer_attrs;
548
+ }
546
549
547
550
std::vector<MacroRule> &get_macro_rules () { return rules; }
548
551
const std::vector<MacroRule> &get_macro_rules () const { return rules; }
@@ -651,7 +654,10 @@ class MacroInvocation : public TypeNoBounds,
651
654
return invoc_data.is_marked_for_strip ();
652
655
}
653
656
654
- const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
657
+ const std::vector<Attribute> &get_outer_attrs () const override
658
+ {
659
+ return outer_attrs;
660
+ }
655
661
std::vector<Attribute> &get_outer_attrs () override { return outer_attrs; }
656
662
657
663
void set_outer_attrs (std::vector<Attribute> new_attrs) override
You can’t perform that action at this time.
0 commit comments