Skip to content

Commit c0bbb4b

Browse files
authored
Rollup merge of #65790 - Centril:move-report-invalid, r=davidtwco
move report_invalid_macro_expansion_item to item.rs From #65324. r? @Mark-Simulacrum
2 parents cbcbba2 + 5ff7349 commit c0bbb4b

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

13921373
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)]
@@ -1739,6 +1740,25 @@ impl<'a> Parser<'a> {
17391740
}
17401741
}
17411742

1743+
fn report_invalid_macro_expansion_item(&self) {
1744+
self.struct_span_err(
1745+
self.prev_span,
1746+
"macros that expand to items must be delimited with braces or followed by a semicolon",
1747+
).multipart_suggestion(
1748+
"change the delimiters to curly braces",
1749+
vec![
1750+
(self.prev_span.with_hi(self.prev_span.lo() + BytePos(1)), String::from(" {")),
1751+
(self.prev_span.with_lo(self.prev_span.hi() - BytePos(1)), '}'.to_string()),
1752+
],
1753+
Applicability::MaybeIncorrect,
1754+
).span_suggestion(
1755+
self.sess.source_map().next_point(self.prev_span),
1756+
"add a semicolon",
1757+
';'.to_string(),
1758+
Applicability::MaybeIncorrect,
1759+
).emit();
1760+
}
1761+
17421762
fn mk_item(&self, span: Span, ident: Ident, kind: ItemKind, vis: Visibility,
17431763
attrs: Vec<Attribute>) -> P<Item> {
17441764
P(Item {

0 commit comments

Comments
 (0)