make spec parser stricter
Signed-off-by: Onur Özkan <work@onurozkan.dev>
This commit is contained in:
1 parent
4c6ee111e8
commit
b0a7a9bb03
14 files changed
+96
-18
No files matched your search
@@ -0,0 +1,6 @@
|
||||
use kaptan_spec::spec;
|
||||
|
||||
#[spec("flight_core_contract.md")]
|
||||
struct InvalidSuffix;
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
error: spec path must end in `.spec.md`; use #[spec("file.spec.md")]
|
||||
--> tests/ui/fail_invalid_suffix.rs:3:1
|
||||
|
|
||||
3 | #[spec("flight_core_contract.md")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the attribute macro `spec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -0,0 +1,6 @@
|
||||
use kaptan_spec::spec;
|
||||
|
||||
#[spec(path = "flight_core_contract.spec.md")]
|
||||
struct LegacyNamedArgument;
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
error: invalid spec attribute; use #[spec("file.spec.md")]
|
||||
--> tests/ui/fail_legacy_named_argument.rs:3:1
|
||||
|
|
||||
3 | #[spec(path = "flight_core_contract.spec.md")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the attribute macro `spec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -0,0 +1,6 @@
|
||||
use kaptan_spec::spec;
|
||||
|
||||
#[spec]
|
||||
struct MissingArgument;
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
error: missing spec path; use #[spec("file.spec.md")]
|
||||
--> tests/ui/fail_missing_argument.rs:3:1
|
||||
|
|
||||
3 | #[spec]
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: this error originates in the attribute macro `spec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -1,8 +1,7 @@
|
||||
use kaptan_spec::spec;
|
||||
|
||||
#[spec("fail_missing_sidecar.spec.md")]
|
||||
struct MissingSpec;
|
||||
mod missing_spec {}
|
||||
|
||||
fn main() {
|
||||
let _ = core::mem::size_of::<MissingSpec>();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
use kaptan_spec::spec;
|
||||
|
||||
#[spec("flight_core_contract.spec.md")]
|
||||
struct FlightCore;
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
error: `#[spec]` may only be applied to a module
|
||||
--> tests/ui/fail_non_module_item.rs:3:1
|
||||
|
|
||||
3 | #[spec("flight_core_contract.spec.md")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the attribute macro `spec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -0,0 +1,6 @@
|
||||
use kaptan_spec::spec;
|
||||
|
||||
#[spec(42)]
|
||||
struct NonStringArgument;
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
error: invalid spec attribute; use #[spec("file.spec.md")]
|
||||
--> tests/ui/fail_non_string_argument.rs:3:1
|
||||
|
|
||||
3 | #[spec(42)]
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the attribute macro `spec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -1,9 +1,8 @@
|
||||
use kaptan_spec::spec;
|
||||
|
||||
#[spec("flight_core_contract.spec.md")]
|
||||
struct FlightCore;
|
||||
mod flight_core {}
|
||||
|
||||
fn main() {
|
||||
let size = core::mem::size_of::<FlightCore>();
|
||||
assert_eq!(size, 0);
|
||||
assert_eq!(core::mem::size_of::<()>(), 0);
|
||||
}
|
||||
Reference in new issue
Block a user