Open
Description
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:
impl Span {
pub fn source_text(&self) -> Option<String>;
}
impl Group {
pub fn span_open(&self) -> Span;
pub fn span_close(&self) -> Span;
}
To be stabilized, probably in their current form:
impl Span {
pub fn line(&self) -> usize;
pub fn column(&self) -> usize;
pub fn start(&self) -> Span;
pub fn end(&self) -> Span;
}
To be stabilized after some (re)design or discussion:
impl Span {
pub fn source_file(&self) -> SourceFile;
pub fn byte_range(&self) -> Range<usize>;
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SourceFile { .. }
impl !Send for SourceFile {}
impl !Sync for SourceFile {}
impl SourceFile {
pub fn path(&self) -> PathBuf;
pub fn is_real(&self) -> bool;
}
Things that require more discussion:
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 Literal {
pub fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: Procedural macrosArea: Procedural macrosBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.Category: A tracking issue for an RFC or an unstable feature.Category: A tracking issue for an RFC or an unstable feature.Libs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.Status: There are blocking β design concerns.Status: There are blocking β design concerns.Relevant to the language team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.