#include "rust-expr.h"
#include "rust-path.h"
#include "rust-item.h"
+#include "rust-path.h"
#include "rust-token.h"
namespace Rust {
}
std::unique_ptr<TypePathSegment>
-Builder::generic_type_path_segment (std::string seg, GenericArgs args) const
+Builder::type_path_segment (LangItem::Kind lang_item) const
+{
+ return std::unique_ptr<TypePathSegment> (
+ new TypePathSegment (lang_item, loc));
+}
+
+std::unique_ptr<TypePathSegment>
+Builder::type_path_segment_generic (std::string seg, GenericArgs args) const
{
return std::unique_ptr<TypePathSegment> (
new TypePathSegmentGeneric (PathIdentSegment (seg, loc), false, args, loc));
}
+std::unique_ptr<TypePathSegment>
+Builder::type_path_segment_generic (LangItem::Kind lang_item,
+ GenericArgs args) const
+{
+ return std::unique_ptr<TypePathSegment> (
+ new TypePathSegmentGeneric (lang_item, args, loc));
+}
+
std::unique_ptr<Type>
Builder::single_type_path (std::string type) const
{
return std::unique_ptr<Type> (new TypePath (std::move (segments), loc));
}
+std::unique_ptr<Type>
+Builder::single_type_path (LangItem::Kind lang_item) const
+{
+ return std::unique_ptr<Type> (new TypePath (lang_item, {}, loc));
+}
+
std::unique_ptr<Type>
Builder::single_generic_type_path (std::string type, GenericArgs args) const
{
auto segments = std::vector<std::unique_ptr<TypePathSegment>> ();
- segments.emplace_back (generic_type_path_segment (type, args));
+ segments.emplace_back (type_path_segment_generic (type, args));
return std::unique_ptr<Type> (new TypePath (std::move (segments), loc));
}
+std::unique_ptr<Type>
+Builder::single_generic_type_path (LangItem::Kind lang_item,
+ GenericArgs args) const
+{
+ auto segments = std::vector<std::unique_ptr<TypePathSegment>> ();
+ segments.emplace_back (type_path_segment_generic (lang_item, args));
+
+ return std::unique_ptr<Type> (new TypePath (std::move (segments), loc));
+}
+
+TypePath
+Builder::type_path (std::unique_ptr<TypePathSegment> &&segment) const
+{
+ auto segments = std::vector<std::unique_ptr<TypePathSegment>> ();
+ segments.emplace_back (std::move (segment));
+
+ return TypePath (std::move (segments), loc);
+}
+
+TypePath
+Builder::type_path (std::string type) const
+{
+ return type_path (type_path_segment (type));
+}
+
+TypePath
+Builder::type_path (LangItem::Kind lang_item) const
+{
+ return type_path (type_path_segment (lang_item));
+}
+
PathInExpression
Builder::path_in_expression (std::vector<std::string> &&segments) const
{
/* And similarly for type path segments */
std::unique_ptr<TypePathSegment> type_path_segment (std::string seg) const;
+ std::unique_ptr<TypePathSegment>
+ type_path_segment (LangItem::Kind lang_item) const;
std::unique_ptr<TypePathSegment>
- generic_type_path_segment (std::string seg, GenericArgs args) const;
+ type_path_segment_generic (std::string seg, GenericArgs args) const;
+ std::unique_ptr<TypePathSegment>
+ type_path_segment_generic (LangItem::Kind lang_item, GenericArgs args) const;
/* Create a Type from a single string - the most basic kind of type in our AST
*/
std::unique_ptr<Type> single_type_path (std::string type) const;
+ std::unique_ptr<Type> single_type_path (LangItem::Kind lang_item) const;
std::unique_ptr<Type> single_generic_type_path (std::string type,
GenericArgs args) const;
+ std::unique_ptr<Type> single_generic_type_path (LangItem::Kind lang_item,
+ GenericArgs args) const;
+
+ TypePath type_path (std::unique_ptr<TypePathSegment> &&segment) const;
+ TypePath type_path (std::string type) const;
+ TypePath type_path (LangItem::Kind lang_item) const;
/**
* Create a path in expression from multiple segments (`Clone::clone`). You