style: Disallow 'not', 'and', and 'or' from <container-name>

Differential Revision: https://phabricator.services.mozilla.com/D156805
This commit is contained in:
Ziran Sun 2022-09-14 11:48:01 +00:00 committed by Martin Robinson
parent f9f5283a65
commit 3fc54c24e2

View file

@ -1539,9 +1539,10 @@ impl Parse for ContainerName {
if first.eq_ignore_ascii_case("none") {
return Ok(Self::none())
}
idents.push(CustomIdent::from_ident(location, first, &["none"])?);
const DISALLOWED_CONTAINER_NAMES: &'static [&'static str] = &["none", "not", "or", "and"];
idents.push(CustomIdent::from_ident(location, first, DISALLOWED_CONTAINER_NAMES)?);
while let Ok(ident) = input.try_parse(|input| input.expect_ident_cloned()) {
idents.push(CustomIdent::from_ident(location, &ident, &["none"])?);
idents.push(CustomIdent::from_ident(location, &ident, DISALLOWED_CONTAINER_NAMES)?);
}
Ok(ContainerName(idents.into()))
}