-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
TokenStream::from_str is supposed to return Result<proc_macro::TokenStream, proc_macro::LexError>. Currently it appears to print errors to stderr and then panic, rather than returning errors.
Cargo.toml
[package]
name = "repro"
version = "0.0.0"
edition = "2018"
[lib]
proc-macro = truesrc/lib.rs
extern crate proc_macro;
use proc_macro::TokenStream;
use std::str::FromStr;
#[proc_macro_derive(ParseTokenStream)]
pub fn derive(_input: TokenStream) -> TokenStream {
let _ = TokenStream::from_str("\\s");
TokenStream::new()
}src/main.rs
#[derive(repro::ParseTokenStream)]
struct S;
fn main() {}Output of cargo check:
$ cargo check
error: unknown start of token: \
--> src/main.rs:1:10
|
1 | #[derive(repro::ParseTokenStream)]
| ^^^^^^^^^^^^^^^^^^^^^^^
error: proc-macro derive panicked
--> src/main.rs:1:10
|
1 | #[derive(repro::ParseTokenStream)]
| ^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errorsMentioning @eddyb, @petrochenkov, @alexcrichton.
Mentioning @canndrew who reported this in dtolnay/proc-macro2#168.
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.