From 18648e7b9f54c0cec4d4d865ff42b453b8de7101 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Wed, 29 Jun 2022 15:37:38 +0100 Subject: Add support for the self path This keyword is described in https://doc.rust-lang.org/std/keyword.self.html Which allows it to refer to the current module when used as the first segment. If the keyword is used as any other segment it leads to a confusion between self the local parameter keyword in methods. Rustc emits a generic unresolved segment error in that senario which I have adopted here. Fixes #1227 --- gcc/rust/ast/rust-path.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/rust/ast') diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index d2d925a..367c6d6 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -50,6 +50,8 @@ public: std::string as_string () const { return segment_name; } + Location get_locus () const { return locus; } + bool is_super_segment () const { return as_string ().compare ("super") == 0; } bool is_crate_segment () const { return as_string ().compare ("crate") == 0; } bool is_lower_self () const { return as_string ().compare ("self") == 0; } @@ -616,6 +618,10 @@ public: return get_ident_segment ().is_super_segment (); } bool is_big_self_seg () const { return get_ident_segment ().is_big_self (); } + bool is_lower_self_seg () const + { + return get_ident_segment ().is_lower_self (); + } }; // Segment used in type path with generic args -- cgit v1.1