aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-06-29 15:37:38 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-06-29 16:35:52 +0100
commit18648e7b9f54c0cec4d4d865ff42b453b8de7101 (patch)
treee81aeb3fa144b3cb85139c2d0eae4092d68db5e8 /gcc/rust/ast
parent81abc8623cb75fa18315c65e94c5965ec36fdb54 (diff)
downloadgcc-18648e7b9f54c0cec4d4d865ff42b453b8de7101.zip
gcc-18648e7b9f54c0cec4d4d865ff42b453b8de7101.tar.gz
gcc-18648e7b9f54c0cec4d4d865ff42b453b8de7101.tar.bz2
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
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r--gcc/rust/ast/rust-path.h6
1 files changed, 6 insertions, 0 deletions
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