diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-11-17 17:25:01 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-11-17 17:25:01 +0000 |
commit | e8695eee4f1b9121d0caa7a93ff51f69707c607f (patch) | |
tree | dd7a488eae409a4de7886a5b8cb35bbecd17df66 /gcc | |
parent | 649e2ec5682ed8007987f2acb4899892a81cc18f (diff) | |
download | gcc-e8695eee4f1b9121d0caa7a93ff51f69707c607f.zip gcc-e8695eee4f1b9121d0caa7a93ff51f69707c607f.tar.gz gcc-e8695eee4f1b9121d0caa7a93ff51f69707c607f.tar.bz2 |
Add missing implict monomorphized types into the context
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/Make-lang.in | 1 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-substitution-mapper.cc | 49 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-substitution-mapper.h | 8 |
3 files changed, 51 insertions, 7 deletions
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in index f3302c2e..f0e9bc3 100644 --- a/gcc/rust/Make-lang.in +++ b/gcc/rust/Make-lang.in @@ -86,6 +86,7 @@ GRS_OBJS = \ rust/rust-hir-const-fold.o \ rust/rust-hir-type-check-type.o \ rust/rust-hir-type-check-struct.o \ + rust/rust-substitution-mapper.o \ rust/rust-lint-marklive.o \ rust/rust-hir-type-check-path.o \ rust/rust-compile-intrinsic.o \ diff --git a/gcc/rust/typecheck/rust-substitution-mapper.cc b/gcc/rust/typecheck/rust-substitution-mapper.cc new file mode 100644 index 0000000..a439416 --- /dev/null +++ b/gcc/rust/typecheck/rust-substitution-mapper.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2020-2021 Free Software Foundation, Inc. + +// This file is part of GCC. + +// GCC is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3, or (at your option) any later +// version. + +// GCC is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. + +// You should have received a copy of the GNU General Public License +// along with GCC; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include "rust-substitution-mapper.h" +#include "rust-hir-type-check.h" + +namespace Rust { +namespace Resolver { + +TyTy::BaseType * +SubstMapperInternal::Resolve (TyTy::BaseType *base, + TyTy::SubstitutionArgumentMappings &mappings) +{ + SubstMapperInternal mapper (base->get_ref (), mappings); + base->accept_vis (mapper); + rust_assert (mapper.resolved != nullptr); + + // insert these new implict types into the context + bool is_fn = mapper.resolved->get_kind () == TyTy::TypeKind::FNDEF; + bool is_adt = mapper.resolved->get_kind () == TyTy::TypeKind::ADT; + bool is_param = mapper.resolved->get_kind () == TyTy::TypeKind::PARAM; + if (!is_fn && !is_adt && !is_param) + { + auto context = TypeCheckContext::get (); + context->insert_type ( + Analysis::NodeMapping (0, 0, mapper.resolved->get_ty_ref (), 0), + mapper.resolved); + } + + return mapper.resolved; +} + +} // namespace Resolver +} // namespace Rust diff --git a/gcc/rust/typecheck/rust-substitution-mapper.h b/gcc/rust/typecheck/rust-substitution-mapper.h index 0b3ec3b..0932038 100644 --- a/gcc/rust/typecheck/rust-substitution-mapper.h +++ b/gcc/rust/typecheck/rust-substitution-mapper.h @@ -154,13 +154,7 @@ class SubstMapperInternal : public TyTy::TyVisitor { public: static TyTy::BaseType *Resolve (TyTy::BaseType *base, - TyTy::SubstitutionArgumentMappings &mappings) - { - SubstMapperInternal mapper (base->get_ref (), mappings); - base->accept_vis (mapper); - rust_assert (mapper.resolved != nullptr); - return mapper.resolved; - } + TyTy::SubstitutionArgumentMappings &mappings); void visit (TyTy::FnType &type) override { |