Skip to content

Commit

Permalink
Rollup merge of #65790 - Centril:move-report-invalid, r=davidtwco
Browse files Browse the repository at this point in the history
move report_invalid_macro_expansion_item to item.rs

From #65324.

r? @Mark-Simulacrum
  • Loading branch information
Centril authored Oct 25, 2019
2 parents cbcbba2 + 5ff7349 commit c0bbb4b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,25 +1368,6 @@ impl<'a> Parser<'a> {
}
}
}

fn report_invalid_macro_expansion_item(&self) {
self.struct_span_err(
self.prev_span,
"macros that expand to items must be delimited with braces or followed by a semicolon",
).multipart_suggestion(
"change the delimiters to curly braces",
vec![
(self.prev_span.with_hi(self.prev_span.lo() + BytePos(1)), String::from(" {")),
(self.prev_span.with_lo(self.prev_span.hi() - BytePos(1)), '}'.to_string()),
],
Applicability::MaybeIncorrect,
).span_suggestion(
self.sess.source_map().next_point(self.prev_span),
"add a semicolon",
';'.to_string(),
Applicability::MaybeIncorrect,
).emit();
}
}

pub fn emit_unclosed_delims(unclosed_delims: &mut Vec<UnmatchedBrace>, handler: &errors::Handler) {
Expand Down
20 changes: 20 additions & 0 deletions src/libsyntax/parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use log::debug;
use std::mem;
use rustc_target::spec::abi::Abi;
use errors::{Applicability, DiagnosticBuilder, DiagnosticId, StashKey};
use syntax_pos::BytePos;

/// Whether the type alias or associated type is a concrete type or an opaque type.
#[derive(Debug)]
Expand Down Expand Up @@ -1739,6 +1740,25 @@ impl<'a> Parser<'a> {
}
}

fn report_invalid_macro_expansion_item(&self) {
self.struct_span_err(
self.prev_span,
"macros that expand to items must be delimited with braces or followed by a semicolon",
).multipart_suggestion(
"change the delimiters to curly braces",
vec![
(self.prev_span.with_hi(self.prev_span.lo() + BytePos(1)), String::from(" {")),
(self.prev_span.with_lo(self.prev_span.hi() - BytePos(1)), '}'.to_string()),
],
Applicability::MaybeIncorrect,
).span_suggestion(
self.sess.source_map().next_point(self.prev_span),
"add a semicolon",
';'.to_string(),
Applicability::MaybeIncorrect,
).emit();
}

fn mk_item(&self, span: Span, ident: Ident, kind: ItemKind, vis: Visibility,
attrs: Vec<Attribute>) -> P<Item> {
P(Item {
Expand Down

0 comments on commit c0bbb4b

Please sign in to comment.