Lines Matching full:span
187 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
330 pub fn span(&self) -> Span { in span() argument
331 Span::_new(self.inner.span()) in span()
351 pub struct Span { struct
352 inner: imp::Span, argument
356 impl Span { argument
357 fn _new(inner: imp::Span) -> Self { in _new()
358 Span { in _new()
364 fn _new_fallback(inner: fallback::Span) -> Self { in _new_fallback()
365 Span { in _new_fallback()
366 inner: imp::Span::from(inner), in _new_fallback()
371 /// The span of the invocation of the current procedural macro.
373 /// Identifiers created with this span will be resolved as if they were
377 Span::_new(imp::Span::call_site()) in call_site()
380 /// The span located at the invocation of the procedural macro, but with
384 Span::_new(imp::Span::mixed_site()) in mixed_site()
387 /// A span that resolves at the macro definition site.
393 Span::_new(imp::Span::def_site()) in def_site()
396 /// Creates a new span with the same line/column information as `self` but
398 pub fn resolved_at(&self, other: Span) -> Span { in resolved_at() argument
399 Span::_new(self.inner.resolved_at(other.inner)) in resolved_at()
402 /// Creates a new span with the same name resolution behavior as `self` but
404 pub fn located_at(&self, other: Span) -> Span { in located_at() argument
405 Span::_new(self.inner.located_at(other.inner)) in located_at()
408 /// Convert `proc_macro2::Span` to `proc_macro::Span`.
416 /// `proc_macro2::Span`, the `proc_macro::Span` type can only exist within
419 pub fn unwrap(self) -> proc_macro::Span { in unwrap() argument
423 // Soft deprecated. Please use Span::unwrap.
426 pub fn unstable(self) -> proc_macro::Span { in unstable() argument
430 /// Returns the span's byte position range in the source file.
432 /// This method requires the `"span-locations"` feature to be enabled.
440 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
445 /// Get the starting line/column in the source file for this span.
447 /// This method requires the `"span-locations"` feature to be enabled.
455 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
460 /// Get the ending line/column in the source file for this span.
462 /// This method requires the `"span-locations"` feature to be enabled.
470 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
475 /// The path to the source file in which this span occurs, for display
481 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
486 /// The path to the source file in which this span occurs on disk.
493 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
498 /// Create a new span encompassing `self` and `other`.
502 /// Warning: the underlying [`proc_macro::Span::join`] method is
505 pub fn join(&self, other: Span) -> Option<Span> { in join() argument
506 self.inner.join(other.inner).map(Span::_new) in join()
514 pub fn eq(&self, other: &Span) -> bool { in eq()
518 /// Returns the source text behind a span. This preserves the original
520 /// the span corresponds to real source code.
530 /// Prints a span in a form convenient for debugging.
531 impl Debug for Span { implementation
551 /// Returns the span of this tree, delegating to the `span` method of
553 pub fn span(&self) -> Span { in span() argument
555 TokenTree::Group(t) => t.span(), in span()
556 TokenTree::Ident(t) => t.span(), in span()
557 TokenTree::Punct(t) => t.span(), in span()
558 TokenTree::Literal(t) => t.span(), in span()
562 /// Configures the span for *only this token*.
565 /// the span of each of the internal tokens, this will simply delegate to
567 pub fn set_span(&mut self, span: Span) { in set_span() argument
569 TokenTree::Group(t) => t.set_span(span), in set_span()
570 TokenTree::Ident(t) => t.set_span(span), in set_span()
571 TokenTree::Punct(t) => t.set_span(span), in set_span()
572 TokenTree::Literal(t) => t.set_span(span), in set_span()
626 imp::debug_span_field_if_nontrivial(&mut debug, t.span().inner); in fmt()
688 /// This constructor will set the span for this group to
689 /// `Span::call_site()`. To change the span you can use the `set_span`
711 /// Returns the span for the delimiters of this token stream, spanning the
715 /// pub fn span(&self) -> Span {
718 pub fn span(&self) -> Span { in span() argument
719 Span::_new(self.inner.span()) in span()
722 /// Returns the span pointing to the opening delimiter of this group.
725 /// pub fn span_open(&self) -> Span {
728 pub fn span_open(&self) -> Span { in span_open() argument
729 Span::_new(self.inner.span_open()) in span_open()
732 /// Returns the span pointing to the closing delimiter of this group.
735 /// pub fn span_close(&self) -> Span {
738 pub fn span_close(&self) -> Span { in span_close() argument
739 Span::_new(self.inner.span_close()) in span_close()
749 /// Configures the span for this `Group`'s delimiters, but not its internal
752 /// This method will **not** set the span of all the internal tokens spanned
753 /// by this group, but rather it will only set the span of the delimiter
755 pub fn set_span(&mut self, span: Span) { in set_span() argument
756 self.inner.set_span(span.inner); in set_span()
783 span: Span, field
805 /// The returned `Punct` will have the default span of `Span::call_site()`
814 span: Span::call_site(), in new()
835 /// Returns the span for this punctuation character.
836 pub fn span(&self) -> Span { in span() argument
837 self.span in span()
840 /// Configure the span for this punctuation character.
841 pub fn set_span(&mut self, span: Span) { in set_span() argument
842 self.span = span; in set_span()
859 imp::debug_span_field_if_nontrivial(&mut debug, self.span.inner); in fmt()
883 /// A span must be provided explicitly which governs the name resolution
887 /// use proc_macro2::{Ident, Span};
890 /// let call_ident = Ident::new("calligraphy", Span::call_site());
899 /// use proc_macro2::{Ident, Span};
903 /// let ident = Ident::new("demo", Span::call_site());
909 /// let temp_ident = Ident::new(&format!("new_{}", ident), Span::call_site());
918 /// # use proc_macro2::{Ident, Span};
920 /// # let ident = Ident::new("another_identifier", Span::call_site());
950 /// `span`.
955 /// Note that `span`, currently in rustc, configures the hygiene information
958 /// As of this time `Span::call_site()` explicitly opts-in to "call-site"
959 /// hygiene meaning that identifiers created with this span will be resolved
963 /// Later spans like `Span::def_site()` will allow to opt-in to
965 /// span will be resolved at the location of the macro definition and other
969 /// tokens, requires a `Span` to be specified at construction.
981 pub fn new(string: &str, span: Span) -> Self { in new()
982 Ident::_new(imp::Ident::new_checked(string, span.inner)) in new()
991 pub fn new_raw(string: &str, span: Span) -> Self { in new_raw()
992 Ident::_new(imp::Ident::new_raw_checked(string, span.inner)) in new_raw()
995 /// Returns the span of this `Ident`.
996 pub fn span(&self) -> Span { in span() argument
997 Span::_new(self.inner.span()) in span()
1000 /// Configures the span of this `Ident`, possibly changing its hygiene
1002 pub fn set_span(&mut self, span: Span) { in set_span() argument
1003 self.inner.set_span(span.inner); in set_span()
1078 /// Literals created through this method have the `Span::call_site()`
1079 /// span by default, which can be configured with the `set_span` method
1099 /// Literals created through this method have the `Span::call_site()`
1100 /// span by default, which can be configured with the `set_span` method
1250 /// Returns the span encompassing this literal.
1251 pub fn span(&self) -> Span { in span() argument
1252 Span::_new(self.inner.span()) in span()
1255 /// Configures the span associated for this literal.
1256 pub fn set_span(&mut self, span: Span) { in set_span() argument
1257 self.inner.set_span(span.inner); in set_span()
1260 /// Returns a `Span` that is a subset of `self.span()` containing only
1262 /// trimmed span is outside the bounds of `self`.
1267 pub fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span> { in subspan() argument
1268 self.inner.subspan(range).map(Span::_new) in subspan()