Skip to content

Commit 5ff7349

Browse files
committed
move report_invalid_macro_expansion_item to item.rs
1 parent 10a52c2 commit 5ff7349

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/libsyntax/parse/parser.rs

-19
Original file line numberDiff line numberDiff line change
@@ -1367,25 +1367,6 @@ impl<'a> Parser<'a> {
13671367
}
13681368
}
13691369
}
1370-
1371-
fn report_invalid_macro_expansion_item(&self) {
1372-
self.struct_span_err(
1373-
self.prev_span,
1374-
"macros that expand to items must be delimited with braces or followed by a semicolon",
1375-
).multipart_suggestion(
1376-
"change the delimiters to curly braces",
1377-
vec![
1378-
(self.prev_span.with_hi(self.prev_span.lo() + BytePos(1)), String::from(" {")),
1379-
(self.prev_span.with_lo(self.prev_span.hi() - BytePos(1)), '}'.to_string()),
1380-
],
1381-
Applicability::MaybeIncorrect,
1382-
).span_suggestion(
1383-
self.sess.source_map().next_point(self.prev_span),
1384-
"add a semicolon",
1385-
';'.to_string(),
1386-
Applicability::MaybeIncorrect,
1387-
).emit();
1388-
}
13891370
}
13901371

13911372
pub fn emit_unclosed_delims(unclosed_delims: &mut Vec<UnmatchedBrace>, handler: &errors::Handler) {

src/libsyntax/parse/parser/item.rs

+20
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use log::debug;
1919
use std::mem;
2020
use rustc_target::spec::abi::Abi;
2121
use errors::{Applicability, DiagnosticBuilder, DiagnosticId, StashKey};
22+
use syntax_pos::BytePos;
2223

2324
/// Whether the type alias or associated type is a concrete type or an opaque type.
2425
#[derive(Debug)]
@@ -1720,6 +1721,25 @@ impl<'a> Parser<'a> {
17201721
}
17211722
}
17221723

1724+
fn report_invalid_macro_expansion_item(&self) {
1725+
self.struct_span_err(
1726+
self.prev_span,
1727+
"macros that expand to items must be delimited with braces or followed by a semicolon",
1728+
).multipart_suggestion(
1729+
"change the delimiters to curly braces",
1730+
vec![
1731+
(self.prev_span.with_hi(self.prev_span.lo() + BytePos(1)), String::from(" {")),
1732+
(self.prev_span.with_lo(self.prev_span.hi() - BytePos(1)), '}'.to_string()),
1733+
],
1734+
Applicability::MaybeIncorrect,
1735+
).span_suggestion(
1736+
self.sess.source_map().next_point(self.prev_span),
1737+
"add a semicolon",
1738+
';'.to_string(),
1739+
Applicability::MaybeIncorrect,
1740+
).emit();
1741+
}
1742+
17231743
fn mk_item(&self, span: Span, ident: Ident, kind: ItemKind, vis: Visibility,
17241744
attrs: Vec<Attribute>) -> P<Item> {
17251745
P(Item {

0 commit comments

Comments
 (0)