public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Merge #1346
@ 2022-07-06 12:51 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-07-06 12:51 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e0844def89deb7953b6eee563833b0e8e8e2668d

commit e0844def89deb7953b6eee563833b0e8e8e2668d
Merge: 408b7f87b99 f4a5629fb7f
Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Date:   Wed Jul 6 09:15:56 2022 +0000

    Merge #1346
    
    1346: Support self paths r=philberty a=philberty
    
    This adds support for the self path which is used in two different
    contexts. One where it refers to the self parameter within methods
    the other is where it can refer to the crate module scope.
    
    Handling self has some limitations where it must be the first
    the segment in the path or be a single segment path for example see:
    
    ```
      struct foo;
    
      fn test() {
        crate::self::foo;
      }
    ```
    
    Errors with (rustc 1.61):
    
    ```
      Error[E0433]: failed to resolve: `self` in paths can only be used in start position
    ```
    
    crate and super keywords can be chained as expected but self seems to be a special case.
    
    The patch here reorders the algorithm to look at the name/type scope first if its the first segment
    and handle the lower case self as a special case. If this fails to result in a resolved node we
    then try to look at the module_scope_id hierarchy to handle the case that the previous segments
    were crate or super and finally error out at the end if we failed to resolve the segment. We can
    only error for the first segment as associated paths such as Foo::Bar with Bar being an associated
    impl block item requiring type-resolution.
    
    Fixes #1231 #1227
    
    Co-authored-by: Philip Herron <philip.herron@embecosm.com>

Diff:

 gcc/rust/ast/rust-path.h                         |  6 ++
 gcc/rust/resolve/rust-ast-resolve-path.cc        | 89 +++++++++++++++--------
 gcc/rust/resolve/rust-ast-resolve-type.cc        | 90 +++++++++++++++---------
 gcc/testsuite/rust/compile/self-path1.rs         | 12 ++++
 gcc/testsuite/rust/compile/self-path2.rs         | 21 ++++++
 gcc/testsuite/rust/execute/torture/issue-1231.rs | 36 ++++++++++
 6 files changed, 188 insertions(+), 66 deletions(-)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-06 12:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06 12:51 [gcc/devel/rust/master] Merge #1346 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).