Skip to content

Commit 42f34d4

Browse files
committed
Fix breakage after proc_macro LineColumn/Spam changes
(for nightly rustc) Signed-off-by: Miezhiko <[email protected]>
1 parent 9570b97 commit 42f34d4

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

macros/src/embed_python.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use proc_macro::{LineColumn, Span};
2-
use proc_macro2::{Delimiter, Ident, Spacing, TokenStream, TokenTree};
1+
use proc_macro::Span;
2+
use proc_macro2::{Delimiter, Ident, Spacing, TokenStream, TokenTree, LineColumn};
33
use quote::quote_spanned;
44
use std::collections::BTreeMap;
55
use std::fmt::Write;
@@ -52,7 +52,9 @@ impl EmbedPython {
5252

5353
while let Some(token) = tokens.next() {
5454
let span = token.span().unwrap();
55-
self.add_whitespace(span, span.start())?;
55+
let start_span = span.start();
56+
let lc = LineColumn { line: start_span.line(), column: start_span.column() };
57+
self.add_whitespace(span, lc)?;
5658

5759
match &token {
5860
TokenTree::Group(x) => {
@@ -65,9 +67,10 @@ impl EmbedPython {
6567
self.python.push_str(start);
6668
self.loc.column += start.len();
6769
self.add(x.stream())?;
68-
let mut end_loc = token.span().unwrap().end();
69-
end_loc.column = end_loc.column.saturating_sub(end.len());
70-
self.add_whitespace(span, end_loc)?;
70+
let end_loc = token.span().unwrap().end();
71+
let end_col = end_loc.column().saturating_sub(end.len());
72+
let elc = LineColumn { line: end_loc.line(), column: end_col };
73+
self.add_whitespace(span, elc)?;
7174
self.python.push_str(end);
7275
self.loc.column += end.len();
7376
}
@@ -106,7 +109,8 @@ impl EmbedPython {
106109
}
107110
TokenTree::Ident(x) => {
108111
write!(&mut self.python, "{}", x).unwrap();
109-
self.loc = token.span().unwrap().end();
112+
let end_span = token.span().unwrap().end();
113+
self.loc = LineColumn { line: end_span.line(), column: end_span.column() };
110114
}
111115
TokenTree::Literal(x) => {
112116
let s = x.to_string();
@@ -119,7 +123,8 @@ impl EmbedPython {
119123
self.python.pop();
120124
}
121125
self.python += &s;
122-
self.loc = token.span().unwrap().end();
126+
let end_span = token.span().unwrap().end();
127+
self.loc = LineColumn { line: end_span.line(), column: end_span.column() };
123128
}
124129
}
125130
}

macros/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ fn span_for_line(input: TokenStream, line: usize) -> Option<Span> {
5353
let mut spans = input
5454
.into_iter()
5555
.map(|x| x.span().unwrap())
56-
.skip_while(|span| span.start().line < line)
57-
.take_while(|span| span.start().line == line);
56+
.skip_while(|span| span.start().line() < line)
57+
.take_while(|span| span.start().line() == line);
5858

5959
let mut result = spans.next()?;
6060
for span in spans {

0 commit comments

Comments
 (0)