public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Merge #1545
@ 2022-09-27 15:50 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-09-27 15:50 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b71e3dc02a8fd3141080419b7fb1a24d2c4133d0
commit b71e3dc02a8fd3141080419b7fb1a24d2c4133d0
Merge: cecd314884a b17e69852ea
Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Date: Tue Sep 27 14:06:08 2022 +0000
Merge #1545
1545: Refactor TypeResolution to be a simple query based system r=philberty a=philberty
This patch refactors the type resolution system to introduce a new
interface
bool query_type (HirId, TyTy::BaseType** result)
This is needed in order to properly support forward declared items. Our
name resolution system has two parts:
1. Toplevel scan
2. Item resolution
The toplevel scan gathers all the nesseacry 'names' into their respective
namespace by doing a full toplevel scan and generate canonical paths for
each item. The second pass is responsible for drilling down into each
structure or function to resolve each field or variable etc. This means
our name resolution system supports forward decalred items but our type
resolution system did not.
This patch removes the toplevel scan from our type resolution pass which
is not able to handle all cases such as a function with return type and
the type is decalred after the fact or a type alias to a type declared
after the fact. The name resolution mappings are resolved so when errors
occured here we got errors such as unable to lookup HirId 1234, which meant
yes we have 'resolved' this reference to this HirId but we are unable to
find any type information for it. This means we needed a new way to figure
out the type in a query based way.
This is where the new query_type inferface comes in so when we have an
HirId we want to resolve the mappings class allows us to figure out what
item this is such as:
1. HIR::Item (normal HIR::Function, Struct, TypeAlias, ...)
2. HIR::ImplItem (function, constant, ... within an impl-block)
3. HIR::ImplBlock (Self type on an impl-block)
4. HIR::ExternalItem (extern-block item)
The mappings class allows us to simply lookup these HIR nodes and then
call the relevant resolver class to compute the type. This patch does not
add support for self-referencial types but is the starting point to be able to support such types.
Fixes #1455
Fixes #1006
Fixes #1073
Fixes #1272
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diff:
gcc/rust/Make-lang.in | 2 +-
gcc/rust/backend/rust-compile-context.h | 21 +-
gcc/rust/backend/rust-compile-expr.h | 17 +-
gcc/rust/backend/rust-compile-item.cc | 14 +-
gcc/rust/backend/rust-constexpr.cc | 16 +-
gcc/rust/checks/lints/rust-lint-marklive.cc | 7 +-
gcc/rust/resolve/rust-name-resolver.cc | 20 +
gcc/rust/resolve/rust-name-resolver.h | 6 +
gcc/rust/typecheck/rust-hir-dot-operator.cc | 8 +-
gcc/rust/typecheck/rust-hir-dot-operator.h | 6 +-
gcc/rust/typecheck/rust-hir-path-probe.cc | 46 ++
gcc/rust/typecheck/rust-hir-path-probe.h | 24 +-
gcc/rust/typecheck/rust-hir-type-check-base.cc | 76 +++
gcc/rust/typecheck/rust-hir-type-check-base.h | 2 +
gcc/rust/typecheck/rust-hir-type-check-expr.cc | 3 +
gcc/rust/typecheck/rust-hir-type-check-implitem.cc | 181 +++----
gcc/rust/typecheck/rust-hir-type-check-implitem.h | 42 +-
gcc/rust/typecheck/rust-hir-type-check-item.cc | 554 +++++++++++++++++----
gcc/rust/typecheck/rust-hir-type-check-item.h | 47 +-
gcc/rust/typecheck/rust-hir-type-check-path.cc | 9 +-
gcc/rust/typecheck/rust-hir-type-check-stmt.cc | 387 ++------------
gcc/rust/typecheck/rust-hir-type-check-stmt.h | 62 +--
gcc/rust/typecheck/rust-hir-type-check-toplevel.cc | 378 --------------
gcc/rust/typecheck/rust-hir-type-check-toplevel.h | 56 ---
gcc/rust/typecheck/rust-hir-type-check-type.cc | 110 ++--
gcc/rust/typecheck/rust-hir-type-check.cc | 9 +-
gcc/rust/typecheck/rust-hir-type-check.h | 41 ++
gcc/rust/typecheck/rust-substitution-mapper.h | 2 +-
gcc/rust/typecheck/rust-tyty-bounds.cc | 24 +-
gcc/rust/typecheck/rust-tyty-cmp.h | 2 +
gcc/rust/typecheck/rust-tyty.cc | 45 +-
gcc/rust/typecheck/rust-tyty.h | 34 +-
gcc/rust/util/rust-hir-map.cc | 13 +
gcc/rust/util/rust-hir-map.h | 2 +
gcc/testsuite/rust/compile/const_generics_5.rs | 13 +-
gcc/testsuite/rust/compile/issue-1006.rs | 10 +
gcc/testsuite/rust/compile/issue-1073.rs | 4 +
gcc/testsuite/rust/compile/issue-1272.rs | 8 +
.../rust/compile/unconstrained_type_param.rs | 2 +
39 files changed, 1058 insertions(+), 1245 deletions(-)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-27 15:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 15:50 [gcc/devel/rust/master] Merge #1545 Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).