Auto merge of #36354 - mikhail-m1:master, r=jonathandturner

fix span for errors E0537, E0535 & E0536

fix #36182 as part of #35233
This commit is contained in:
bors 2016-09-12 14:05:41 -07:00 committed by GitHub
commit 5531c314a2
7 changed files with 29 additions and 5 deletions

View File

@ -125,7 +125,7 @@ impl<'a> Parser<'a> {
self.expect(&token::OpenDelim(token::Bracket))?;
let meta_item = self.parse_meta_item()?;
let hi = self.span.hi;
let hi = self.last_span.hi;
self.expect(&token::CloseDelim(token::Bracket))?;
(mk_sp(lo, hi), meta_item, style)
@ -231,12 +231,12 @@ impl<'a> Parser<'a> {
token::Eq => {
self.bump();
let lit = self.parse_unsuffixed_lit()?;
let hi = self.span.hi;
let hi = self.last_span.hi;
Ok(P(spanned(lo, hi, ast::MetaItemKind::NameValue(name, lit))))
}
token::OpenDelim(token::Paren) => {
let inner_items = self.parse_meta_seq()?;
let hi = self.span.hi;
let hi = self.last_span.hi;
Ok(P(spanned(lo, hi, ast::MetaItemKind::List(name, inner_items))))
}
_ => {
@ -253,14 +253,14 @@ impl<'a> Parser<'a> {
match self.parse_unsuffixed_lit() {
Ok(lit) => {
return Ok(spanned(lo, self.span.hi, ast::NestedMetaItemKind::Literal(lit)))
return Ok(spanned(lo, self.last_span.hi, ast::NestedMetaItemKind::Literal(lit)))
}
Err(ref mut err) => self.diagnostic().cancel(err)
}
match self.parse_meta_item() {
Ok(mi) => {
return Ok(spanned(lo, self.span.hi, ast::NestedMetaItemKind::MetaItem(mi)))
return Ok(spanned(lo, self.last_span.hi, ast::NestedMetaItemKind::MetaItem(mi)))
}
Err(ref mut err) => self.diagnostic().cancel(err)
}

View File

@ -0,0 +1,8 @@
error[E0535]: invalid argument
--> $DIR/E0535.rs:11:10
|
11 | #[inline(unknown)] //~ ERROR E0535
| ^^^^^^^
error: aborting due to previous error

View File

@ -0,0 +1,8 @@
error[E0536]: expected 1 cfg-pattern
--> $DIR/E0536.rs:11:7
|
11 | #[cfg(not())] //~ ERROR E0536
| ^^^^^
error: aborting due to previous error

View File

@ -0,0 +1,8 @@
error[E0537]: invalid predicate `unknown`
--> $DIR/E0537.rs:11:7
|
11 | #[cfg(unknown())] //~ ERROR E0537
| ^^^^^^^^^
error: aborting due to previous error