aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-02-10 11:54:39 +0100
committerPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-03-30 13:52:28 +0200
commit4f16aff137ed29caf9db5e362994bdd6944e39d5 (patch)
treef2507ba3f971901d5ab2f93a664a9b6970305ccd
parentdf33f7b5bb1fb0936a9fc6cf9b9cc251447ad89e (diff)
downloadgcc-4f16aff137ed29caf9db5e362994bdd6944e39d5.zip
gcc-4f16aff137ed29caf9db5e362994bdd6944e39d5.tar.gz
gcc-4f16aff137ed29caf9db5e362994bdd6944e39d5.tar.bz2
libproc_macro: Add Span type rust interface
Add the rust stable interface for Span type in libproc_macro. ChangeLog: * librust/proc_macro/rust/lib.rs: Add span type interface Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--librust/proc_macro/rust/lib.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/librust/proc_macro/rust/lib.rs b/librust/proc_macro/rust/lib.rs
index b2da8bb..d3ef527 100644
--- a/librust/proc_macro/rust/lib.rs
+++ b/librust/proc_macro/rust/lib.rs
@@ -1,3 +1,5 @@
+use std::fmt;
+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Delimiter {
Parenthesis,
@@ -6,3 +8,46 @@ pub enum Delimiter {
/// Invisible delimiter
None,
}
+
+#[derive(Copy, Clone)]
+pub struct Span {
+ // Internal implementation details
+}
+
+impl Span {
+ // TODO: Add experimental API functions for this type
+
+ /// Creates a new span that resolves at the macro call location
+ pub fn call_site() -> Self {
+ todo!("Implement this function")
+ }
+
+ /// Creates a new span that resolved sometimes at macro call site, and
+ /// sometimes at macro definition site
+ pub fn mixed_site() -> Self {
+ todo!("Implement this function")
+ }
+
+ /// Creates a new span with the same line/column informations but that
+ /// resolve symbols as though it were at `other`
+ pub fn resolved_at(&self, other: Span) -> Self {
+ todo!("Implement this function")
+ }
+
+ /// Creates a new span with the same name resolution behavior as self, but
+ /// with the line/column information of `other`.
+ pub fn located_at(&self, other: Span) -> Self {
+ todo!("Implement this function")
+ }
+
+ /// Return the source text behind a span.
+ pub fn source_text(&self) -> Option<String> {
+ todo!("Implement this function")
+ }
+}
+
+impl fmt::Debug for Span {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ todo!("Implement this function")
+ }
+}