summaryrefslogtreecommitdiffstats
path: root/library/proc_macro
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /library/proc_macro
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/proc_macro')
-rw-r--r--library/proc_macro/src/bridge/mod.rs10
-rw-r--r--library/proc_macro/src/lib.rs8
2 files changed, 17 insertions, 1 deletions
diff --git a/library/proc_macro/src/bridge/mod.rs b/library/proc_macro/src/bridge/mod.rs
index 4c1e196b5..caecda1bc 100644
--- a/library/proc_macro/src/bridge/mod.rs
+++ b/library/proc_macro/src/bridge/mod.rs
@@ -14,6 +14,7 @@ use std::hash::Hash;
use std::marker;
use std::mem;
use std::ops::Bound;
+use std::ops::Range;
use std::panic;
use std::sync::atomic::AtomicUsize;
use std::sync::Once;
@@ -93,6 +94,7 @@ macro_rules! with_api {
fn source_file($self: $S::Span) -> $S::SourceFile;
fn parent($self: $S::Span) -> Option<$S::Span>;
fn source($self: $S::Span) -> $S::Span;
+ fn byte_range($self: $S::Span) -> Range<usize>;
fn start($self: $S::Span) -> LineColumn;
fn end($self: $S::Span) -> LineColumn;
fn before($self: $S::Span) -> $S::Span;
@@ -335,6 +337,8 @@ pub enum LitKind {
StrRaw(u8),
ByteStr,
ByteStrRaw(u8),
+ CStr,
+ CStrRaw(u8),
Err,
}
@@ -348,6 +352,8 @@ rpc_encode_decode!(
StrRaw(n),
ByteStr,
ByteStrRaw(n),
+ CStr,
+ CStrRaw(n),
Err,
}
);
@@ -519,3 +525,7 @@ pub struct ExpnGlobals<Span> {
compound_traits!(
struct ExpnGlobals<Span> { def_site, call_site, mixed_site }
);
+
+compound_traits!(
+ struct Range<T> { start, end }
+);
diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs
index 9d081c8b8..c64665b6a 100644
--- a/library/proc_macro/src/lib.rs
+++ b/library/proc_macro/src/lib.rs
@@ -44,7 +44,7 @@ mod diagnostic;
pub use diagnostic::{Diagnostic, Level, MultiSpan};
use std::cmp::Ordering;
-use std::ops::RangeBounds;
+use std::ops::{Range, RangeBounds};
use std::path::PathBuf;
use std::str::FromStr;
use std::{error, fmt};
@@ -488,6 +488,12 @@ impl Span {
Span(self.0.source())
}
+ /// Returns the span's byte position range in the source file.
+ #[unstable(feature = "proc_macro_span", issue = "54725")]
+ pub fn byte_range(&self) -> Range<usize> {
+ self.0.byte_range()
+ }
+
/// Gets the starting line/column in the source file for this span.
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn start(&self) -> LineColumn {