Rollup merge of #68899 - kinseytamsin:lexerror-error-impl, r=Centril
Add Display and Error impls for proc_macro::LexError This should allow LexError to play much nicer with the `?` operator. Fixes #68896. (I'm not sure if I did the stability attributes right, so if I need to change them, please let me know!)
This commit is contained in:
commit
703dcff081
1 changed files with 11 additions and 1 deletions
|
@ -41,7 +41,7 @@ pub use diagnostic::{Diagnostic, Level, MultiSpan};
|
||||||
use std::ops::{Bound, RangeBounds};
|
use std::ops::{Bound, RangeBounds};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::{fmt, iter, mem};
|
use std::{error, fmt, iter, mem};
|
||||||
|
|
||||||
/// The main type provided by this crate, representing an abstract stream of
|
/// The main type provided by this crate, representing an abstract stream of
|
||||||
/// tokens, or, more specifically, a sequence of token trees.
|
/// tokens, or, more specifically, a sequence of token trees.
|
||||||
|
@ -66,6 +66,16 @@ pub struct LexError {
|
||||||
_inner: (),
|
_inner: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "proc_macro_lexerror_impls", since = "1.44.0")]
|
||||||
|
impl fmt::Display for LexError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.write_str("cannot parse string into token stream")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "proc_macro_lexerror_impls", since = "1.44.0")]
|
||||||
|
impl error::Error for LexError {}
|
||||||
|
|
||||||
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
|
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
|
||||||
impl !Send for LexError {}
|
impl !Send for LexError {}
|
||||||
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
|
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue