aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-ast.h3
-rw-r--r--gcc/rust/ast/rust-path.h2
-rw-r--r--gcc/rust/backend/rust-tree.cc88
-rw-r--r--gcc/rust/backend/rust-tree.h211
-rw-r--r--gcc/rust/hir/rust-ast-lower-base.cc35
-rw-r--r--gcc/rust/hir/rust-ast-lower-type.h18
-rw-r--r--gcc/rust/hir/tree/rust-hir-full-test.cc15
-rw-r--r--gcc/rust/hir/tree/rust-hir-path.h74
-rw-r--r--gcc/rust/hir/tree/rust-hir-type.h140
-rw-r--r--gcc/rust/hir/tree/rust-hir.h67
-rw-r--r--gcc/rust/privacy/rust-privacy-reporter.cc12
-rw-r--r--gcc/rust/privacy/rust-privacy-reporter.h3
-rw-r--r--gcc/rust/privacy/rust-reachability.cc2
-rw-r--r--gcc/rust/typecheck/rust-hir-trait-resolve.cc8
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-implitem.h8
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-item.h4
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-stmt.h20
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-toplevel.h24
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check.cc4
-rw-r--r--gcc/testsuite/rust/compile/privacy5.rs3
20 files changed, 560 insertions, 181 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index b4d401c..76324dc 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1381,6 +1381,9 @@ public:
}
bool has_type () { return type != nullptr; }
+ bool has_default_value () { return default_value != nullptr; }
+
+ const Identifier &get_name () const { return name; }
std::unique_ptr<AST::Type> &get_type ()
{
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index 232f11c..6e2b020 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -191,6 +191,8 @@ public:
Kind get_kind () const { return kind; }
+ std::unique_ptr<AST::Expr> &get_expression () { return expression; }
+
std::string as_string () const
{
switch (get_kind ())
diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc
index a2a8a22..a71b584 100644
--- a/gcc/rust/backend/rust-tree.cc
+++ b/gcc/rust/backend/rust-tree.cc
@@ -760,4 +760,92 @@ out:
#undef WALK_SUBTREE
}
+// forked from gcc/cp/tree.cc cp_expr_location
+
+/* Like EXPR_LOCATION, but also handle some tcc_exceptional that have
+ locations. */
+
+location_t
+cp_expr_location (const_tree t_)
+{
+ tree t = CONST_CAST_TREE (t_);
+ if (t == NULL_TREE)
+ return UNKNOWN_LOCATION;
+
+ return EXPR_LOCATION (t);
+}
+
+// forked from gcc/cp/class.cc
+
+/* Returns true if TYPE contains no actual data, just various
+ possible combinations of empty classes. If IGNORE_VPTR is true,
+ a vptr doesn't prevent the class from being considered empty. Typically
+ we want to ignore the vptr on assignment, and not on initialization. */
+
+bool
+is_really_empty_class (tree type, bool ignore_vptr)
+{
+ if (CLASS_TYPE_P (type))
+ {
+ tree field;
+ tree binfo;
+ tree base_binfo;
+ int i;
+
+ /* CLASSTYPE_EMPTY_P isn't set properly until the class is actually laid
+ out, but we'd like to be able to check this before then. */
+ if (COMPLETE_TYPE_P (type) && is_empty_class (type))
+ return true;
+
+ if (!ignore_vptr && TYPE_CONTAINS_VPTR_P (type))
+ return false;
+
+ for (binfo = TYPE_BINFO (type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
+ if (!is_really_empty_class (BINFO_TYPE (base_binfo), ignore_vptr))
+ return false;
+ for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
+ if (TREE_CODE (field) == FIELD_DECL
+ && !DECL_ARTIFICIAL (field)
+ /* An unnamed bit-field is not a data member. */
+ && !DECL_UNNAMED_BIT_FIELD (field)
+ && !is_really_empty_class (TREE_TYPE (field), ignore_vptr))
+ return false;
+ return true;
+ }
+ else if (TREE_CODE (type) == ARRAY_TYPE)
+ return (integer_zerop (array_type_nelts_top (type))
+ || is_really_empty_class (TREE_TYPE (type), ignore_vptr));
+ return false;
+}
+
+// forked from gcc/cp/class.cc is_empty_class
+
+/* Returns 1 if TYPE contains only padding bytes. */
+
+int
+is_empty_class (tree type)
+{
+ if (type == error_mark_node)
+ return 0;
+
+ if (!CLASS_TYPE_P (type))
+ return 0;
+
+ return CLASSTYPE_EMPTY_P (type);
+}
+
+// forked from gcc/cp/tree.cc array_type_nelts_top
+
+/* Return, as an INTEGER_CST node, the number of elements for TYPE
+ (which is an ARRAY_TYPE). This counts only elements of the top
+ array. */
+
+tree
+array_type_nelts_top (tree type)
+{
+ return fold_build2_loc (input_location, PLUS_EXPR, sizetype,
+ array_type_nelts (type), size_one_node);
+}
+
} // namespace Rust
diff --git a/gcc/rust/backend/rust-tree.h b/gcc/rust/backend/rust-tree.h
index f164a10..b564090 100644
--- a/gcc/rust/backend/rust-tree.h
+++ b/gcc/rust/backend/rust-tree.h
@@ -111,8 +111,186 @@
has been duly initialized in its constructor. */
#define TREE_HAS_CONSTRUCTOR(NODE) (TREE_LANG_FLAG_4 (NODE))
+/* Nonzero if T is a class type. Zero for template type parameters,
+ typename types, and so forth. */
+#define CLASS_TYPE_P(T) \
+ (RECORD_OR_UNION_CODE_P (TREE_CODE (T)) && TYPE_LANG_FLAG_5 (T))
+
+/* [class.virtual]
+
+ A class that declares or inherits a virtual function is called a
+ polymorphic class. */
+#define TYPE_POLYMORPHIC_P(NODE) (TREE_LANG_FLAG_2 (NODE))
+
+/* Nonzero if this class has a virtual function table pointer. */
+#define TYPE_CONTAINS_VPTR_P(NODE) \
+ (TYPE_POLYMORPHIC_P (NODE) || CLASSTYPE_VBASECLASSES (NODE))
+
+/* A vector of BINFOs for the direct and indirect virtual base classes
+ that this type uses in a post-order depth-first left-to-right
+ order. (In other words, these bases appear in the order that they
+ should be initialized.) */
+#define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
+
+/* A vector of BINFOs for the direct and indirect virtual base classes
+ that this type uses in a post-order depth-first left-to-right
+ order. (In other words, these bases appear in the order that they
+ should be initialized.) */
+#define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
+
+/* We used to have a variant type for lang_type. Keep the name of the
+ checking accessor for the sole survivor. */
+#define LANG_TYPE_CLASS_CHECK(NODE) (TYPE_LANG_SPECIFIC (NODE))
+
+/* Keep these checks in ascending code order. */
+#define RECORD_OR_UNION_CODE_P(T) ((T) == RECORD_TYPE || (T) == UNION_TYPE)
+#define OVERLOAD_TYPE_P(T) (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
+
+/* Nonzero if this class is "empty" in the sense of the C++ ABI. */
+#define CLASSTYPE_EMPTY_P(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->empty_p)
+
+// Below macros are copied from gcc/c-family/c-common.h
+
+/* In a FIELD_DECL, nonzero if the decl was originally a bitfield. */
+#define DECL_C_BIT_FIELD(NODE) (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) == 1)
+#define SET_DECL_C_BIT_FIELD(NODE) \
+ (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 1)
+#define CLEAR_DECL_C_BIT_FIELD(NODE) \
+ (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 0)
+
+/* True if the decl was an unnamed bitfield. */
+#define DECL_UNNAMED_BIT_FIELD(NODE) \
+ (DECL_C_BIT_FIELD (NODE) && !DECL_NAME (NODE))
+
+// Above macros are copied from gcc/c-family/c-common.h
+
+// forked from gcc/cp/cp-tree.h treee_pair_s
+
+struct GTY (()) tree_pair_s
+{
+ tree purpose;
+ tree value;
+};
+
+// forked from gcc/cp/cp-tree.h tree_pair_p
+
+typedef tree_pair_s *tree_pair_p;
+
+// forked from gcc/cp/cp-tree.h lang_type
+
+/* This structure provides additional information above and beyond
+ what is provide in the ordinary tree_type. In the past, we used it
+ for the types of class types, template parameters types, typename
+ types, and so forth. However, there can be many (tens to hundreds
+ of thousands) of template parameter types in a compilation, and
+ there's no need for this additional information in that case.
+ Therefore, we now use this data structure only for class types.
+
+ In the past, it was thought that there would be relatively few
+ class types. However, in the presence of heavy use of templates,
+ many (i.e., thousands) of classes can easily be generated.
+ Therefore, we should endeavor to keep the size of this structure to
+ a minimum. */
+struct GTY (()) lang_type
+{
+ unsigned char align;
+
+ unsigned has_type_conversion : 1;
+ unsigned has_copy_ctor : 1;
+ unsigned has_default_ctor : 1;
+ unsigned const_needs_init : 1;
+ unsigned ref_needs_init : 1;
+ unsigned has_const_copy_assign : 1;
+ unsigned use_template : 2;
+
+ unsigned has_mutable : 1;
+ unsigned com_interface : 1;
+ unsigned non_pod_class : 1;
+ unsigned nearly_empty_p : 1;
+ unsigned user_align : 1;
+ unsigned has_copy_assign : 1;
+ unsigned has_new : 1;
+ unsigned has_array_new : 1;
+
+ unsigned gets_delete : 2;
+ unsigned interface_only : 1;
+ unsigned interface_unknown : 1;
+ unsigned contains_empty_class_p : 1;
+ unsigned anon_aggr : 1;
+ unsigned non_zero_init : 1;
+ unsigned empty_p : 1;
+ /* 32 bits allocated. */
+
+ unsigned vec_new_uses_cookie : 1;
+ unsigned declared_class : 1;
+ unsigned diamond_shaped : 1;
+ unsigned repeated_base : 1;
+ unsigned being_defined : 1;
+ unsigned debug_requested : 1;
+ unsigned fields_readonly : 1;
+ unsigned ptrmemfunc_flag : 1;
+
+ unsigned lazy_default_ctor : 1;
+ unsigned lazy_copy_ctor : 1;
+ unsigned lazy_copy_assign : 1;
+ unsigned lazy_destructor : 1;
+ unsigned has_const_copy_ctor : 1;
+ unsigned has_complex_copy_ctor : 1;
+ unsigned has_complex_copy_assign : 1;
+ unsigned non_aggregate : 1;
+
+ unsigned has_complex_dflt : 1;
+ unsigned has_list_ctor : 1;
+ unsigned non_std_layout : 1;
+ unsigned is_literal : 1;
+ unsigned lazy_move_ctor : 1;
+ unsigned lazy_move_assign : 1;
+ unsigned has_complex_move_ctor : 1;
+ unsigned has_complex_move_assign : 1;
+
+ unsigned has_constexpr_ctor : 1;
+ unsigned unique_obj_representations : 1;
+ unsigned unique_obj_representations_set : 1;
+ bool erroneous : 1;
+ bool non_pod_aggregate : 1;
+
+ /* When adding a flag here, consider whether or not it ought to
+ apply to a template instance if it applies to the template. If
+ so, make sure to copy it in instantiate_class_template! */
+
+ /* There are some bits left to fill out a 32-bit word. Keep track
+ of this by updating the size of this bitfield whenever you add or
+ remove a flag. */
+ unsigned dummy : 3;
+
+ tree primary_base;
+ vec<tree_pair_s, va_gc> *vcall_indices;
+ tree vtables;
+ tree typeinfo_var;
+ vec<tree, va_gc> *vbases;
+ tree as_base;
+ vec<tree, va_gc> *pure_virtuals;
+ tree friend_classes;
+ vec<tree, va_gc> *GTY ((reorder ("resort_type_member_vec"))) members;
+ tree key_method;
+ tree decl_list;
+ tree befriending_classes;
+ /* In a RECORD_TYPE, information specific to Objective-C++, such
+ as a list of adopted protocols or a pointer to a corresponding
+ @interface. See objc/objc-act.h for details. */
+ tree objc_info;
+ /* FIXME reuse another field? */
+ tree lambda_expr;
+};
+
namespace Rust {
+// forked from gcc/cp/cp-tree.h tsubst_flags_t
+
+/* This type is used for parameters and variables which hold
+ combinations of the flags in enum tsubst_flags. */
+typedef int tsubst_flags_t;
+
// forked from gcc/cp/cvt.cc convert_to_void
//
// When an expression is used in a void context, its value is discarded and
@@ -220,6 +398,20 @@ get_fndecl_from_callee (tree fn);
extern tree
pointer_offset_expression (tree base_tree, tree index_tree, location_t locus);
+/* A tree node, together with a location, so that we can track locations
+ (and ranges) during parsing.
+
+ The location is redundant for node kinds that have locations,
+ but not all node kinds do (e.g. constants, and references to
+ params, locals, etc), so we stash a copy here. */
+
+extern location_t cp_expr_location (const_tree);
+
+extern int
+is_empty_class (tree type);
+
+extern tree array_type_nelts_top (tree);
+
extern tree
rs_walk_subtrees (tree *, int *, walk_tree_fn, void *, hash_set<tree> *);
#define rs_walk_tree(tp, func, data, pset) \
@@ -227,6 +419,25 @@ rs_walk_subtrees (tree *, int *, walk_tree_fn, void *, hash_set<tree> *);
#define rs_walk_tree_without_duplicates(tp, func, data) \
walk_tree_without_duplicates_1 (tp, func, data, rs_walk_subtrees)
+// forked from gcc/cp/cp-tree.h cp_expr_loc_or_loc
+
+inline location_t
+cp_expr_loc_or_loc (const_tree t, location_t or_loc)
+{
+ location_t loc = cp_expr_location (t);
+ if (loc == UNKNOWN_LOCATION)
+ loc = or_loc;
+ return loc;
+}
+
+// forked from gcc/cp/cp-tree.h cp_expr_loc_or_input_loc
+
+inline location_t
+cp_expr_loc_or_input_loc (const_tree t)
+{
+ return cp_expr_loc_or_loc (t, input_location);
+}
+
} // namespace Rust
#endif // RUST_TREE
diff --git a/gcc/rust/hir/rust-ast-lower-base.cc b/gcc/rust/hir/rust-ast-lower-base.cc
index 68bec88..7e80f81 100644
--- a/gcc/rust/hir/rust-ast-lower-base.cc
+++ b/gcc/rust/hir/rust-ast-lower-base.cc
@@ -612,8 +612,19 @@ ASTLoweringBase::lower_generic_args (AST::GenericArgs &args)
type_args.push_back (std::unique_ptr<HIR::Type> (t));
}
+ std::vector<HIR::ConstGenericArg> const_args;
+ for (auto &const_arg : args.get_const_args ())
+ const_args.emplace_back (HIR::ConstGenericArg (
+ std::unique_ptr<HIR::Expr> (
+ ASTLoweringExpr::translate (const_arg.get_expression ().get ())),
+ Location ()));
+
+ // FIXME:
+ // const_arg.get_locus ());
+
return HIR::GenericArgs (std::move (lifetime_args), std::move (type_args),
- std::move (binding_args), args.get_locus ());
+ std::move (binding_args), std::move (const_args),
+ args.get_locus ());
}
HIR::SelfParam
@@ -650,29 +661,17 @@ ASTLowerTypePath::visit (AST::TypePathSegmentGeneric &segment)
bool has_separating_scope_resolution
= segment.get_separating_scope_resolution ();
- std::vector<HIR::Lifetime> lifetime_args;
- for (auto &lifetime : segment.get_generic_args ().get_lifetime_args ())
- {
- HIR::Lifetime l = lower_lifetime (lifetime);
- lifetime_args.push_back (std::move (l));
- }
-
- std::vector<std::unique_ptr<HIR::Type>> type_args;
- for (auto &type : segment.get_generic_args ().get_type_args ())
- {
- HIR::Type *t = ASTLoweringType::translate (type.get ());
- type_args.push_back (std::unique_ptr<HIR::Type> (t));
- }
+ auto generic_args = lower_generic_args (segment.get_generic_args ());
auto crate_num = mappings->get_current_crate ();
auto hirid = mappings->get_next_hir_id (crate_num);
Analysis::NodeMapping mapping (crate_num, segment.get_node_id (), hirid,
UNKNOWN_LOCAL_DEFID);
- translated_segment = new HIR::TypePathSegmentGeneric (
- std::move (mapping), segment_name, has_separating_scope_resolution,
- std::move (lifetime_args), std::move (type_args), std::move (binding_args),
- segment.get_locus ());
+ translated_segment
+ = new HIR::TypePathSegmentGeneric (std::move (mapping), segment_name,
+ has_separating_scope_resolution,
+ generic_args, segment.get_locus ());
}
void
diff --git a/gcc/rust/hir/rust-ast-lower-type.h b/gcc/rust/hir/rust-ast-lower-type.h
index 58ee560..dc20be7 100644
--- a/gcc/rust/hir/rust-ast-lower-type.h
+++ b/gcc/rust/hir/rust-ast-lower-type.h
@@ -375,13 +375,17 @@ public:
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
- // FIXME: This creates a BOGUS HIR::Lifetime instance because we do not have
- // an `HIR::ConstGenericParam` type yet. This needs to be removed, but for
- // now it avoids bogus ICEs
- HIR::Lifetime lt (mapping, AST::Lifetime::LifetimeType::WILDCARD, "fixme",
- param.get_locus ());
- translated = new HIR::LifetimeParam (mapping, lt, param.get_locus (),
- std::vector<Lifetime> ());
+ auto type = ASTLoweringType::translate (param.get_type ().get ());
+ auto default_expr
+ = param.has_default_value ()
+ ? ASTLoweringExpr::translate (param.get_default_value ().get ())
+ : nullptr;
+
+ translated
+ = new HIR::ConstGenericParam (param.get_name (),
+ std::unique_ptr<Type> (type),
+ std::unique_ptr<Expr> (default_expr),
+ mapping, param.get_locus ());
}
void visit (AST::TypeParam &param) override
diff --git a/gcc/rust/hir/tree/rust-hir-full-test.cc b/gcc/rust/hir/tree/rust-hir-full-test.cc
index b328a7f..8000e5c 100644
--- a/gcc/rust/hir/tree/rust-hir-full-test.cc
+++ b/gcc/rust/hir/tree/rust-hir-full-test.cc
@@ -5285,5 +5285,20 @@ StaticItem::accept_vis (HIRVisItemVisitor &vis)
vis.visit (*this);
}
+std::string
+ConstGenericParam::as_string () const
+{
+ auto result = "ConstGenericParam: " + name + " : " + type->as_string ();
+
+ if (default_expression)
+ result += " = " + default_expression->as_string ();
+
+ return result;
+}
+
+void
+ConstGenericParam::accept_vis (HIRFullVisitor &vis)
+{}
+
} // namespace HIR
} // namespace Rust
diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h
index b18bf1d..64c6ddc 100644
--- a/gcc/rust/hir/tree/rust-hir-path.h
+++ b/gcc/rust/hir/tree/rust-hir-path.h
@@ -112,12 +112,41 @@ public:
Location get_locus () const { return locus; }
};
+class ConstGenericArg
+{
+ // FIXME: Do we need to disambiguate or no? We should be able to disambiguate
+ // at name-resolution, hence no need for ambiguities here
+
+public:
+ ConstGenericArg (std::unique_ptr<Expr> expression, Location locus)
+ : expression (std::move (expression)), locus (locus)
+ {}
+
+ ConstGenericArg (const ConstGenericArg &other) : locus (other.locus)
+ {
+ expression = other.expression->clone_expr ();
+ }
+
+ ConstGenericArg operator= (const ConstGenericArg &other)
+ {
+ expression = other.expression->clone_expr ();
+ locus = other.locus;
+
+ return *this;
+ }
+
+private:
+ std::unique_ptr<Expr> expression;
+ Location locus;
+};
+
// Generic arguments allowed in each path expression segment - inline?
struct GenericArgs
{
std::vector<Lifetime> lifetime_args;
std::vector<std::unique_ptr<Type> > type_args;
std::vector<GenericArgsBinding> binding_args;
+ std::vector<ConstGenericArg> const_args;
Location locus;
public:
@@ -130,18 +159,21 @@ public:
GenericArgs (std::vector<Lifetime> lifetime_args,
std::vector<std::unique_ptr<Type> > type_args,
- std::vector<GenericArgsBinding> binding_args, Location locus)
+ std::vector<GenericArgsBinding> binding_args,
+ std::vector<ConstGenericArg> const_args, Location locus)
: lifetime_args (std::move (lifetime_args)),
type_args (std::move (type_args)),
- binding_args (std::move (binding_args)), locus (locus)
+ binding_args (std::move (binding_args)),
+ const_args (std::move (const_args)), locus (locus)
{}
// copy constructor with vector clone
GenericArgs (GenericArgs const &other)
: lifetime_args (other.lifetime_args), binding_args (other.binding_args),
- locus (other.locus)
+ const_args (other.const_args), locus (other.locus)
{
type_args.reserve (other.type_args.size ());
+
for (const auto &e : other.type_args)
type_args.push_back (e->clone_type ());
}
@@ -153,6 +185,7 @@ public:
{
lifetime_args = other.lifetime_args;
binding_args = other.binding_args;
+ const_args = other.const_args;
locus = other.locus;
type_args.reserve (other.type_args.size ());
@@ -169,9 +202,7 @@ public:
// Creates an empty GenericArgs (no arguments)
static GenericArgs create_empty (Location locus = Location ())
{
- return GenericArgs (std::vector<Lifetime> (),
- std::vector<std::unique_ptr<Type> > (),
- std::vector<GenericArgsBinding> (), locus);
+ return GenericArgs ({}, {}, {}, {}, locus);
}
bool is_empty () const
@@ -188,6 +219,8 @@ public:
std::vector<GenericArgsBinding> &get_binding_args () { return binding_args; }
+ std::vector<ConstGenericArg> &get_const_args () { return const_args; }
+
Location get_locus () const { return locus; }
};
@@ -464,12 +497,13 @@ public:
std::vector<Lifetime> lifetime_args,
std::vector<std::unique_ptr<Type> > type_args,
std::vector<GenericArgsBinding> binding_args,
+ std::vector<ConstGenericArg> const_args,
Location locus)
: TypePathSegment (std::move (mappings), std::move (segment_name),
has_separating_scope_resolution, locus),
- generic_args (GenericArgs (std::move (lifetime_args),
- std::move (type_args),
- std::move (binding_args), locus))
+ generic_args (
+ GenericArgs (std::move (lifetime_args), std::move (type_args),
+ std::move (binding_args), std::move (const_args), locus))
{}
std::string as_string () const override;
@@ -623,7 +657,6 @@ class TypePath : public TypeNoBounds
public:
bool has_opening_scope_resolution;
std::vector<std::unique_ptr<TypePathSegment> > segments;
- Location locus;
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -660,16 +693,15 @@ public:
TypePath (Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<TypePathSegment> > segments,
Location locus, bool has_opening_scope_resolution = false)
- : TypeNoBounds (mappings),
+ : TypeNoBounds (mappings, locus),
has_opening_scope_resolution (has_opening_scope_resolution),
- segments (std::move (segments)), locus (locus)
+ segments (std::move (segments))
{}
// Copy constructor with vector clone
TypePath (TypePath const &other)
- : TypeNoBounds (other.mappings),
- has_opening_scope_resolution (other.has_opening_scope_resolution),
- locus (other.locus)
+ : TypeNoBounds (other.mappings, other.locus),
+ has_opening_scope_resolution (other.has_opening_scope_resolution)
{
segments.reserve (other.segments.size ());
for (const auto &e : other.segments)
@@ -703,8 +735,6 @@ public:
// Creates a trait bound with a clone of this type path as its only element.
TraitBound *to_trait_bound (bool in_parens) const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
@@ -865,7 +895,6 @@ class QualifiedPathInType : public TypeNoBounds
QualifiedPathType path_type;
std::unique_ptr<TypePathSegment> associated_segment;
std::vector<std::unique_ptr<TypePathSegment> > segments;
- Location locus;
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -888,9 +917,9 @@ public:
std::unique_ptr<TypePathSegment> associated_segment,
std::vector<std::unique_ptr<TypePathSegment> > path_segments,
Location locus = Location ())
- : TypeNoBounds (mappings), path_type (std::move (qual_path_type)),
+ : TypeNoBounds (mappings, locus), path_type (std::move (qual_path_type)),
associated_segment (std::move (associated_segment)),
- segments (std::move (path_segments)), locus (locus)
+ segments (std::move (path_segments))
{}
/* TODO: maybe make a shortcut constructor that has QualifiedPathType elements
@@ -898,8 +927,7 @@ public:
// Copy constructor with vector clone
QualifiedPathInType (QualifiedPathInType const &other)
- : TypeNoBounds (other.mappings), path_type (other.path_type),
- locus (other.locus)
+ : TypeNoBounds (other.mappings, other.locus), path_type (other.path_type)
{
segments.reserve (other.segments.size ());
for (const auto &e : other.segments)
@@ -943,8 +971,6 @@ public:
{
return segments;
}
-
- Location get_locus () { return locus; }
};
class SimplePathSegment
diff --git a/gcc/rust/hir/tree/rust-hir-type.h b/gcc/rust/hir/tree/rust-hir-type.h
index c4817ad..0d2e743 100644
--- a/gcc/rust/hir/tree/rust-hir-type.h
+++ b/gcc/rust/hir/tree/rust-hir-type.h
@@ -87,9 +87,7 @@ class ImplTraitType : public Type
{
// TypeParamBounds type_param_bounds;
// inlined form
- std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds;
-
- Location locus;
+ std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds;
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -100,17 +98,15 @@ protected:
}
public:
- ImplTraitType (
- Analysis::NodeMapping mappings,
- std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds,
- Location locus)
- : Type (mappings), type_param_bounds (std::move (type_param_bounds)),
- locus (locus)
+ ImplTraitType (Analysis::NodeMapping mappings,
+ std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
+ Location locus)
+ : Type (mappings, locus), type_param_bounds (std::move (type_param_bounds))
{}
// copy constructor with vector clone
ImplTraitType (ImplTraitType const &other)
- : Type (other.mappings), locus (other.locus)
+ : Type (other.mappings, other.locus)
{
type_param_bounds.reserve (other.type_param_bounds.size ());
for (const auto &e : other.type_param_bounds)
@@ -136,8 +132,6 @@ public:
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
};
@@ -146,8 +140,7 @@ public:
class TraitObjectType : public Type
{
bool has_dyn;
- std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds;
- Location locus;
+ std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds;
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -160,15 +153,15 @@ protected:
public:
TraitObjectType (
Analysis::NodeMapping mappings,
- std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds,
+ std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
Location locus, bool is_dyn_dispatch)
- : Type (mappings), has_dyn (is_dyn_dispatch),
- type_param_bounds (std::move (type_param_bounds)), locus (locus)
+ : Type (mappings, locus), has_dyn (is_dyn_dispatch),
+ type_param_bounds (std::move (type_param_bounds))
{}
// copy constructor with vector clone
TraitObjectType (TraitObjectType const &other)
- : Type (other.mappings), has_dyn (other.has_dyn), locus (other.locus)
+ : Type (other.mappings, other.locus), has_dyn (other.has_dyn)
{
type_param_bounds.reserve (other.type_param_bounds.size ());
for (const auto &e : other.type_param_bounds)
@@ -194,17 +187,15 @@ public:
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
- std::vector<std::unique_ptr<TypeParamBound> > &get_type_param_bounds ()
+ std::vector<std::unique_ptr<TypeParamBound>> &get_type_param_bounds ()
{
return type_param_bounds;
}
- const std::vector<std::unique_ptr<TypeParamBound> > &
+ const std::vector<std::unique_ptr<TypeParamBound>> &
get_type_param_bounds () const
{
return type_param_bounds;
@@ -215,7 +206,6 @@ public:
class ParenthesisedType : public TypeNoBounds
{
std::unique_ptr<Type> type_in_parens;
- Location locus;
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -236,15 +226,15 @@ public:
// Constructor uses Type pointer for polymorphism
ParenthesisedType (Analysis::NodeMapping mappings,
std::unique_ptr<Type> type_inside_parens, Location locus)
- : TypeNoBounds (mappings), type_in_parens (std::move (type_inside_parens)),
- locus (locus)
+ : TypeNoBounds (mappings, locus),
+ type_in_parens (std::move (type_inside_parens))
{}
/* Copy constructor uses custom deep copy method for type to preserve
* polymorphism */
ParenthesisedType (ParenthesisedType const &other)
- : TypeNoBounds (other.mappings),
- type_in_parens (other.type_in_parens->clone_type ()), locus (other.locus)
+ : TypeNoBounds (other.mappings, other.locus),
+ type_in_parens (other.type_in_parens->clone_type ())
{}
// overload assignment operator to use custom clone method
@@ -274,8 +264,6 @@ public:
return type_in_parens->to_trait_bound (true);
}
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
};
@@ -285,8 +273,6 @@ class ImplTraitTypeOneBound : public TypeNoBounds
{
TraitBound trait_bound;
- Location locus;
-
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -305,14 +291,11 @@ protected:
public:
ImplTraitTypeOneBound (Analysis::NodeMapping mappings, TraitBound trait_bound,
Location locus)
- : TypeNoBounds (mappings), trait_bound (std::move (trait_bound)),
- locus (locus)
+ : TypeNoBounds (mappings, locus), trait_bound (std::move (trait_bound))
{}
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
};
@@ -323,21 +306,20 @@ class TypePath; // definition moved to "rust-path.h"
* specific order */
class TupleType : public TypeNoBounds
{
- std::vector<std::unique_ptr<Type> > elems;
- Location locus;
+ std::vector<std::unique_ptr<Type>> elems;
public:
// Returns whether the tuple type is the unit type, i.e. has no elements.
bool is_unit_type () const { return elems.empty (); }
TupleType (Analysis::NodeMapping mappings,
- std::vector<std::unique_ptr<Type> > elems, Location locus)
- : TypeNoBounds (mappings), elems (std::move (elems)), locus (locus)
+ std::vector<std::unique_ptr<Type>> elems, Location locus)
+ : TypeNoBounds (mappings, locus), elems (std::move (elems))
{}
// copy constructor with vector clone
TupleType (TupleType const &other)
- : TypeNoBounds (other.mappings), locus (other.locus)
+ : TypeNoBounds (other.mappings, other.locus)
{
mappings = other.mappings;
elems.reserve (other.elems.size ());
@@ -363,16 +345,11 @@ public:
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
- std::vector<std::unique_ptr<Type> > &get_elems () { return elems; }
- const std::vector<std::unique_ptr<Type> > &get_elems () const
- {
- return elems;
- }
+ std::vector<std::unique_ptr<Type>> &get_elems () { return elems; }
+ const std::vector<std::unique_ptr<Type>> &get_elems () const { return elems; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -392,8 +369,6 @@ protected:
* Represented as "!". */
class NeverType : public TypeNoBounds
{
- Location locus;
-
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -408,13 +383,11 @@ protected:
public:
NeverType (Analysis::NodeMapping mappings, Location locus)
- : TypeNoBounds (mappings), locus (locus)
+ : TypeNoBounds (mappings, locus)
{}
std::string as_string () const override { return "! (never type)"; }
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
};
@@ -425,19 +398,18 @@ class RawPointerType : public TypeNoBounds
private:
Mutability mut;
std::unique_ptr<Type> type;
- Location locus;
public:
// Constructor requires pointer for polymorphism reasons
RawPointerType (Analysis::NodeMapping mappings, Mutability mut,
std::unique_ptr<Type> type, Location locus)
- : TypeNoBounds (mappings), mut (mut), type (std::move (type)), locus (locus)
+ : TypeNoBounds (mappings, locus), mut (mut), type (std::move (type))
{}
// Copy constructor calls custom polymorphic clone function
RawPointerType (RawPointerType const &other)
- : TypeNoBounds (other.mappings), mut (other.mut),
- type (other.type->clone_type ()), locus (other.locus)
+ : TypeNoBounds (other.mappings, other.locus), mut (other.mut),
+ type (other.type->clone_type ())
{}
// overload assignment operator to use custom clone method
@@ -456,8 +428,6 @@ public:
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
@@ -495,7 +465,6 @@ class ReferenceType : public TypeNoBounds
Mutability mut;
std::unique_ptr<Type> type;
- Location locus;
public:
// Returns whether the reference is mutable or immutable.
@@ -508,14 +477,14 @@ public:
ReferenceType (Analysis::NodeMapping mappings, Mutability mut,
std::unique_ptr<Type> type_no_bounds, Location locus,
Lifetime lifetime)
- : TypeNoBounds (mappings), lifetime (std::move (lifetime)), mut (mut),
- type (std::move (type_no_bounds)), locus (locus)
+ : TypeNoBounds (mappings, locus), lifetime (std::move (lifetime)),
+ mut (mut), type (std::move (type_no_bounds))
{}
// Copy constructor with custom clone method
ReferenceType (ReferenceType const &other)
- : TypeNoBounds (other.mappings), lifetime (other.lifetime), mut (other.mut),
- type (other.type->clone_type ()), locus (other.locus)
+ : TypeNoBounds (other.mappings, other.locus), lifetime (other.lifetime),
+ mut (other.mut), type (other.type->clone_type ())
{}
// Operator overload assignment operator to custom clone the unique pointer
@@ -536,8 +505,6 @@ public:
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
@@ -568,20 +535,20 @@ class ArrayType : public TypeNoBounds
{
std::unique_ptr<Type> elem_type;
std::unique_ptr<Expr> size;
- Location locus;
public:
// Constructor requires pointers for polymorphism
ArrayType (Analysis::NodeMapping mappings, std::unique_ptr<Type> type,
std::unique_ptr<Expr> array_size, Location locus)
- : TypeNoBounds (mappings), elem_type (std::move (type)),
- size (std::move (array_size)), locus (locus)
+ : TypeNoBounds (mappings, locus), elem_type (std::move (type)),
+ size (std::move (array_size))
{}
// Copy constructor requires deep copies of both unique pointers
ArrayType (ArrayType const &other)
- : TypeNoBounds (other.mappings), elem_type (other.elem_type->clone_type ()),
- size (other.size->clone_expr ()), locus (other.locus)
+ : TypeNoBounds (other.mappings, other.locus),
+ elem_type (other.elem_type->clone_type ()),
+ size (other.size->clone_expr ())
{}
// Overload assignment operator to deep copy pointers
@@ -600,8 +567,6 @@ public:
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
@@ -609,8 +574,6 @@ public:
Expr *get_size_expr () { return size.get (); }
- Location &get_locus () { return locus; }
-
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -629,19 +592,18 @@ protected:
class SliceType : public TypeNoBounds
{
std::unique_ptr<Type> elem_type;
- Location locus;
public:
// Constructor requires pointer for polymorphism
SliceType (Analysis::NodeMapping mappings, std::unique_ptr<Type> type,
Location locus)
- : TypeNoBounds (mappings), elem_type (std::move (type)), locus (locus)
+ : TypeNoBounds (mappings, locus), elem_type (std::move (type))
{}
// Copy constructor requires deep copy of Type smart pointer
SliceType (SliceType const &other)
- : TypeNoBounds (other.mappings), elem_type (other.elem_type->clone_type ()),
- locus (other.locus)
+ : TypeNoBounds (other.mappings, other.locus),
+ elem_type (other.elem_type->clone_type ())
{}
// Overload assignment operator to deep copy
@@ -660,8 +622,6 @@ public:
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
@@ -684,8 +644,6 @@ protected:
* pattern) */
class InferredType : public TypeNoBounds
{
- Location locus;
-
// e.g. Vec<_> = whatever
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -704,13 +662,11 @@ protected:
public:
InferredType (Analysis::NodeMapping mappings, Location locus)
- : TypeNoBounds (mappings), locus (locus)
+ : TypeNoBounds (mappings, locus)
{}
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
};
@@ -804,8 +760,6 @@ class BareFunctionType : public TypeNoBounds
std::unique_ptr<Type> return_type; // inlined version
- Location locus;
-
public:
// Whether a return type is defined with the function.
bool has_return_type () const { return return_type != nullptr; }
@@ -818,18 +772,20 @@ public:
FunctionQualifiers qualifiers,
std::vector<MaybeNamedParam> named_params, bool is_variadic,
std::unique_ptr<Type> type, Location locus)
- : TypeNoBounds (mappings), for_lifetimes (std::move (lifetime_params)),
+ : TypeNoBounds (mappings, locus),
+ for_lifetimes (std::move (lifetime_params)),
function_qualifiers (std::move (qualifiers)),
params (std::move (named_params)), is_variadic (is_variadic),
- return_type (std::move (type)), locus (locus)
+ return_type (std::move (type))
{}
// Copy constructor with clone
BareFunctionType (BareFunctionType const &other)
- : TypeNoBounds (other.mappings), for_lifetimes (other.for_lifetimes),
+ : TypeNoBounds (other.mappings, other.locus),
+ for_lifetimes (other.for_lifetimes),
function_qualifiers (other.function_qualifiers), params (other.params),
is_variadic (other.is_variadic),
- return_type (other.return_type->clone_type ()), locus (other.locus)
+ return_type (other.return_type->clone_type ())
{}
// Overload assignment operator to deep copy
@@ -852,8 +808,6 @@ public:
std::string as_string () const override;
- Location get_locus () const { return locus; }
-
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h
index cab46b2..8f94354 100644
--- a/gcc/rust/hir/tree/rust-hir.h
+++ b/gcc/rust/hir/tree/rust-hir.h
@@ -478,16 +478,18 @@ public:
virtual void accept_vis (HIRTypeVisitor &vis) = 0;
virtual Analysis::NodeMapping get_mappings () const { return mappings; }
+ virtual Location get_locus () const { return locus; }
protected:
- Type (Analysis::NodeMapping mappings) : mappings (mappings) {}
+ Type (Analysis::NodeMapping mappings, Location locus)
+ : mappings (mappings), locus (locus)
+ {}
// Clone function implementation as pure virtual method
virtual Type *clone_type_impl () const = 0;
Analysis::NodeMapping mappings;
-
- // FIXME: How do we get the location here for each type?
+ Location locus;
};
// A type without parentheses? - abstract
@@ -501,7 +503,9 @@ public:
}
protected:
- TypeNoBounds (Analysis::NodeMapping mappings) : Type (mappings) {}
+ TypeNoBounds (Analysis::NodeMapping mappings, Location locus)
+ : Type (mappings, locus)
+ {}
// Clone function implementation as pure virtual method
virtual TypeNoBounds *clone_type_no_bounds_impl () const = 0;
@@ -615,13 +619,11 @@ class GenericParam
public:
virtual ~GenericParam () {}
- enum GenericKind
+ enum class GenericKind
{
TYPE,
LIFETIME,
-
- // CONST generic parameter not yet handled
- // CONST,
+ CONST,
};
// Unique pointer custom clone function
@@ -648,7 +650,8 @@ protected:
enum GenericKind kind;
- GenericParam (Analysis::NodeMapping mapping, enum GenericKind kind = TYPE)
+ GenericParam (Analysis::NodeMapping mapping,
+ enum GenericKind kind = GenericKind::TYPE)
: mappings (mapping), kind (kind)
{}
};
@@ -732,6 +735,52 @@ protected:
}
};
+class ConstGenericParam : public GenericParam
+{
+public:
+ ConstGenericParam (std::string name, std::unique_ptr<Type> type,
+ std::unique_ptr<Expr> default_expression,
+ Analysis::NodeMapping mapping, Location locus)
+ : GenericParam (mapping, GenericKind::CONST), name (std::move (name)),
+ type (std::move (type)),
+ default_expression (std::move (default_expression)), locus (locus)
+ {}
+
+ ConstGenericParam (const ConstGenericParam &other) : GenericParam (other)
+ {
+ name = other.name;
+ locus = other.locus;
+
+ if (other.type)
+ type = other.type->clone_type ();
+ if (other.default_expression)
+ default_expression = other.default_expression->clone_expr ();
+ }
+
+ std::string as_string () const override final;
+
+ void accept_vis (HIRFullVisitor &vis) override final;
+
+ Location get_locus () const override final { return locus; };
+
+protected:
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ConstGenericParam *clone_generic_param_impl () const override
+ {
+ return new ConstGenericParam (*this);
+ }
+
+private:
+ std::string name;
+ std::unique_ptr<Type> type;
+
+ /* Optional - can be a null pointer if there is no default expression */
+ std::unique_ptr<Expr> default_expression;
+
+ Location locus;
+};
+
// Item used in trait declarations - abstract base class
class TraitItem : public Node
{
diff --git a/gcc/rust/privacy/rust-privacy-reporter.cc b/gcc/rust/privacy/rust-privacy-reporter.cc
index f2752b6..77f477b 100644
--- a/gcc/rust/privacy/rust-privacy-reporter.cc
+++ b/gcc/rust/privacy/rust-privacy-reporter.cc
@@ -188,8 +188,7 @@ PrivacyReporter::check_base_type_privacy (Analysis::NodeMapping &node_mappings,
}
void
-PrivacyReporter::check_type_privacy (const HIR::Type *type,
- const Location &locus)
+PrivacyReporter::check_type_privacy (const HIR::Type *type)
{
rust_assert (type);
@@ -198,7 +197,7 @@ PrivacyReporter::check_type_privacy (const HIR::Type *type,
ty_ctx.lookup_type (type->get_mappings ().get_hirid (), &lookup));
auto node_mappings = type->get_mappings ();
- return check_base_type_privacy (node_mappings, lookup, locus);
+ return check_base_type_privacy (node_mappings, lookup, type->get_locus ());
}
void
@@ -634,9 +633,7 @@ void
PrivacyReporter::visit (HIR::Function &function)
{
for (auto &param : function.get_function_params ())
- check_type_privacy (param.get_type (), param.get_locus ());
-
- // FIXME: It would be better if it was specifically the type's locus (#1256)
+ check_type_privacy (param.get_type ());
function.get_definition ()->accept_vis (*this);
}
@@ -737,8 +734,7 @@ PrivacyReporter::visit (HIR::LetStmt &stmt)
{
auto type = stmt.get_type ();
if (type)
- check_type_privacy (type, stmt.get_locus ());
- // FIXME: #1256
+ check_type_privacy (type);
auto init_expr = stmt.get_init_expr ();
if (init_expr)
diff --git a/gcc/rust/privacy/rust-privacy-reporter.h b/gcc/rust/privacy/rust-privacy-reporter.h
index 234bea7..a04e318 100644
--- a/gcc/rust/privacy/rust-privacy-reporter.h
+++ b/gcc/rust/privacy/rust-privacy-reporter.h
@@ -74,9 +74,8 @@ types
*
* @param type Reference to an explicit type used in a statement, expression
* or parameter
- * @param locus Location of said type
*/
- void check_type_privacy (const HIR::Type *type, const Location &locus);
+ void check_type_privacy (const HIR::Type *type);
virtual void visit (HIR::StructExprFieldIdentifier &field);
virtual void visit (HIR::StructExprFieldIdentifierValue &field);
diff --git a/gcc/rust/privacy/rust-reachability.cc b/gcc/rust/privacy/rust-reachability.cc
index bf2480b..b322e29 100644
--- a/gcc/rust/privacy/rust-reachability.cc
+++ b/gcc/rust/privacy/rust-reachability.cc
@@ -48,7 +48,7 @@ ReachabilityVisitor::visit_generic_predicates (
for (const auto &generic : generics)
{
- if (generic->get_kind () == HIR::GenericParam::TYPE)
+ if (generic->get_kind () == HIR::GenericParam::GenericKind::TYPE)
{
TyTy::BaseType *generic_ty = nullptr;
auto ok = ty_ctx.lookup_type (generic->get_mappings ().get_hirid (),
diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.cc b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
index 7e87e1d..c008763 100644
--- a/gcc/rust/typecheck/rust-hir-trait-resolve.cc
+++ b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
@@ -141,7 +141,9 @@ TraitResolver::resolve_trait (HIR::Trait *trait_reference)
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -383,7 +385,9 @@ AssociatedImplTrait::setup_associated_types (
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.h b/gcc/rust/typecheck/rust-hir-type-check-implitem.h
index c7af9b2..0bca9b4 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-implitem.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.h
@@ -57,7 +57,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -190,7 +192,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.h b/gcc/rust/typecheck/rust-hir-type-check-item.h
index 8573335..84a33f8 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-item.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-item.h
@@ -51,7 +51,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
diff --git a/gcc/rust/typecheck/rust-hir-type-check-stmt.h b/gcc/rust/typecheck/rust-hir-type-check-stmt.h
index 96e92b4..67eddb5 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-stmt.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-stmt.h
@@ -139,7 +139,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -215,7 +217,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -273,7 +277,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -347,7 +353,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -415,7 +423,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
diff --git a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
index fe961d1..af63c5a 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
@@ -64,7 +64,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -150,7 +152,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -228,7 +232,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -286,7 +292,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -374,7 +382,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
@@ -457,7 +467,9 @@ public:
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc
index 1d26d60..7cfb952 100644
--- a/gcc/rust/typecheck/rust-hir-type-check.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check.cc
@@ -203,7 +203,9 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const
switch (generic_param.get ()->get_kind ())
{
case HIR::GenericParam::GenericKind::LIFETIME:
- // Skipping Lifetime completely until better handling.
+ case HIR::GenericParam::GenericKind::CONST:
+ // FIXME: Skipping Lifetime and Const completely until better
+ // handling.
break;
case HIR::GenericParam::GenericKind::TYPE: {
diff --git a/gcc/testsuite/rust/compile/privacy5.rs b/gcc/testsuite/rust/compile/privacy5.rs
index ad552c7..0e0e496 100644
--- a/gcc/testsuite/rust/compile/privacy5.rs
+++ b/gcc/testsuite/rust/compile/privacy5.rs
@@ -12,7 +12,6 @@ mod orange {
let _: green::Foo; // { dg-error "definition is private in this context" }
- fn any(a0: green::Foo, a1: green::Bar) {}
- // { dg-error "definition is private in this context" "" { target *-*-* } .-1 }
+ fn any(a0: green::Foo, a1: green::Bar) {} // { dg-error "20:definition is private in this context" }
}
}