Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify which errors are format string errors #10306

Merged
merged 1 commit into from
Nov 6, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/libstd/fmt/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl<'self> Iterator<Piece<'self>> for Parser<'self> {
}
Some((_, '}')) if self.depth == 0 => {
self.cur.next();
self.err(~"unmatched `}` found");
self.err("unmatched `}` found");
None
}
Some((_, '}')) | None => { None }
Expand All @@ -204,8 +204,8 @@ impl<'self> Parser<'self> {
/// Notifies of an error. The message doesn't actually need to be of type
/// ~str, but I think it does when this eventually uses conditions so it
/// might as well start using it now.
fn err(&self, msg: ~str) {
parse_error::cond.raise(msg);
fn err(&self, msg: &str) {
parse_error::cond.raise("invalid format string: " + msg);
}

/// Optionally consumes the specified character. If the character is not at
Expand All @@ -230,11 +230,11 @@ impl<'self> Parser<'self> {
self.cur.next();
}
Some((_, other)) => {
parse_error::cond.raise(
self.err(
format!("expected `{}` but found `{}`", c, other));
}
None => {
parse_error::cond.raise(
self.err(
format!("expected `{}` but string was terminated", c));
}
}
Expand Down Expand Up @@ -267,7 +267,7 @@ impl<'self> Parser<'self> {
c
}
None => {
self.err(~"expected an escape sequence, but format string was \
self.err("expected an escape sequence, but format string was \
terminated");
' '
}
Expand Down Expand Up @@ -411,7 +411,7 @@ impl<'self> Parser<'self> {
Some(self.plural())
}
"" => {
self.err(~"expected method after comma");
self.err("expected method after comma");
return None;
}
method => {
Expand All @@ -430,7 +430,7 @@ impl<'self> Parser<'self> {
self.ws();
let selector = self.word();
if selector == "" {
self.err(~"cannot have an empty selector");
self.err("cannot have an empty selector");
break
}
self.must_consume('{');
Expand All @@ -440,7 +440,7 @@ impl<'self> Parser<'self> {
self.must_consume('}');
if selector == "other" {
if !other.is_none() {
self.err(~"multiple `other` statements in `select");
self.err("multiple `other` statements in `select");
}
other = Some(pieces);
} else {
Expand All @@ -456,7 +456,7 @@ impl<'self> Parser<'self> {
let other = match other {
Some(arm) => { arm }
None => {
self.err(~"`select` statement must provide an `other` case");
self.err("`select` statement must provide an `other` case");
~[]
}
};
Expand Down Expand Up @@ -488,7 +488,7 @@ impl<'self> Parser<'self> {
match self.integer() {
Some(i) => { offset = Some(i); }
None => {
self.err(~"offset must be an integer");
self.err("offset must be an integer");
}
}
}
Expand All @@ -506,8 +506,8 @@ impl<'self> Parser<'self> {
match self.integer() {
Some(i) => Right(i),
None => {
self.err(~"plural `=` selectors must be followed by an \
integer");
self.err("plural `=` selectors must be followed by an \
integer");
Right(0)
}
}
Expand Down Expand Up @@ -538,7 +538,7 @@ impl<'self> Parser<'self> {
self.must_consume('}');
if isother {
if !other.is_none() {
self.err(~"multiple `other` statements in `select");
self.err("multiple `other` statements in `select");
}
other = Some(pieces);
} else {
Expand All @@ -554,7 +554,7 @@ impl<'self> Parser<'self> {
let other = match other {
Some(arm) => { arm }
None => {
self.err(~"`plural` statement must provide an `other` case");
self.err("`plural` statement must provide an `other` case");
~[]
}
};
Expand Down