mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 01:23:26 +00:00
Rollup merge of #123431 - slanterns:literal_byte_character_c_string_stabilize, r=dtolnay
Stabilize `proc_macro_byte_character` and `proc_macro_c_str_literals` This PR stabilizes `proc_macro_byte_character` and `proc_macro_c_str_literals`: ```rust // proc_macro::Literal impl Literal { pub fn byte_character(byte: u8) -> Literal; pub fn c_string(string: &CStr) -> Literal } ``` <br> Tracking issue: https://github.com/rust-lang/rust/issues/115268, https://github.com/rust-lang/rust/issues/119750. Implementation PR: https://github.com/rust-lang/rust/pull/112711, https://github.com/rust-lang/rust/pull/119651. FCPs already completed in their respective tracking issues. Closes https://github.com/rust-lang/rust/issues/115268. Closes https://github.com/rust-lang/rust/issues/119750. r? libs-api
This commit is contained in:
commit
ad300b6738
@ -1360,7 +1360,7 @@ impl Literal {
|
||||
}
|
||||
|
||||
/// Byte character literal.
|
||||
#[unstable(feature = "proc_macro_byte_character", issue = "115268")]
|
||||
#[stable(feature = "proc_macro_byte_character", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub fn byte_character(byte: u8) -> Literal {
|
||||
let string = [byte].escape_ascii().to_string();
|
||||
Literal::new(bridge::LitKind::Byte, &string, None)
|
||||
@ -1374,7 +1374,7 @@ impl Literal {
|
||||
}
|
||||
|
||||
/// C string literal.
|
||||
#[unstable(feature = "proc_macro_c_str_literals", issue = "119750")]
|
||||
#[stable(feature = "proc_macro_c_str_literals", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub fn c_string(string: &CStr) -> Literal {
|
||||
let string = string.to_bytes().escape_ascii().to_string();
|
||||
Literal::new(bridge::LitKind::CStr, &string, None)
|
||||
|
@ -1,10 +0,0 @@
|
||||
//@ force-host
|
||||
#![crate_type = "proc-macro"]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::Literal;
|
||||
|
||||
fn test() {
|
||||
Literal::byte_character(b'a'); //~ ERROR use of unstable library feature 'proc_macro_byte_character'
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
error[E0658]: use of unstable library feature 'proc_macro_byte_character'
|
||||
--> $DIR/feature-gate-proc_macro_byte_character.rs:9:5
|
||||
|
|
||||
LL | Literal::byte_character(b'a');
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #115268 <https://github.com/rust-lang/rust/issues/115268> for more information
|
||||
= help: add `#![feature(proc_macro_byte_character)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -1,11 +0,0 @@
|
||||
//@ edition: 2021
|
||||
//@ force-host
|
||||
#![crate_type = "proc-macro"]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::Literal;
|
||||
|
||||
fn test() {
|
||||
Literal::c_string(c"a"); //~ ERROR use of unstable library feature 'proc_macro_c_str_literals'
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
error[E0658]: use of unstable library feature 'proc_macro_c_str_literals'
|
||||
--> $DIR/feature-gate-proc_macro_c_str_literals.rs:10:5
|
||||
|
|
||||
LL | Literal::c_string(c"a");
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #119750 <https://github.com/rust-lang/rust/issues/119750> for more information
|
||||
= help: add `#![feature(proc_macro_c_str_literals)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -5,8 +5,6 @@
|
||||
#![crate_type = "proc-macro"]
|
||||
#![crate_name = "proc_macro_api_tests"]
|
||||
#![feature(proc_macro_span)]
|
||||
#![feature(proc_macro_byte_character)]
|
||||
#![feature(proc_macro_c_str_literals)]
|
||||
#![deny(dead_code)] // catch if a test function is never called
|
||||
|
||||
extern crate proc_macro;
|
||||
|
Loading…
Reference in New Issue
Block a user