forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: reproduce the issue with the cstr parsing inside the proc macro
While I am working on trying to patch rust-lang#112820 I think it is useful to have a test for this case as known-bug Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
- Loading branch information
1 parent
136d74f
commit 97a7ed2
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/wrong_parsing.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/ui/rfcs/rfc-3348-c-string-literals/edition-issue-112820-spans.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!(b"bytestr" c"cstr"); | ||
}; | ||
|
||
fn main() {} |
10 changes: 10 additions & 0 deletions
10
tests/ui/rfcs/rfc-3348-c-string-literals/edition-issue-112820-spans.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!(b"bytestr" c"cstr"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: message: panic on: `cstr` | ||
|
||
error: aborting due to previous error | ||
|