Skip to content

Commit c117b76

Browse files
authored
WIP attr macro (#316)
* some progress on attribute macro * first draft, tests still broken * nix cleanup * use real trybuild * test for config parameter * PR feedback - use formatted Display impl for snapshot test * add hygiene test * PR feedback * pin to trybuild 1.0.0 for MSRV * actually pin properly
1 parent b449b1e commit c117b76

28 files changed

+4665
-4
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ persistence-test.txt
99

1010
# IntelliJ
1111
.idea
12+
13+
/.direnv

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ members = [
33
"proptest",
44
"proptest-derive",
55
"proptest-state-machine",
6+
"proptest-macro",
67
]
78

89
exclude = ["proptest/test-persistence-location/*"]

flake.lock

+129
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
description = "proptest development environment";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
rust-overlay.url = "github:oxalica/rust-overlay";
8+
};
9+
10+
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
11+
flake-utils.lib.eachDefaultSystem
12+
(
13+
system:
14+
let
15+
pkgs = import nixpkgs {
16+
inherit system;
17+
overlays = [ (import rust-overlay) ];
18+
};
19+
in
20+
{
21+
devShells.default = pkgs.mkShell {
22+
nativeBuildInputs = with pkgs; [
23+
rust-bin.nightly.latest.default
24+
25+
cargo-insta
26+
];
27+
28+
TRYBUILD_CARGO_CMD = "test";
29+
};
30+
}
31+
);
32+
}

proptest-derive/src/ast.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use std::ops::{Add, AddAssign};
1414

1515
use proc_macro2::{Span, TokenStream};
1616
use quote::{ToTokens, TokenStreamExt};
17-
use syn;
1817
use syn::spanned::Spanned;
1918

2019
use crate::error::{Ctx, DeriveResult};

proptest-macro/Cargo.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "proptest-macro"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
proc-macro = true
8+
9+
[dependencies]
10+
syn = { version = "2", features = ["full"] }
11+
quote = "1"
12+
proc-macro2 = "1"
13+
convert_case = "0.6"
14+
15+
[dev-dependencies]
16+
insta = "1"
17+
prettyplease = "0.2"

proptest-macro/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use proc_macro::TokenStream;
2+
3+
mod property_test;
4+
5+
#[proc_macro_attribute]
6+
pub fn property_test(attr: TokenStream, item: TokenStream) -> TokenStream {
7+
property_test::property_test(attr.into(), item.into()).into()
8+
}

0 commit comments

Comments
 (0)