Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,13 @@ impl fmt::Debug for Punct {
}
}

#[stable(feature = "proc_macro_punct_eq", since = "1.49.0")]
impl PartialEq<char> for Punct {
fn eq(&self, rhs: &char) -> bool {
self.as_char() == *rhs
}
}

/// An identifier (`ident`).
#[derive(Clone)]
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
Expand Down
10 changes: 9 additions & 1 deletion library/proc_macro/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(proc_macro_span)]

use proc_macro::LineColumn;
use proc_macro::{LineColumn, Punct};

#[test]
fn test_line_column_ord() {
Expand All @@ -10,3 +10,11 @@ fn test_line_column_ord() {
assert!(line0_column0 < line0_column1);
assert!(line0_column1 < line1_column0);
}

#[test]
fn test_punct_eq() {
// Good enough if it typechecks, since proc_macro::Punct can't exist in a test.
fn _check(punct: Punct) {
let _ = punct == ':';
}
}