diff options
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-type.cc | 36 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-type.h | 3 | ||||
-rw-r--r-- | gcc/rust/hir/rust-hir-dump.cc | 9 | ||||
-rw-r--r-- | gcc/rust/hir/rust-hir-dump.h | 1 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-full-decls.h | 1 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-type.h | 32 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-visitor.h | 3 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir.cc | 20 |
8 files changed, 39 insertions, 66 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-type.cc b/gcc/rust/hir/rust-ast-lower-type.cc index 8df418b..d3e528d 100644 --- a/gcc/rust/hir/rust-ast-lower-type.cc +++ b/gcc/rust/hir/rust-ast-lower-type.cc @@ -477,6 +477,42 @@ ASTLoweringType::visit (AST::ParenthesisedType &type) type.get_locus ()); } +void +ASTLoweringType::visit (AST::ImplTraitType &type) +{ + std::vector<std::unique_ptr<HIR::TypeParamBound>> bounds; + for (auto &bound : type.get_type_param_bounds ()) + { + auto b = ASTLoweringTypeBounds::translate (*bound.get ()); + bounds.push_back (std::unique_ptr<HIR::TypeParamBound> (b)); + } + + auto crate_num = mappings.get_current_crate (); + Analysis::NodeMapping mapping (crate_num, type.get_node_id (), + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); + + translated + = new HIR::ImplTraitType (mapping, std::move (bounds), type.get_locus ()); +} + +void +ASTLoweringType::visit (AST::ImplTraitTypeOneBound &type) +{ + std::vector<std::unique_ptr<HIR::TypeParamBound>> bounds; + + auto b = ASTLoweringTypeBounds::translate (type.get_trait_bound ()); + bounds.push_back (std::unique_ptr<HIR::TypeParamBound> (b)); + + auto crate_num = mappings.get_current_crate (); + Analysis::NodeMapping mapping (crate_num, type.get_node_id (), + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); + + translated + = new HIR::ImplTraitType (mapping, std::move (bounds), type.get_locus ()); +} + HIR::GenericParam * ASTLowerGenericParam::translate (AST::GenericParam ¶m) { diff --git a/gcc/rust/hir/rust-ast-lower-type.h b/gcc/rust/hir/rust-ast-lower-type.h index af0b4be..4efaeee 100644 --- a/gcc/rust/hir/rust-ast-lower-type.h +++ b/gcc/rust/hir/rust-ast-lower-type.h @@ -82,6 +82,9 @@ public: void visit (AST::TraitObjectType &type) override; void visit (AST::ParenthesisedType &type) override; + void visit (AST::ImplTraitType &type) override; + void visit (AST::ImplTraitTypeOneBound &type) override; + private: ASTLoweringType (bool default_to_static_lifetime) : ASTLoweringBase (), diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc index 0bfcc97a..6861277 100644 --- a/gcc/rust/hir/rust-hir-dump.cc +++ b/gcc/rust/hir/rust-hir-dump.cc @@ -2333,15 +2333,6 @@ Dump::visit (ParenthesisedType &e) } void -Dump::visit (ImplTraitTypeOneBound &e) -{ - begin ("ImplTraitTypeOneBound"); - do_type (e); - visit_field ("trait_bound", e.get_trait_bound ()); - end ("ImplTraitTypeOneBound"); -} - -void Dump::visit (TupleType &e) { begin ("TupleType"); diff --git a/gcc/rust/hir/rust-hir-dump.h b/gcc/rust/hir/rust-hir-dump.h index 8683dee..afcd668 100644 --- a/gcc/rust/hir/rust-hir-dump.h +++ b/gcc/rust/hir/rust-hir-dump.h @@ -237,7 +237,6 @@ private: virtual void visit (ImplTraitType &) override; virtual void visit (TraitObjectType &) override; virtual void visit (ParenthesisedType &) override; - virtual void visit (ImplTraitTypeOneBound &) override; virtual void visit (TupleType &) override; virtual void visit (NeverType &) override; virtual void visit (RawPointerType &) override; diff --git a/gcc/rust/hir/tree/rust-hir-full-decls.h b/gcc/rust/hir/tree/rust-hir-full-decls.h index c64c8bf..6c19f24 100644 --- a/gcc/rust/hir/tree/rust-hir-full-decls.h +++ b/gcc/rust/hir/tree/rust-hir-full-decls.h @@ -211,7 +211,6 @@ class TraitBound; class ImplTraitType; class TraitObjectType; class ParenthesisedType; -class ImplTraitTypeOneBound; class TupleType; class NeverType; class RawPointerType; diff --git a/gcc/rust/hir/tree/rust-hir-type.h b/gcc/rust/hir/tree/rust-hir-type.h index e231d78..bd0f2b6 100644 --- a/gcc/rust/hir/tree/rust-hir-type.h +++ b/gcc/rust/hir/tree/rust-hir-type.h @@ -164,38 +164,6 @@ public: void accept_vis (HIRTypeVisitor &vis) override; }; -// Impl trait with a single bound? Poor reference material here. -class ImplTraitTypeOneBound : public TypeNoBounds -{ - TraitBound trait_bound; - -protected: - /* Use covariance to implement clone function as returning this object rather - * than base */ - ImplTraitTypeOneBound *clone_type_impl () const override - { - return new ImplTraitTypeOneBound (*this); - } - - /* Use covariance to implement clone function as returning this object rather - * than base */ - ImplTraitTypeOneBound *clone_type_no_bounds_impl () const override - { - return new ImplTraitTypeOneBound (*this); - } - -public: - ImplTraitTypeOneBound (Analysis::NodeMapping mappings, TraitBound trait_bound, - location_t locus) - : TypeNoBounds (mappings, locus), trait_bound (std::move (trait_bound)) - {} - - std::string as_string () const override; - TraitBound &get_trait_bound () { return trait_bound; } - void accept_vis (HIRFullVisitor &vis) override; - void accept_vis (HIRTypeVisitor &vis) override; -}; - /* A type consisting of the "product" of others (the tuple's elements) in a * specific order */ class TupleType : public TypeNoBounds diff --git a/gcc/rust/hir/tree/rust-hir-visitor.h b/gcc/rust/hir/tree/rust-hir-visitor.h index 33e6b7b..800e647 100644 --- a/gcc/rust/hir/tree/rust-hir-visitor.h +++ b/gcc/rust/hir/tree/rust-hir-visitor.h @@ -142,7 +142,6 @@ public: virtual void visit (ImplTraitType &type) = 0; virtual void visit (TraitObjectType &type) = 0; virtual void visit (ParenthesisedType &type) = 0; - virtual void visit (ImplTraitTypeOneBound &type) = 0; virtual void visit (TupleType &type) = 0; virtual void visit (NeverType &type) = 0; virtual void visit (RawPointerType &type) = 0; @@ -290,7 +289,6 @@ public: virtual void visit (ImplTraitType &) override {} virtual void visit (TraitObjectType &) override {} virtual void visit (ParenthesisedType &) override {} - virtual void visit (ImplTraitTypeOneBound &) override {} virtual void visit (TupleType &) override {} virtual void visit (NeverType &) override {} virtual void visit (RawPointerType &) override {} @@ -354,7 +352,6 @@ public: virtual void visit (ImplTraitType &type) = 0; virtual void visit (TraitObjectType &type) = 0; virtual void visit (ParenthesisedType &type) = 0; - virtual void visit (ImplTraitTypeOneBound &type) = 0; virtual void visit (TupleType &type) = 0; virtual void visit (NeverType &type) = 0; virtual void visit (RawPointerType &type) = 0; diff --git a/gcc/rust/hir/tree/rust-hir.cc b/gcc/rust/hir/tree/rust-hir.cc index 22b086730..822eaff 100644 --- a/gcc/rust/hir/tree/rust-hir.cc +++ b/gcc/rust/hir/tree/rust-hir.cc @@ -2866,14 +2866,6 @@ BareFunctionType::as_string () const } std::string -ImplTraitTypeOneBound::as_string () const -{ - std::string str ("ImplTraitTypeOneBound: \n TraitBound: "); - - return str + trait_bound.as_string (); -} - -std::string TypePathSegmentGeneric::as_string () const { return TypePathSegment::as_string () + "<" + generic_args.as_string () + ">"; @@ -4526,12 +4518,6 @@ ParenthesisedType::accept_vis (HIRFullVisitor &vis) } void -ImplTraitTypeOneBound::accept_vis (HIRFullVisitor &vis) -{ - vis.visit (*this); -} - -void TupleType::accept_vis (HIRFullVisitor &vis) { vis.visit (*this); @@ -4724,12 +4710,6 @@ ArrayType::accept_vis (HIRTypeVisitor &vis) } void -ImplTraitTypeOneBound::accept_vis (HIRTypeVisitor &vis) -{ - vis.visit (*this); -} - -void BareFunctionType::accept_vis (HIRTypeVisitor &vis) { vis.visit (*this); |