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

test: reproduce the issue with the cstr parsing inside a the proc macro #116103

Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// force-host
// no-prefer-dynamic
#![crate_type = "proc-macro"]

extern crate proc_macro;

use proc_macro::{TokenStream, TokenTree};

#[proc_macro]
pub fn repro(input: TokenStream) -> TokenStream {
for token in input {
if let TokenTree::Literal(literal) = token {
assert!(format!("{}", literal).contains(&"c\""), "panic on: `{}`", literal);
}
}
TokenStream::new()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// edition: 2021
// known-bug: #112820
//
// aux-build: count.rs
#![feature(c_str_literals)]

// aux-build: wrong_parsing.rs
extern crate wrong_parsing;

const _: () = {
wrong_parsing::repro!(c"cstr");
};

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: proc macro panicked
--> $DIR/edition-issue-112820-spans.rs:11:5
|
LL | wrong_parsing::repro!(c"cstr");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: panic on: `cstr`

error: aborting due to previous error

Loading