mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
fix(derive): Improve skip
method error
Really this is about consolidating the skip checks but it also provideda chance to improve the error.
This commit is contained in:
parent
8a5a9ba931
commit
abcee38466
2 changed files with 16 additions and 12 deletions
|
@ -221,15 +221,8 @@ impl Item {
|
|||
);
|
||||
}
|
||||
}
|
||||
Kind::Skip(_, _) => {
|
||||
if res.has_explicit_methods() {
|
||||
abort!(
|
||||
res.kind.span(),
|
||||
"methods are not allowed for skipped fields"
|
||||
);
|
||||
}
|
||||
}
|
||||
Kind::FromGlobal(_)
|
||||
Kind::Skip(_, _)
|
||||
| Kind::FromGlobal(_)
|
||||
| Kind::Arg(_)
|
||||
| Kind::Command(_)
|
||||
| Kind::Value
|
||||
|
@ -792,6 +785,17 @@ impl Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Kind::Skip(_, attr) = &*self.kind {
|
||||
if self.has_explicit_methods() {
|
||||
abort!(
|
||||
self.methods[0].name.span(),
|
||||
"`{}` cannot be used with `#[{}(skip)]",
|
||||
self.methods[0].name,
|
||||
attr.as_str(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn push_doc_comment(&mut self, attrs: &[Attribute], name: &str) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: methods are not allowed for skipped fields
|
||||
--> tests/derive_ui/skip_with_other_options.rs:8:11
|
||||
error: `long` cannot be used with `#[arg(skip)]
|
||||
--> tests/derive_ui/skip_with_other_options.rs:8:17
|
||||
|
|
||||
8 | #[arg(skip, long)]
|
||||
| ^^^^
|
||||
| ^^^^
|
||||
|
|
Loading…
Reference in a new issue