-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Reimplement C-str literals #113476
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Merged
Reimplement C-str literals #113476
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs
This file contains hidden or 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 @@ | ||
// force-host | ||
// edition: 2018 | ||
// no-prefer-dynamic | ||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::TokenStream; | ||
use std::str::FromStr; | ||
|
||
#[proc_macro] | ||
pub fn number_of_tokens(_: TokenStream) -> TokenStream { | ||
TokenStream::from_str("c\"\"").unwrap().into_iter().count().to_string().parse().unwrap() | ||
} |
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,16 @@ | ||
// even if this crate is edition 2021, proc macros compiled using older | ||
// editions should still be able to observe the pre-2021 token behavior | ||
// | ||
// adapted from tests/ui/rust-2021/reserved-prefixes-via-macro.rs | ||
|
||
// edition: 2021 | ||
// check-pass | ||
|
||
// aux-build: count.rs | ||
extern crate count; | ||
|
||
const _: () = { | ||
assert!(count::number_of_tokens!() == 2); | ||
}; | ||
|
||
fn main() {} |
This file contains hidden or 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 |
---|---|---|
@@ -1,32 +1,21 @@ | ||
error: prefix `c` is unknown | ||
error[E0658]: `c".."` literals are experimental | ||
--> $DIR/gate.rs:10:5 | ||
| | ||
LL | c"foo"; | ||
| ^ unknown prefix | ||
| ^^^^^^ | ||
| | ||
= note: prefixed identifiers and literals are reserved since Rust 2021 | ||
help: consider inserting whitespace here | ||
| | ||
LL | c "foo"; | ||
| + | ||
= note: see issue #105723 <https://github.com/rust-lang/rust/issues/105723> for more information | ||
= help: add `#![feature(c_str_literals)]` to the crate attributes to enable | ||
|
||
error: prefix `c` is unknown | ||
error[E0658]: `c".."` literals are experimental | ||
--> $DIR/gate.rs:13:8 | ||
| | ||
LL | m!(c"test"); | ||
| ^ unknown prefix | ||
| | ||
= note: prefixed identifiers and literals are reserved since Rust 2021 | ||
help: consider inserting whitespace here | ||
| ^^^^^^^ | ||
| | ||
LL | m!(c "test"); | ||
| + | ||
|
||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"foo"` | ||
--> $DIR/gate.rs:10:6 | ||
| | ||
LL | c"foo"; | ||
| ^^^^^ expected one of 8 possible tokens | ||
= note: see issue #105723 <https://github.com/rust-lang/rust/issues/105723> for more information | ||
= help: add `#![feature(c_str_literals)]` to the crate attributes to enable | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
Binary file not shown.
Binary file not shown.
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.