adressed comments by @kennytm and @petrochenkov
This commit is contained in:
parent
a9c163ebe9
commit
958c67d9c8
@ -111,7 +111,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
// overflow the maximum line width.
|
||||
description.map(|raw_msg| {
|
||||
let msg = raw_msg.as_str();
|
||||
if !msg.starts_with('\n') || !msg.ends_with('\n') {
|
||||
if !msg.starts_with("\n") || !msg.ends_with("\n") {
|
||||
ecx.span_err(span, &format!(
|
||||
"description for error code {} doesn't start and end with a newline",
|
||||
code
|
||||
@ -120,7 +120,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
|
||||
// URLs can be unavoidably longer than the line limit, so we allow them.
|
||||
// Allowed format is: `[name]: https://www.rust-lang.org/`
|
||||
let is_url = |l: &str| l.starts_with('[') && l.contains("]:") && l.contains("http");
|
||||
let is_url = |l: &str| l.starts_with("[") && l.contains("]:") && l.contains("http");
|
||||
|
||||
if msg.lines().any(|line| line.len() > MAX_DESCRIPTION_WIDTH && !is_url(line)) {
|
||||
ecx.span_err(span, &format!(
|
||||
|
@ -635,8 +635,8 @@ pub struct ExpansionData {
|
||||
}
|
||||
|
||||
/// One of these is made during expansion and incrementally updated as we go;
|
||||
/// when a macro expansion occurs, the resulting nodes have the backtrace()
|
||||
/// -> `expn_info` of their expansion context stored into their span.
|
||||
/// when a macro expansion occurs, the resulting nodes have the `backtrace()
|
||||
/// -> expn_info` of their expansion context stored into their span.
|
||||
pub struct ExtCtxt<'a> {
|
||||
pub parse_sess: &'a parse::ParseSess,
|
||||
pub ecfg: expand::ExpansionConfig<'a>,
|
||||
|
@ -36,43 +36,47 @@
|
||||
//! repetitions indicated by Kleene stars. It only advances or calls out to the
|
||||
//! real Rust parser when no `cur_eis` items remain
|
||||
//!
|
||||
//! Example: Start parsing `a a a a b` against [· a $( a )* a b].
|
||||
//! Example:
|
||||
//!
|
||||
//! Remaining input: `a a a a b`
|
||||
//! `next_eis`: `[· a $( a )* a b]`
|
||||
//! ```text, ignore
|
||||
//! Start parsing a a a a b against [· a $( a )* a b].
|
||||
//!
|
||||
//! - - - Advance over an `a`. - - -
|
||||
//! Remaining input: a a a a b
|
||||
//! next_eis: [· a $( a )* a b]
|
||||
//!
|
||||
//! Remaining input: `a a a b`
|
||||
//! cur: `[a · $( a )* a b]`
|
||||
//! - - - Advance over an a. - - -
|
||||
//!
|
||||
//! Remaining input: a a a b
|
||||
//! cur: [a · $( a )* a b]
|
||||
//! Descend/Skip (first item).
|
||||
//! next: `[a $( · a )* a b] [a $( a )* · a b]`.
|
||||
//! next: [a $( · a )* a b] [a $( a )* · a b].
|
||||
//!
|
||||
//! - - - Advance over an `a`. - - -
|
||||
//! - - - Advance over an a. - - -
|
||||
//!
|
||||
//! Remaining input: `a a b`
|
||||
//! cur: `[a $( a · )* a b]` next: `[a $( a )* a · b]`
|
||||
//! Remaining input: a a b
|
||||
//! cur: [a $( a · )* a b] next: [a $( a )* a · b]
|
||||
//! Finish/Repeat (first item)
|
||||
//! next: `[a $( a )* · a b] [a $( · a )* a b] [a $( a )* a · b]`
|
||||
//! next: [a $( a )* · a b] [a $( · a )* a b] [a $( a )* a · b]
|
||||
//!
|
||||
//! - - - Advance over an `a`. - - - (this looks exactly like the last step)
|
||||
//! - - - Advance over an a. - - - (this looks exactly like the last step)
|
||||
//!
|
||||
//! Remaining input: `a b`
|
||||
//! cur: `[a $( a · )* a b]` next: `[a $( a )* a · b]`
|
||||
//! Remaining input: a b
|
||||
//! cur: [a $( a · )* a b] next: [a $( a )* a · b]
|
||||
//! Finish/Repeat (first item)
|
||||
//! next: `[a $( a )* · a b] [a $( · a )* a b] [a $( a )* a · b]`
|
||||
//! next: [a $( a )* · a b] [a $( · a )* a b] [a $( a )* a · b]
|
||||
//!
|
||||
//! - - - Advance over an `a`. - - - (this looks exactly like the last step)
|
||||
//! - - - Advance over an a. - - - (this looks exactly like the last step)
|
||||
//!
|
||||
//! Remaining input: `b`
|
||||
//! cur: `[a $( a · )* a b]` next: `[a $( a )* a · b]`
|
||||
//! Remaining input: b
|
||||
//! cur: [a $( a · )* a b] next: [a $( a )* a · b]
|
||||
//! Finish/Repeat (first item)
|
||||
//! next: `[a $( a )* · a b] [a $( · a )* a b]`
|
||||
//! next: [a $( a )* · a b] [a $( · a )* a b]
|
||||
//!
|
||||
//! - - - Advance over a `b`. - - -
|
||||
//! - - - Advance over a b. - - -
|
||||
//!
|
||||
//! Remaining input: ``
|
||||
//! eof: `[a $( a )* a b ·]`
|
||||
//! Remaining input: ''
|
||||
//! eof: [a $( a )* a b ·]
|
||||
//! ```
|
||||
|
||||
pub use self::NamedMatch::*;
|
||||
pub use self::ParseResult::*;
|
||||
@ -485,7 +489,7 @@ pub fn parse(sess: &ParseSess, tts: TokenStream, ms: &[TokenTree], directory: Op
|
||||
}
|
||||
|
||||
fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
|
||||
if let "tt" = name {
|
||||
if name == "tt" {
|
||||
return token::NtTT(p.parse_token_tree());
|
||||
}
|
||||
// check at the beginning and the parser checks after each bump
|
||||
|
@ -858,6 +858,7 @@ fn quoted_tt_to_string(tt: "ed::TokenTree) -> String {
|
||||
match *tt {
|
||||
quoted::TokenTree::Token(_, ref tok) => ::print::pprust::token_to_string(tok),
|
||||
quoted::TokenTree::MetaVarDecl(_, name, kind) => format!("${}:{}", name, kind),
|
||||
_ => panic!("unexpected quoted::TokenTree::{{Sequence or Delimited}} in follow set checker"),
|
||||
_ => panic!("unexpected quoted::TokenTree::{{Sequence or Delimited}} \
|
||||
in follow set checker"),
|
||||
}
|
||||
}
|
||||
|
@ -1216,7 +1216,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
}
|
||||
|
||||
ast::ItemKind::Impl(_, polarity, defaultness, _, _, _, _) => {
|
||||
if let ast::ImplPolarity::Negative = polarity {
|
||||
if polarity == ast::ImplPolarity::Negative {
|
||||
gate_feature_post!(&self, optin_builtin_traits,
|
||||
i.span,
|
||||
"negative trait bounds are not yet fully implemented; \
|
||||
@ -1269,10 +1269,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
|
||||
fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) {
|
||||
if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty {
|
||||
if let ast::TyKind::Never = output_ty.node {
|
||||
return
|
||||
if output_ty.node != ast::TyKind::Never {
|
||||
self.visit_ty(output_ty)
|
||||
}
|
||||
self.visit_ty(output_ty)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,8 @@ pub fn expr_is_simple_block(e: &ast::Expr) -> bool {
|
||||
pub fn stmt_ends_with_semi(stmt: &ast::StmtKind) -> bool {
|
||||
match *stmt {
|
||||
ast::StmtKind::Local(_) => true,
|
||||
ast::StmtKind::Item(_) => false,
|
||||
ast::StmtKind::Expr(ref e) => expr_requires_semi_to_be_stmt(e),
|
||||
ast::StmtKind::Item(_) |
|
||||
ast::StmtKind::Semi(..) |
|
||||
ast::StmtKind::Mac(..) => false,
|
||||
}
|
||||
|
@ -341,7 +341,6 @@ pub fn raw_str_lit(lit: &str) -> String {
|
||||
debug!("raw_str_lit: given {}", escape_default(lit));
|
||||
let mut res = String::with_capacity(lit.len());
|
||||
|
||||
// FIXME #8372: This could be a for-loop if it didn't borrow the iterator
|
||||
let mut chars = lit.chars().peekable();
|
||||
while let Some(c) = chars.next() {
|
||||
if c == '\r' {
|
||||
|
@ -1546,7 +1546,7 @@ impl<'a> Parser<'a> {
|
||||
pub fn is_named_argument(&mut self) -> bool {
|
||||
let offset = match self.token {
|
||||
token::BinOp(token::And) |
|
||||
token::AndAnd |
|
||||
token::AndAnd => 1,
|
||||
_ if self.token.is_keyword(keywords::Mut) => 1,
|
||||
_ => 0
|
||||
};
|
||||
@ -2569,7 +2569,7 @@ impl<'a> Parser<'a> {
|
||||
s.print_usize(float.trunc() as usize)?;
|
||||
s.pclose()?;
|
||||
word(&mut s.s, ".")?;
|
||||
word(&mut s.s, fstr.splitn(2, '.').last().unwrap())
|
||||
word(&mut s.s, fstr.splitn(2, ".").last().unwrap())
|
||||
});
|
||||
err.span_suggestion(
|
||||
lo.to(self.prev_span),
|
||||
@ -4917,7 +4917,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let ast::ImplPolarity::Negative = polarity {
|
||||
if polarity == ast::ImplPolarity::Negative {
|
||||
// This is a negated type implementation
|
||||
// `impl !MyType {}`, which is not allowed.
|
||||
self.span_err(neg_span, "inherent implementation can't be negated");
|
||||
|
@ -1327,7 +1327,7 @@ impl<'a> State<'a> {
|
||||
space(&mut self.s)?;
|
||||
}
|
||||
|
||||
if let ast::ImplPolarity::Negative = polarity {
|
||||
if polarity == ast::ImplPolarity::Negative {
|
||||
word(&mut self.s, "!")?;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user