IssueRaiser

Tracking issue for `proc_macro::Span` inspection APIs

<!-- homu-ignore:start --> *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/issues/54725)* <!-- homu-ignore:end --> This issue is intended to track a number of unstable APIs which are used to inspect the contents of a `Span` for information like the file name, byte position, manufacturing new spans, combining them, etc. This issue tracks the `proc_macro_span` unstable feature. ### Public API Already stabilized: ```rust impl Span { // as `proc_macro_source_text` pub fn source_text(&self) -> Option<String>; // as `proc_macro_span_location` pub fn start(&self) -> Span; pub fn end(&self) -> Span; pub fn line(&self) -> usize; pub fn column(&self) -> usize; // as `proc_macro_span_file` pub fn file(&self) -> String; // Mapped file name, for display purposes. pub fn local_file(&self) -> Option<PathBuf>; // Real file name as it exists on disk. } impl Group { // as `proc_macro_group_span` pub fn span_open(&self) -> Span; pub fn span_close(&self) -> Span; } ``` Close to stabilization, pending some bikeshedding: ```rust impl Span { pub fn byte_range(&self) -> Range<usize>; // Open question: Do we want to use the old or new Range type? } ``` Things that require more discussion: ```rust impl Span { pub fn eq(&self, other: &Span) -> bool; pub fn join(&self, other: Span) -> Option<Span>; pub fn parent(&self) -> Option<Span>; pub fn source(&self) -> Span; } impl Litera

Posted by alexcrichton on Oct 1, 2018, 5:52 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

github (Sysadmin)

Tracking issue for `proc_macro::Span` inspection APIs

alexcrichtonOct 1, 2018, 5:52 PM

<!-- homu-ignore:start --> *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/issues/54725)* <!-- homu-ignore:end --> This issue is intended to track a number of unstable APIs which are used to inspect the contents of a `Span` for information like the file name, byte position, manufacturing new spans, combining them, etc. This issue tracks the `proc_macro_span` unstable feature. ### Public API Already stabilized: ```rust impl Span { // as `proc_macro_source_text` pub fn source_text(&self) -> Option<String>; // as `proc_macro_span_location` pub fn start(&self) -> Span; pub fn end(&self) -> Span; pub fn line(&self) -> usize; pub fn column(&self) -> usize; // as `proc_macro_span_file` pub fn file(&self) -> String; // Mapped file name, for display purposes. pub fn local_file(&self) -> Option<PathBuf>; // Real file name as it exists on disk. } impl Group { // as `proc_macro_group_span` pub fn span_open(&self) -> Span; pub fn span_close(&self) -> Span; } ``` Close to stabilization, pending some bikeshedding: ```rust impl Span { pub fn byte_range(&self) -> Range<usize>; // Open question: Do we want to use the old or new Range type? } ``` Things that require more discussion: ```rust impl Span { pub fn eq(&self, other: &Span) -> bool; pub fn join(&self, other: Span) -> Option<Span>; pub fn parent(&self) -> Option<Span>; pub fn source(&self) -> Span; } impl Litera

Comments (0)

No comments yet. Start the discussion.

Comment on this issue