Closed as not planned
Description
The prohibition of ##
in Rust 2024 breaks some proc-macros. For example, the peg
makes use of ##
for calling methods:
#![warn(rust_2024_guarded_string_incompatible_syntax)]
use peg::RuleResult;
trait StrExt {
fn ident_start(&self, pos: usize) -> RuleResult<()>;
}
impl StrExt for str {
fn ident_start(&self, pos: usize) -> RuleResult<()> {
let Some(ch) = self[pos..].chars().next() else {
return RuleResult::Failed;
};
RuleResult::Matched(pos + ch.len_utf8(), ())
}
}
peg::parser!(grammar parser() for str {
pub(crate) rule simple_literal_start()
= [ 'A'..='Z' ] / ##ident_start()
});
Here this will suggest to add a space to supposedly maintain compatibility with Rust 2024:
@@ -15,5 +15,5 @@
peg::parser!(grammar parser() for str {
pub(crate) rule simple_literal_start()
- = [ 'A'..='Z' ] / ##ident_start()
+ = [ 'A'..='Z' ] / # #ident_start()
});
However, this breaks peg
because the peg macro uses Jointness to detect the ##IDENT()
syntax. When the ##
tokens are separated, they change to have Alone
spacing.
I don't know what we can do here, other than remove the ##
reservation in 2024, but that has other implications.
Meta
rustc 1.85.0-nightly (c44b3d50f 2024-12-03)
binary: rustc
commit-hash: c44b3d50fea96a3e0417e8264c16ea21a0a3fca2
commit-date: 2024-12-03
host: aarch64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4
Tracking:
Metadata
Metadata
Assignees
Labels
Area: The 2024 editionArea: Procedural macrosCategory: This is a bug.Diagnostics: An error or lint that should account for edition differences.`#![feature(unprefixed_guarded_strings)]`Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.