}
}
+void
+CfgStrip::maybe_strip_struct_expr_fields (
+ std::vector<std::unique_ptr<AST::StructExprField>> &fields)
+{
+ for (auto it = fields.begin (); it != fields.end ();)
+ {
+ auto &field = *it;
+
+ auto &field_attrs = field->get_outer_attrs ();
+ expand_cfg_attrs (field_attrs);
+ if (fails_cfg_with_expand (field_attrs))
+ {
+ it = fields.erase (it);
+ continue;
+ }
+
+ ++it;
+ }
+}
+
void
CfgStrip::maybe_strip_tuple_fields (std::vector<AST::TupleField> &fields)
{
"cannot strip expression in this position - outer "
"attributes not allowed");
}
+
+ maybe_strip_struct_expr_fields (expr.get_fields ());
}
void
}
AST::DefaultASTVisitor::visit (struct_item);
+
+ /* strip struct fields if required - this is presumably
+ * allowed by spec */
+ maybe_strip_struct_fields (struct_item.get_fields ());
}
void
CfgStrip::visit (AST::TupleStruct &tuple_struct)
void go (AST::Crate &crate);
void maybe_strip_struct_fields (std::vector<AST::StructField> &fields);
+ void maybe_strip_struct_expr_fields (
+ std::vector<std::unique_ptr<AST::StructExprField>> &fields);
void maybe_strip_tuple_fields (std::vector<AST::TupleField> &fields);
void maybe_strip_function_params (
std::vector<std::unique_ptr<AST::Param>> ¶ms);
--- /dev/null
+pub struct ReadDir {
+ pub inner: i32,
+ #[cfg(not(A))]
+ pub end_of_stream: bool,
+ #[cfg(A)]
+ pub end_of_stream_but_different: bool,
+}
+
+fn main() {
+ // Success
+ let _ = ReadDir {
+ inner: 14,
+ #[cfg(not(A))]
+ end_of_stream: false,
+ #[cfg(A)]
+ end_of_stream_but_different: false,
+ };
+
+ // Error
+ let _ = ReadDir {
+ inner: 14,
+ end_of_stream: false,
+ end_of_stream_but_different: false, // { dg-error "failed to resolve type for field" }
+ // { dg-error "unknown field" "" { target *-*-* } .-1 }
+ // { dg-prune-output "compilation terminated" }
+ };
+}