confval v0.12.0
The non_empty and unique flags take a help line.
#[confval(format = ...)] now applies to a PathBuf field.
check_references alone decides whether a block label names anything.
A handwritten spec builds its range and length records from the constants it checks with.
Highlights
#[confval(non_empty(help = "..."))]and#[confval(unique(help = "..."))]keep a help line in the diagnostic, the schema, and the hover.#[confval(format = AbsolutePath)]compiles on aLocated<PathBuf>.#[confval(non_empty)]on a#[confval(label)]field is a compile error, becausecheck_referencesreports an empty label.
Added
#[confval(non_empty(help = "..."))]and#[confval(unique(help = "..."))]. The help replaces the generated suggestion in the diagnostic. The schema keeps it inSchemaField::non_empty_helpandSchemaField::unique_help. The hover reads it after the rule sentence.NonEmptyConstraint::with_helpandUniqueConstraint::with_help, for a handwritten spec that declares the rule once as a const.SchemaField::with_non_empty_helpandSchemaField::with_unique_help, which set the flag and keep the help line.#[confval(format = ...)]on aLocated<PathBuf>or anOption<Located<PathBuf>>. The check reads the path's text, and the schema records the format on thePathleaf.check_format_path, in the prelude besidecheck_format. The derive emits it for aPathBufleaf, and a handwrittenValidatebody calls it the same way.RangeConstraint::constraintandLengthConstraint::constraint, which return the schema record for the constant a handwrittenvalidatechecks with. The derive emits the same call. A derived record and a handwritten record then come from one code path.
Changed
- The compile error for a
formaton the wrong shape now reads#[confval(format = ...)] requires a String leaf, a Path leaf, or a string list. NonEmptyConstraintandUniqueConstraintare structs with ahelpfield and are#[non_exhaustive]. WriteNON_EMPTY,UNIQUE, orwith_help(...)where code named the bare type as a value.check_referencestreats a whitespace-only label as empty. The empty label report has a help line that names the block and its label field. A reference to such a label no longer resolves.- The language server refuses to rename a whitespace-only label, the way it refuses an empty one.
Removed
- The
#[confval(label, non_empty)]pair. The derive rejects it with#[confval(non_empty)] cannot be combined with #[confval(label)]; check_references reports an empty label, so run that pass beside validate_all.
Upgrading
If a #[confval(label)] field has #[confval(non_empty)], delete the flag.
Confirm that your pipeline runs check_references beside validate_all.
That pass reports the empty label the flag used to report.
A whitespace-only label now reports as empty.
A reference to that label reports as undefined.
NonEmptyConstraint and UniqueConstraint are no longer unit structs, and both are #[non_exhaustive].
Where code wrote the bare type name as a value, write NON_EMPTY, UNIQUE, or NonEmptyConstraint::with_help(...).
Where code matched the bare type name as a pattern, bind the value or match with NonEmptyConstraint { .. }.
A struct literal of either type no longer compiles outside the crate.
[dependencies]
confval = { version = "0.12", features = ["derive", "hcl", "color"] }