1
Fork 0

* Rename 'move_span' into 'local_span_to_global_span'

* Add documentation on new arguments/functions
This commit is contained in:
Guillaume Gomez 2021-04-20 17:42:06 +02:00 committed by Guillaume Gomez
parent b5c27b49d0
commit 2a3b71ae33
4 changed files with 85 additions and 17 deletions

View file

@ -1943,14 +1943,18 @@ crate enum Variant {
crate struct Span(rustc_span::Span);
impl Span {
/// Wraps a [`rustc_span::Span`]. In case this span is the result of a macro expansion, the
/// span will be updated to point to the macro invocation instead of the macro definition.
///
/// (See rust-lang/rust#39726)
crate fn from_rustc_span(sp: rustc_span::Span) -> Self {
// Get the macro invocation instead of the definition,
// in case the span is result of a macro expansion.
// (See rust-lang/rust#39726)
Self(sp.source_callsite())
}
/// Unless you know what you're doing, use [`Self::from_rustc_span`] instead!
///
/// Contrary to [`Self::from_rustc_span`], this constructor wraps the span as is and don't
/// perform any operation on it, even if it's from a macro expansion.
crate fn wrap(sp: rustc_span::Span) -> Span {
Self(sp)
}