return *trait_path;
}
+ Type &get_trait_path_type ()
+ {
+ rust_assert (trait_path->get_path_kind () == Path::Kind::Type);
+
+ return (AST::Type &) static_cast<AST::TypePath &> (*trait_path);
+ }
+
protected:
/* Use covariance to implement clone function as returning this object
* rather than base */
#include "rust-ast-lower-type.h"
#include "optional.h"
#include "rust-attribute-values.h"
+#include "rust-path.h"
namespace Rust {
namespace HIR {
+HIR::TypePath *
+ASTLowerTypePath::translate (AST::Path &type)
+{
+ rust_assert (type.get_path_kind () == AST::Path::Kind::Type);
+
+ return ASTLowerTypePath::translate (static_cast<AST::TypePath &> (type));
+}
+
HIR::TypePath *
ASTLowerTypePath::translate (AST::TypePath &type)
{
using Rust::HIR::ASTLoweringBase::visit;
public:
+ static HIR::TypePath *translate (AST::Path &type);
static HIR::TypePath *translate (AST::TypePath &type);
void visit (AST::TypePathSegmentFunction &segment) override;
// setup paths
CanonicalPath canonical_trait_type = CanonicalPath::create_empty ();
- bool ok = ResolveTypeToCanonicalPath::go (impl_block.get_trait_path (),
+ bool ok = ResolveTypeToCanonicalPath::go (impl_block.get_trait_path_type (),
canonical_trait_type);
if (!ok)
{
#include "rust-ast-resolve-base.h"
#include "rust-ast-resolve-expr.h"
+#include "rust-hir-map.h"
+#include "rust-path.h"
namespace Rust {
namespace Resolver {
using Rust::Resolver::ResolverBase::visit;
public:
+ static NodeId go (AST::TypePath &type_path)
+ {
+ return ResolveType::go ((AST::Type &) type_path);
+ }
+
+ static NodeId go (AST::Path &type_path)
+ {
+ if (type_path.get_path_kind () == AST::Path::Kind::LangItem)
+ {
+ auto &type = static_cast<AST::LangItemPath &> (type_path);
+
+ Analysis::Mappings::get_lang_item (type);
+
+ type.get_node_id ();
+ }
+
+ rust_assert (type_path.get_path_kind () == AST::Path::Kind::Type);
+
+ // We have to do this dance to first downcast to a typepath, and then upcast
+ // to a Type. The altnernative is to split `go` into `go` and `go_inner` or
+ // something, but eventually this will need to change as we'll need
+ // `ResolveType::` to resolve other kinds of `Path`s as well.
+ return ResolveType::go (
+ (AST::Type &) static_cast<AST::TypePath &> (type_path));
+ }
+
static NodeId go (AST::Type &type)
{
ResolveType resolver;