}
token::Literal(token::Float(n), _suf) => {
self.bump();
- let prev_span = self.prev_span;
let fstr = n.as_str();
- let mut err = self.diagnostic().struct_span_err(prev_span,
+ let mut err = self.diagnostic().struct_span_err(self.prev_span,
&format!("unexpected token: `{}`", n));
+ err.span_label(self.prev_span, &"unexpected token");
if fstr.chars().all(|x| "0123456789.".contains(x)) {
let float = match fstr.parse::<f64>().ok() {
Some(f) => f,
word(&mut s.s, fstr.splitn(2, ".").last().unwrap())
});
err.span_suggestion(
- prev_span,
+ lo.to(self.prev_span),
"try parenthesizing the first index",
sugg);
}
}).emit();
}
- // Parse bounds of a type parameter `BOUND + BOUND + BOUND` without trailing `+`.
+ // Parse bounds of a type parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
// BOUND = TY_BOUND | LT_BOUND
// LT_BOUND = LIFETIME (e.g. `'a`)
// TY_BOUND = [?] [for<LT_PARAM_DEFS>] SIMPLE_PATH (e.g. `?for<'a: 'b> m::Trait<'a>`)
self.parse_ty_param_bounds_common(true)
}
- // Parse bounds of a type parameter `BOUND + BOUND + BOUND` without trailing `+`.
+ // Parse bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
// BOUND = LT_BOUND (e.g. `'a`)
fn parse_lt_param_bounds(&mut self) -> Vec<Lifetime> {
let mut lifetimes = Vec::new();
/// and `pub(super)` for `pub(in super)`. If the following element can't be a tuple (i.e. it's
/// a function definition, it's not a tuple struct field) and the contents within the parens
/// isn't valid, emit a proper diagnostic.
- fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
+ pub fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
+ maybe_whole!(self, NtVis, |x| x);
+
if !self.eat_keyword(keywords::Pub) {
return Ok(Visibility::Inherited)
}