1
Fork 0
mirror of https://github.com/RGBCube/cstree synced 2025-07-28 01:27:44 +00:00

Add derive macro for Syntax (used to be Language) (#51)

This commit is contained in:
DQ 2023-04-18 20:10:35 +02:00 committed by GitHub
parent 2aa543036f
commit c5279bae7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 1459 additions and 899 deletions

View file

@ -0,0 +1,10 @@
use cstree::Syntax;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Syntax)]
pub enum SyntaxKind {
A,
#[static_text("b")]
B,
}
fn main() {}

View file

@ -0,0 +1,9 @@
error: syntax kind definitions must be `#[repr(u32)]` to derive `Syntax`
--> tests/ui/repr/missing_repr.rs:4:1
|
4 | / pub enum SyntaxKind {
5 | | A,
6 | | #[static_text("b")]
7 | | B,
8 | | }
| |_^

View file

@ -0,0 +1,11 @@
use cstree::Syntax;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Syntax)]
#[repr(C)]
pub enum SyntaxKind {
A,
#[static_text("b")]
B,
}
fn main() {}

View file

@ -0,0 +1,10 @@
error: syntax kind definitions must be `#[repr(u32)]` to derive `Syntax`
--> tests/ui/repr/wrong_repr_c.rs:4:1
|
4 | / #[repr(C)]
5 | | pub enum SyntaxKind {
6 | | A,
7 | | #[static_text("b")]
8 | | B,
9 | | }
| |_^

View file

@ -0,0 +1,11 @@
use cstree::Syntax;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Syntax)]
#[repr(u16)]
pub enum SyntaxKind {
A,
#[static_text("b")]
B,
}
fn main() {}

View file

@ -0,0 +1,10 @@
error: syntax kind definitions must be `#[repr(u32)]` to derive `Syntax`
--> tests/ui/repr/wrong_repr_u16.rs:4:1
|
4 | / #[repr(u16)]
5 | | pub enum SyntaxKind {
6 | | A,
7 | | #[static_text("b")]
8 | | B,
9 | | }
| |_^