aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-struct-field-expr.cc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-09-27 14:06:08 +0000
committerGitHub <noreply@github.com>2022-09-27 14:06:08 +0000
commitb71e3dc02a8fd3141080419b7fb1a24d2c4133d0 (patch)
tree44b3a95ad14a292d10c025127cdf235480154194 /gcc/rust/backend/rust-compile-struct-field-expr.cc
parentcecd314884a285957a110560bbd141a5f39ad7d3 (diff)
parentb17e69852ea999547305b19e9c8da385f6c31e1e (diff)
downloadgcc-b71e3dc02a8fd3141080419b7fb1a24d2c4133d0.zip
gcc-b71e3dc02a8fd3141080419b7fb1a24d2c4133d0.tar.gz
gcc-b71e3dc02a8fd3141080419b7fb1a24d2c4133d0.tar.bz2
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>
Diffstat (limited to 'gcc/rust/backend/rust-compile-struct-field-expr.cc')
0 files changed, 0 insertions, 0 deletions