std: Stabilize FromStr and parse
This commits adds an associated type to the `FromStr` trait representing an error payload for parses which do not succeed. The previous return value, `Option<Self>` did not allow for this form of payload. After the associated type was added, the following attributes were applied: * `FromStr` is now stable * `FromStr::Err` is now stable * `FromStr::from_str` is now stable * `StrExt::parse` is now stable * `FromStr for bool` is now stable * `FromStr for $float` is now stable * `FromStr for $integral` is now stable * Errors returned from stable `FromStr` implementations are stable * Errors implement `Display` and `Error` (both impl blocks being `#[stable]`) Closes #15138
This commit is contained in:
@@ -613,7 +613,7 @@ impl<'a> StringReader<'a> {
|
||||
// find the integer representing the name
|
||||
self.scan_digits(base);
|
||||
let encoded_name : u32 = self.with_str_from(start_bpos, |s| {
|
||||
num::from_str_radix(s, 10).unwrap_or_else(|| {
|
||||
num::from_str_radix(s, 10).ok().unwrap_or_else(|| {
|
||||
panic!("expected digits representing a name, got {:?}, {}, range [{:?},{:?}]",
|
||||
s, whence, start_bpos, self.last_pos);
|
||||
})
|
||||
@@ -631,7 +631,7 @@ impl<'a> StringReader<'a> {
|
||||
let start_bpos = self.last_pos;
|
||||
self.scan_digits(base);
|
||||
let encoded_ctxt : ast::SyntaxContext = self.with_str_from(start_bpos, |s| {
|
||||
num::from_str_radix(s, 10).unwrap_or_else(|| {
|
||||
num::from_str_radix(s, 10).ok().unwrap_or_else(|| {
|
||||
panic!("expected digits representing a ctxt, got {:?}, {}", s, whence);
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user