extract error_unexpected_after_dot and de-fatalize
This commit is contained in:
parent
ff5762b78a
commit
9c6bbf1252
7 changed files with 40 additions and 27 deletions
|
@ -715,11 +715,7 @@ impl<'a> Parser<'a> {
|
||||||
err?
|
err?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => self.error_unexpected_after_dot(),
|
||||||
// FIXME Could factor this out into non_fatal_unexpected or something.
|
|
||||||
let actual = self.this_token_to_string();
|
|
||||||
self.span_err(self.token.span, &format!("unexpected token: `{}`", actual));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -735,6 +731,12 @@ impl<'a> Parser<'a> {
|
||||||
return Ok(e);
|
return Ok(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn error_unexpected_after_dot(&self) {
|
||||||
|
// FIXME Could factor this out into non_fatal_unexpected or something.
|
||||||
|
let actual = self.this_token_to_string();
|
||||||
|
self.struct_span_err(self.token.span, &format!("unexpected token: `{}`", actual)).emit();
|
||||||
|
}
|
||||||
|
|
||||||
fn recover_field_access_by_float_lit(
|
fn recover_field_access_by_float_lit(
|
||||||
&mut self,
|
&mut self,
|
||||||
lo: Span,
|
lo: Span,
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
|
|
||||||
//~^ ERROR unexpected token: `#`
|
|
|
@ -1,8 +0,0 @@
|
||||||
error: unexpected token: `#`
|
|
||||||
--> $DIR/attr-stmt-expr-attr-bad-2.rs:1:34
|
|
||||||
|
|
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
|
|
||||||
| ^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
|
|
||||||
//~^ ERROR unexpected token: `#`
|
|
|
@ -1,8 +0,0 @@
|
||||||
error: unexpected token: `#`
|
|
||||||
--> $DIR/attr-stmt-expr-attr-bad-3.rs:1:34
|
|
||||||
|
|
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
|
|
||||||
| ^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
|
@ -101,6 +101,13 @@ fn main() {}
|
||||||
//~^ ERROR `X..=` range patterns are not supported
|
//~^ ERROR `X..=` range patterns are not supported
|
||||||
//~| ERROR expected one of `=>`, `if`, or `|`, found `#`
|
//~| ERROR expected one of `=>`, `if`, or `|`, found `#`
|
||||||
|
|
||||||
|
#[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
|
||||||
|
//~^ ERROR unexpected token: `#`
|
||||||
|
//~| ERROR expected one of `.`
|
||||||
|
#[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
|
||||||
|
//~^ ERROR unexpected token: `#`
|
||||||
|
//~| ERROR expected one of `.`
|
||||||
|
|
||||||
// make sure we don't catch this bug again...
|
// make sure we don't catch this bug again...
|
||||||
#[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } }
|
#[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } }
|
||||||
//~^ ERROR expected statement after outer attribute
|
//~^ ERROR expected statement after outer attribute
|
||||||
|
|
|
@ -380,11 +380,35 @@ error: expected one of `=>`, `if`, or `|`, found `#`
|
||||||
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
|
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
|
||||||
| ^ expected one of `=>`, `if`, or `|`
|
| ^ expected one of `=>`, `if`, or `|`
|
||||||
|
|
||||||
|
error: unexpected token: `#`
|
||||||
|
--> $DIR/attr-stmt-expr-attr-bad.rs:104:34
|
||||||
|
|
|
||||||
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: expected one of `.`, `;`, `?`, or an operator, found `#`
|
||||||
|
--> $DIR/attr-stmt-expr-attr-bad.rs:104:34
|
||||||
|
|
|
||||||
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
|
||||||
|
| ^ expected one of `.`, `;`, `?`, or an operator
|
||||||
|
|
||||||
|
error: unexpected token: `#`
|
||||||
|
--> $DIR/attr-stmt-expr-attr-bad.rs:106:34
|
||||||
|
|
|
||||||
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: expected one of `.`, `;`, `?`, or an operator, found `#`
|
||||||
|
--> $DIR/attr-stmt-expr-attr-bad.rs:106:34
|
||||||
|
|
|
||||||
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
|
||||||
|
| ^ expected one of `.`, `;`, `?`, or an operator
|
||||||
|
|
||||||
error: expected statement after outer attribute
|
error: expected statement after outer attribute
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:105:44
|
--> $DIR/attr-stmt-expr-attr-bad.rs:110:44
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } }
|
LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } }
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: aborting due to 52 previous errors
|
error: aborting due to 56 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue