Skip to content

Commit 74cc1fd

Browse files
committed
Rename Span::default -> Span::def_site.
1 parent 8a98531 commit 74cc1fd

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/libproc_macro/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ impl TokenStream {
177177
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
178178
pub struct Span(syntax_pos::Span);
179179

180-
#[unstable(feature = "proc_macro", issue = "38356")]
181-
impl Default for Span {
182-
fn default() -> Span {
180+
impl Span {
181+
/// A span that resolves at the macro definition site.
182+
#[unstable(feature = "proc_macro", issue = "38356")]
183+
pub fn def_site() -> Span {
183184
::__internal::with_sess(|(_, mark)| {
184185
let call_site = mark.expn_info().unwrap().call_site;
185186
Span(call_site.with_ctxt(SyntaxContext::empty().apply_mark(mark)))
@@ -351,7 +352,7 @@ pub struct TokenTree {
351352
#[unstable(feature = "proc_macro", issue = "38356")]
352353
impl From<TokenNode> for TokenTree {
353354
fn from(kind: TokenNode) -> TokenTree {
354-
TokenTree { span: Span::default(), kind: kind }
355+
TokenTree { span: Span::def_site(), kind: kind }
355356
}
356357
}
357358

src/libproc_macro/quote.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Quote for Term {
168168

169169
impl Quote for Span {
170170
fn quote(self) -> TokenStream {
171-
quote!(::Span::default())
171+
quote!(::Span::def_site())
172172
}
173173
}
174174

src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use proc_macro::{TokenStream, TokenNode, Span, Diagnostic};
1818

1919
fn parse(input: TokenStream) -> Result<(), Diagnostic> {
2020
let mut count = 0;
21-
let mut last_span = Span::default();
21+
let mut last_span = Span::def_site();
2222
for tree in input {
2323
let span = tree.span;
2424
if count >= 3 {
@@ -37,7 +37,7 @@ fn parse(input: TokenStream) -> Result<(), Diagnostic> {
3737
}
3838

3939
if count < 3 {
40-
return Err(Span::default()
40+
return Err(Span::def_site()
4141
.error(format!("found {} equal signs, need exactly 3", count))
4242
.help("input must be: `===`"))
4343
}

0 commit comments

Comments
 (0)