facet-kdl Compile Error Showcase
Unknown Extension Attribute
Using an unknown attribute like kdl::nonexistent produces a clear error
that points directly to the attribute and suggests valid options.
Rust Input
use facet::Facet; use facet_kdl as kdl; #[derive(Facet)] struct Config { #[facet(kdl::nonexistent)] field: String, } fn main() {}
Compiler Error
error: unknown extension attribute `nonexistent`
--> src/main.rs:6:18
|
6 | #[facet(kdl::nonexistent)]
| ^^^^^^^^^^^
error: could not compile test (bin "test") due to 1 previous error
Typo in Attribute Name
Common typos like chld instead of child or proprty instead of property
are caught at compile time with helpful suggestions.
Rust Input
use facet::Facet; use facet_kdl as kdl; #[derive(Facet)] struct Config { #[facet(kdl::chld)] nested: Inner, } #[derive(Facet)] struct Inner { #[facet(kdl::proprty)] value: String, } fn main() {}
Compiler Error
error: unknown extension attribute `chld`
--> src/main.rs:6:18
|
6 | #[facet(kdl::chld)]
| ^^^^
error: unknown extension attribute proprty
--> src/main.rs:12:18
|
12 | #[facet(kdl::proprty)]
| ^^^^^^^
error: could not compile test (bin "test") due to 2 previous errors
Attribute with Unexpected Arguments
Passing arguments to attributes that don't accept them produces a clear error.
Rust Input
use facet::Facet; use facet_kdl as kdl; #[derive(Facet)] struct Config { #[facet(kdl::child = "unexpected")] nested: Inner, } #[derive(Facet)] struct Inner { value: String, } fn main() {}
Compiler Error
error: kdl::child does not accept arguments
--> src/main.rs:6:26
|
6 | #[facet(kdl::child = "unexpected")]
| ^^^^^^^^^^^^
error: could not compile test (bin "test") due to 1 previous error
Valid Usage
When extension attributes are used correctly, everything compiles smoothly.
This shows the intended usage pattern for KDL attributes.
Rust Input
use facet::Facet; use facet_kdl as kdl; #[derive(Facet)] struct Config { #[facet(kdl::child)] server: Server, #[facet(kdl::property)] name: String, #[facet(kdl::argument)] version: u32, } #[derive(Facet)] struct Server { #[facet(kdl::property)] host: String, #[facet(kdl::property)] port: u16, } fn main() { println!("Compiles successfully!"); }
Compiler Error
Compilation successful! No errors.