diff --git a/Cargo.lock b/Cargo.lock index 63a3f5dd03773..e91116ade9edd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2082,13 +2082,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" -[[package]] -name = "literal-escaper" -version = "0.0.0" -dependencies = [ - "rustc-std-workspace-std 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "lld-wrapper" version = "0.1.0" @@ -3155,12 +3148,6 @@ version = "1.0.1" name = "rustc-std-workspace-std" version = "1.0.1" -[[package]] -name = "rustc-std-workspace-std" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aba676a20abe46e5b0f1b0deae474aaaf31407e6c71147159890574599da04ef" - [[package]] name = "rustc_abi" version = "0.0.0" @@ -3199,7 +3186,6 @@ name = "rustc_ast" version = "0.0.0" dependencies = [ "bitflags", - "literal-escaper", "memchr", "rustc_ast_ir", "rustc_data_structures", @@ -3909,7 +3895,6 @@ name = "rustc_lexer" version = "0.0.0" dependencies = [ "expect-test", - "literal-escaper", "memchr", "unicode-properties", "unicode-xid", @@ -4172,7 +4157,6 @@ name = "rustc_parse" version = "0.0.0" dependencies = [ "bitflags", - "literal-escaper", "rustc_ast", "rustc_ast_pretty", "rustc_data_structures", @@ -4195,7 +4179,6 @@ dependencies = [ name = "rustc_parse_format" version = "0.0.0" dependencies = [ - "literal-escaper", "rustc_index", "rustc_lexer", ] diff --git a/compiler/rustc_ast/Cargo.toml b/compiler/rustc_ast/Cargo.toml index 7f0db1560c1ba..902287d032802 100644 --- a/compiler/rustc_ast/Cargo.toml +++ b/compiler/rustc_ast/Cargo.toml @@ -6,7 +6,6 @@ edition = "2024" [dependencies] # tidy-alphabetical-start bitflags = "2.4.1" -literal-escaper = { path = "../../library/literal-escaper" } memchr = "2.7.4" rustc_ast_ir = { path = "../rustc_ast_ir" } rustc_data_structures = { path = "../rustc_data_structures" } diff --git a/compiler/rustc_ast/src/util/literal.rs b/compiler/rustc_ast/src/util/literal.rs index 121331ece6d64..6896ac723fa58 100644 --- a/compiler/rustc_ast/src/util/literal.rs +++ b/compiler/rustc_ast/src/util/literal.rs @@ -2,7 +2,7 @@ use std::{ascii, fmt, str}; -use literal_escaper::{ +use rustc_lexer::unescape::{ MixedUnit, Mode, byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode, }; use rustc_span::{Span, Symbol, kw, sym}; diff --git a/compiler/rustc_lexer/Cargo.toml b/compiler/rustc_lexer/Cargo.toml index c72425fd92dba..448a50faf458e 100644 --- a/compiler/rustc_lexer/Cargo.toml +++ b/compiler/rustc_lexer/Cargo.toml @@ -16,7 +16,6 @@ Rust lexer used by rustc. No stability guarantees are provided. [dependencies] memchr = "2.7.4" unicode-xid = "0.2.0" -literal-escaper = { path = "../../library/literal-escaper" } [dependencies.unicode-properties] version = "0.1.0" diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index c45dd33982b72..61638e45253fd 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -26,13 +26,11 @@ // tidy-alphabetical-end mod cursor; +pub mod unescape; #[cfg(test)] mod tests; -// FIXME: This is needed for rust-analyzer. Remove this dependency once rust-analyzer uses -// `literal-escaper`. -pub use literal_escaper as unescape; use unicode_properties::UnicodeEmoji; pub use unicode_xid::UNICODE_VERSION as UNICODE_XID_VERSION; diff --git a/library/literal-escaper/src/lib.rs b/compiler/rustc_lexer/src/unescape.rs similarity index 100% rename from library/literal-escaper/src/lib.rs rename to compiler/rustc_lexer/src/unescape.rs diff --git a/library/literal-escaper/src/tests.rs b/compiler/rustc_lexer/src/unescape/tests.rs similarity index 100% rename from library/literal-escaper/src/tests.rs rename to compiler/rustc_lexer/src/unescape/tests.rs diff --git a/compiler/rustc_parse/Cargo.toml b/compiler/rustc_parse/Cargo.toml index e83f2d5a56d60..c9dcab0c871dd 100644 --- a/compiler/rustc_parse/Cargo.toml +++ b/compiler/rustc_parse/Cargo.toml @@ -6,7 +6,6 @@ edition = "2024" [dependencies] # tidy-alphabetical-start bitflags = "2.4.1" -literal-escaper = { path = "../../library/literal-escaper" } rustc_ast = { path = "../rustc_ast" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_data_structures = { path = "../rustc_data_structures" } diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 4a3fda86c86c0..1d17290e1c706 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -1,12 +1,12 @@ use std::ops::Range; -use literal_escaper::{self, EscapeError, Mode}; use rustc_ast::ast::{self, AttrStyle}; use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Token, TokenKind}; use rustc_ast::tokenstream::TokenStream; use rustc_ast::util::unicode::contains_text_flow_control_chars; use rustc_errors::codes::*; use rustc_errors::{Applicability, Diag, DiagCtxtHandle, StashKey}; +use rustc_lexer::unescape::{self, EscapeError, Mode}; use rustc_lexer::{Base, Cursor, DocStyle, LiteralKind, RawStrError}; use rustc_session::lint::BuiltinLintDiag; use rustc_session::lint::builtin::{ @@ -970,7 +970,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> { postfix_len: u32, ) -> (token::LitKind, Symbol) { self.cook_common(kind, mode, start, end, prefix_len, postfix_len, |src, mode, callback| { - literal_escaper::unescape_unicode(src, mode, &mut |span, result| { + unescape::unescape_unicode(src, mode, &mut |span, result| { callback(span, result.map(drop)) }) }) @@ -986,7 +986,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> { postfix_len: u32, ) -> (token::LitKind, Symbol) { self.cook_common(kind, mode, start, end, prefix_len, postfix_len, |src, mode, callback| { - literal_escaper::unescape_mixed(src, mode, &mut |span, result| { + unescape::unescape_mixed(src, mode, &mut |span, result| { callback(span, result.map(drop)) }) }) diff --git a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs index e8aa400e73d44..2e066f0179c3f 100644 --- a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs +++ b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs @@ -3,8 +3,8 @@ use std::iter::once; use std::ops::Range; -use literal_escaper::{EscapeError, Mode}; use rustc_errors::{Applicability, DiagCtxtHandle, ErrorGuaranteed}; +use rustc_lexer::unescape::{EscapeError, Mode}; use rustc_span::{BytePos, Span}; use tracing::debug; diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 85d94400b1c6f..0774324eae742 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -6,7 +6,6 @@ use core::ops::{Bound, ControlFlow}; use ast::mut_visit::{self, MutVisitor}; use ast::token::{IdentIsRaw, MetaVarKind}; use ast::{CoroutineKind, ForLoopKind, GenBlockKind, MatchKind, Pat, Path, PathSegment, Recovered}; -use literal_escaper::unescape_char; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token, TokenKind}; use rustc_ast::tokenstream::TokenTree; @@ -22,6 +21,7 @@ use rustc_ast::{ use rustc_ast_pretty::pprust; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::{Applicability, Diag, PResult, StashKey, Subdiagnostic}; +use rustc_lexer::unescape::unescape_char; use rustc_macros::Subdiagnostic; use rustc_session::errors::{ExprParenthesesNeeded, report_lit_error}; use rustc_session::lint::BuiltinLintDiag; diff --git a/compiler/rustc_parse_format/Cargo.toml b/compiler/rustc_parse_format/Cargo.toml index e63ed9e16f2e8..a39cca716d23e 100644 --- a/compiler/rustc_parse_format/Cargo.toml +++ b/compiler/rustc_parse_format/Cargo.toml @@ -5,7 +5,6 @@ edition = "2024" [dependencies] # tidy-alphabetical-start -literal-escaper = { path = "../../library/literal-escaper" } rustc_index = { path = "../rustc_index", default-features = false } rustc_lexer = { path = "../rustc_lexer" } # tidy-alphabetical-end diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index 5780daf303437..5b8a2fe52d3f5 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -18,6 +18,7 @@ pub use Alignment::*; pub use Count::*; pub use Position::*; +use rustc_lexer::unescape; // Note: copied from rustc_span /// Range inside of a `Span` used for diagnostics when we only have access to relative positions. @@ -1093,14 +1094,12 @@ fn find_width_map_from_snippet( fn unescape_string(string: &str) -> Option { let mut buf = String::new(); let mut ok = true; - literal_escaper::unescape_unicode( - string, - literal_escaper::Mode::Str, - &mut |_, unescaped_char| match unescaped_char { + unescape::unescape_unicode(string, unescape::Mode::Str, &mut |_, unescaped_char| { + match unescaped_char { Ok(c) => buf.push(c), Err(_) => ok = false, - }, - ); + } + }); ok.then_some(buf) } diff --git a/library/Cargo.lock b/library/Cargo.lock index d9a24f7cd242b..ac8740605144a 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -165,13 +165,6 @@ dependencies = [ "rustc-std-workspace-core", ] -[[package]] -name = "literal-escaper" -version = "0.0.0" -dependencies = [ - "rustc-std-workspace-std", -] - [[package]] name = "memchr" version = "2.7.4" @@ -243,7 +236,6 @@ name = "proc_macro" version = "0.0.0" dependencies = [ "core", - "literal-escaper", "std", ] diff --git a/library/Cargo.toml b/library/Cargo.toml index 5445fd61afa0c..4d5955593ffcd 100644 --- a/library/Cargo.toml +++ b/library/Cargo.toml @@ -8,7 +8,6 @@ members = [ ] exclude = [ - "literal-escaper", # stdarch has its own Cargo workspace "stdarch", "windows_targets" diff --git a/library/literal-escaper/Cargo.toml b/library/literal-escaper/Cargo.toml deleted file mode 100644 index 708fcd3cacb69..0000000000000 --- a/library/literal-escaper/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "literal-escaper" -version = "0.0.0" -edition = "2021" - -[dependencies] -std = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-std' } - -[features] -rustc-dep-of-std = ["dep:std"] diff --git a/library/literal-escaper/README.md b/library/literal-escaper/README.md deleted file mode 100644 index 9986d2451c759..0000000000000 --- a/library/literal-escaper/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# literal-escaper - -This crate provides code to unescape string literals. It is used by `rustc_lexer` -and `proc_macro`. diff --git a/library/proc_macro/Cargo.toml b/library/proc_macro/Cargo.toml index f2ac530dfd2b0..72cb4e4166f8e 100644 --- a/library/proc_macro/Cargo.toml +++ b/library/proc_macro/Cargo.toml @@ -4,7 +4,6 @@ version = "0.0.0" edition = "2024" [dependencies] -literal-escaper = { path = "../literal-escaper", features = ["rustc-dep-of-std"] } std = { path = "../std" } # Workaround: when documenting this crate rustdoc will try to load crate named # `core` when resolving doc links. Without this line a different `core` will be diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index bd08d59daa866..d9141eab5919f 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -28,7 +28,6 @@ #![feature(restricted_std)] #![feature(rustc_attrs)] #![feature(extend_one)] -#![feature(stmt_expr_attributes)] #![recursion_limit = "256"] #![allow(internal_features)] #![deny(ffi_unwind_calls)] @@ -52,24 +51,11 @@ use std::{error, fmt}; #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub use diagnostic::{Diagnostic, Level, MultiSpan}; -#[unstable(feature = "proc_macro_value", issue = "136652")] -pub use literal_escaper::EscapeError; -use literal_escaper::{MixedUnit, Mode, byte_from_char, unescape_mixed, unescape_unicode}; #[unstable(feature = "proc_macro_totokens", issue = "130977")] pub use to_tokens::ToTokens; use crate::escape::{EscapeOptions, escape_bytes}; -/// Errors returned when trying to retrieve a literal unescaped value. -#[unstable(feature = "proc_macro_value", issue = "136652")] -#[derive(Debug, PartialEq, Eq)] -pub enum ConversionErrorKind { - /// The literal failed to be escaped, take a look at [`EscapeError`] for more information. - FailedToUnescape(EscapeError), - /// Trying to convert a literal with the wrong type. - InvalidLiteralKind, -} - /// Determines whether proc_macro has been made accessible to the currently /// running program. /// @@ -1465,107 +1451,6 @@ impl Literal { } }) } - - /// Returns the unescaped string value if the current literal is a string or a string literal. - #[unstable(feature = "proc_macro_value", issue = "136652")] - pub fn str_value(&self) -> Result { - self.0.symbol.with(|symbol| match self.0.kind { - bridge::LitKind::Str => { - if symbol.contains('\\') { - let mut buf = String::with_capacity(symbol.len()); - let mut error = None; - // Force-inlining here is aggressive but the closure is - // called on every char in the string, so it can be hot in - // programs with many long strings containing escapes. - unescape_unicode( - symbol, - Mode::Str, - &mut #[inline(always)] - |_, c| match c { - Ok(c) => buf.push(c), - Err(err) => { - if err.is_fatal() { - error = Some(ConversionErrorKind::FailedToUnescape(err)); - } - } - }, - ); - if let Some(error) = error { Err(error) } else { Ok(buf) } - } else { - Ok(symbol.to_string()) - } - } - bridge::LitKind::StrRaw(_) => Ok(symbol.to_string()), - _ => Err(ConversionErrorKind::InvalidLiteralKind), - }) - } - - /// Returns the unescaped string value if the current literal is a c-string or a c-string - /// literal. - #[unstable(feature = "proc_macro_value", issue = "136652")] - pub fn cstr_value(&self) -> Result, ConversionErrorKind> { - self.0.symbol.with(|symbol| match self.0.kind { - bridge::LitKind::CStr => { - let mut error = None; - let mut buf = Vec::with_capacity(symbol.len()); - - unescape_mixed(symbol, Mode::CStr, &mut |_span, c| match c { - Ok(MixedUnit::Char(c)) => { - buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes()) - } - Ok(MixedUnit::HighByte(b)) => buf.push(b), - Err(err) => { - if err.is_fatal() { - error = Some(ConversionErrorKind::FailedToUnescape(err)); - } - } - }); - if let Some(error) = error { - Err(error) - } else { - buf.push(0); - Ok(buf) - } - } - bridge::LitKind::CStrRaw(_) => { - // Raw strings have no escapes so we can convert the symbol - // directly to a `Lrc` after appending the terminating NUL - // char. - let mut buf = symbol.to_owned().into_bytes(); - buf.push(0); - Ok(buf) - } - _ => Err(ConversionErrorKind::InvalidLiteralKind), - }) - } - - /// Returns the unescaped string value if the current literal is a byte string or a byte string - /// literal. - #[unstable(feature = "proc_macro_value", issue = "136652")] - pub fn byte_str_value(&self) -> Result, ConversionErrorKind> { - self.0.symbol.with(|symbol| match self.0.kind { - bridge::LitKind::ByteStr => { - let mut buf = Vec::with_capacity(symbol.len()); - let mut error = None; - - unescape_unicode(symbol, Mode::ByteStr, &mut |_, c| match c { - Ok(c) => buf.push(byte_from_char(c)), - Err(err) => { - if err.is_fatal() { - error = Some(ConversionErrorKind::FailedToUnescape(err)); - } - } - }); - if let Some(error) = error { Err(error) } else { Ok(buf) } - } - bridge::LitKind::ByteStrRaw(_) => { - // Raw strings have no escapes so we can convert the symbol - // directly to a `Lrc`. - Ok(symbol.to_owned().into_bytes()) - } - _ => Err(ConversionErrorKind::InvalidLiteralKind), - }) - } } /// Parse a single literal from its stringified representation. diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 343fbcc0286de..b062781e68a71 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -655,7 +655,7 @@ mod dist { let mut builder = Builder::new(&build); builder.run_step_descriptions( &Builder::get_step_descriptions(Kind::Build), - &["compiler/rustc".into(), "std".into()], + &["compiler/rustc".into(), "library".into()], ); assert_eq!(builder.config.stage, 2); diff --git a/src/bootstrap/src/core/metadata.rs b/src/bootstrap/src/core/metadata.rs index 3720602dc7749..2706aba5ffc8d 100644 --- a/src/bootstrap/src/core/metadata.rs +++ b/src/bootstrap/src/core/metadata.rs @@ -62,11 +62,6 @@ pub fn build(build: &mut Build) { let relative_path = krate.local_path(build); build.crates.insert(name.clone(), krate); let existing_path = build.crate_paths.insert(relative_path, name); - // `literal-escaper` is both a dependency of `compiler/rustc_lexer` and of - // `library/proc-macro`, making it appear multiple times in the workspace. - if existing_path.as_deref() == Some("literal-escaper") { - continue; - } assert!( existing_path.is_none(), "multiple crates with the same path: {}", diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 1943d0299b9e7..1fba17dcf3087 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -716,7 +716,7 @@ impl Build { features.push("llvm"); } // keep in sync with `bootstrap/compile.rs:rustc_cargo_env` - if self.config.rust_randomize_layout && check("rustc_randomized_layouts") { + if self.config.rust_randomize_layout { features.push("rustc_randomized_layouts"); } diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 8a95c6dd5e626..81c55ecaa7a29 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -318,7 +318,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "libloading", "linux-raw-sys", "litemap", - "literal-escaper", "lock_api", "log", "matchers", @@ -364,7 +363,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "rustc-rayon", "rustc-rayon-core", "rustc-stable-hash", - "rustc-std-workspace-std", "rustc_apfloat", "rustix", "ruzstd", // via object in thorin-dwp diff --git a/tests/ui/feature-gates/literal-escaper.rs b/tests/ui/feature-gates/literal-escaper.rs deleted file mode 100644 index 7c145fca7dec2..0000000000000 --- a/tests/ui/feature-gates/literal-escaper.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![crate_type = "lib"] - -extern crate literal_escaper; //~ ERROR diff --git a/tests/ui/feature-gates/literal-escaper.stderr b/tests/ui/feature-gates/literal-escaper.stderr deleted file mode 100644 index edddb6504f575..0000000000000 --- a/tests/ui/feature-gates/literal-escaper.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: use of unstable library feature `rustc_private`: this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? - --> $DIR/literal-escaper.rs:3:1 - | -LL | extern crate literal_escaper; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #27812 for more information - = help: add `#![feature(rustc_private)]` 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`. diff --git a/tests/ui/proc-macro/auxiliary/api/literal.rs b/tests/ui/proc-macro/auxiliary/api/literal.rs index 941de1521ade9..7109340bb645b 100644 --- a/tests/ui/proc-macro/auxiliary/api/literal.rs +++ b/tests/ui/proc-macro/auxiliary/api/literal.rs @@ -1,11 +1,10 @@ // ignore-tidy-linelength -use proc_macro::{ConversionErrorKind, Literal}; +use proc_macro::Literal; pub fn test() { test_display_literal(); test_parse_literal(); - test_str_value_methods(); } fn test_display_literal() { @@ -82,53 +81,3 @@ fn test_parse_literal() { assert!("- 10".parse::().is_err()); assert!("-'x'".parse::().is_err()); } - -fn test_str_value_methods() { - // Testing `str_value` - let lit = "\"\n\"".parse::().unwrap(); - assert_eq!(lit.str_value(), Ok("\n".to_string())); - - let lit = "r#\"\n\"#".parse::().unwrap(); - assert_eq!(lit.str_value(), Ok("\n".to_string())); - - let lit = "1".parse::().unwrap(); - assert_eq!(lit.str_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - let lit = "b\"\n\"".parse::().unwrap(); - assert_eq!(lit.str_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - let lit = "c\"\n\"".parse::().unwrap(); - assert_eq!(lit.str_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - // Testing `cstr_value` - let lit = "\"\n\"".parse::().unwrap(); - assert_eq!(lit.cstr_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - let lit = "r#\"\n\"#".parse::().unwrap(); - assert_eq!(lit.cstr_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - let lit = "1".parse::().unwrap(); - assert_eq!(lit.cstr_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - let lit = "b\"\n\"".parse::().unwrap(); - assert_eq!(lit.cstr_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - let lit = "c\"\n\"".parse::().unwrap(); - assert_eq!(lit.cstr_value(), Ok(vec![b'\n', 0])); - - // Testing `byte_str_value` - let lit = "\"\n\"".parse::().unwrap(); - assert_eq!(lit.byte_str_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - let lit = "r#\"\n\"#".parse::().unwrap(); - assert_eq!(lit.byte_str_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - let lit = "1".parse::().unwrap(); - assert_eq!(lit.byte_str_value(), Err(ConversionErrorKind::InvalidLiteralKind)); - - let lit = "b\"\n\"".parse::().unwrap(); - assert_eq!(lit.byte_str_value(), Ok(vec![b'\n'])); - - let lit = "c\"\n\"".parse::().unwrap(); - assert_eq!(lit.byte_str_value(), Err(ConversionErrorKind::InvalidLiteralKind)); -} diff --git a/tests/ui/proc-macro/auxiliary/api/proc_macro_api_tests.rs b/tests/ui/proc-macro/auxiliary/api/proc_macro_api_tests.rs index 390d46852cd54..abd667d8ce1d0 100644 --- a/tests/ui/proc-macro/auxiliary/api/proc_macro_api_tests.rs +++ b/tests/ui/proc-macro/auxiliary/api/proc_macro_api_tests.rs @@ -1,7 +1,6 @@ //@ edition: 2021 #![feature(proc_macro_span)] -#![feature(proc_macro_value)] #![deny(dead_code)] // catch if a test function is never called extern crate proc_macro;