Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_bake! #5092

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions components/calendar/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,12 @@ impl<'de> serde::Deserialize<'de> for WeekdaySet {
fn test_weekdayset_bake() {
databake::test_bake!(
WeekdaySet,
const: crate::provider::WeekdaySet::new(
&[crate::types::IsoWeekday::Monday, crate::types::IsoWeekday::Wednesday, crate::types::IsoWeekday::Friday]),
const,
crate::provider::WeekdaySet::new(&[
crate::types::IsoWeekday::Monday,
crate::types::IsoWeekday::Wednesday,
crate::types::IsoWeekday::Friday
]),
icu_calendar
);
}
Expand Down
5 changes: 3 additions & 2 deletions components/collections/src/codepointinvlist/cpinvlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,12 +1016,13 @@ mod tests {
fn databake() {
databake::test_bake!(
CodePointInversionList<'static>,
const: unsafe {
const,
unsafe {
#[allow(unused_unsafe)]
crate::codepointinvlist::CodePointInversionList::from_parts_unchecked(
unsafe {
zerovec::ZeroVec::from_bytes_unchecked(
b"0\0\0\0:\0\0\0A\0\0\0G\0\0\0a\0\0\0g\0\0\0"
b"0\0\0\0:\0\0\0A\0\0\0G\0\0\0a\0\0\0g\0\0\0",
)
},
22u32,
Expand Down
3 changes: 2 additions & 1 deletion components/collections/src/codepointtrie/cptrie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,8 @@ mod tests {
fn databake() {
databake::test_bake!(
CodePointTrie<'static, u32>,
const: crate::codepointtrie::CodePointTrie::from_parts(
const,
crate::codepointtrie::CodePointTrie::from_parts(
crate::codepointtrie::CodePointTrieHeader {
high_start: 1u32,
shifted12_high_start: 2u16,
Expand Down
3 changes: 2 additions & 1 deletion components/datetime/src/pattern/runtime/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ impl databake::Bake for PatternMetadata {
fn databake() {
databake::test_bake!(
PatternMetadata,
const: crate::pattern::runtime::PatternMetadata::from_time_granularity(
const,
crate::pattern::runtime::PatternMetadata::from_time_granularity(
crate::pattern::TimeGranularity::Hours
),
icu_datetime,
Expand Down
3 changes: 2 additions & 1 deletion components/list/src/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ impl databake::Bake for ListJoinerPattern<'_> {
fn databake() {
databake::test_bake!(
ListJoinerPattern,
const: crate::provider::ListJoinerPattern::from_parts(", ", 2u8),
const,
crate::provider::ListJoinerPattern::from_parts(", ", 2u8),
icu_list
);
}
15 changes: 10 additions & 5 deletions components/list/src/provider/serde_dfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,16 @@ mod test {
// This is the DFA for ".*"
databake::test_bake!(
SerdeDFA,
const: unsafe { crate::provider::SerdeDFA::from_dfa_bytes_unchecked(if cfg!(target_endian = "little") {
b"rust-regex-automata-dfa-sparse\0\0\xFF\xFE\0\0\x02\0\0\0\0\0\0\0\x0E\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x06\x06\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x08\t\t\t\t\t\t\t\t\t\t\t\t\n\x0B\x0B\x0C\r\r\r\x0E\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x98\x01\0\0\x01\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x0E\x80\0\0\x01\x01\x02\x02\x03\x06\x07\x07\x08\x08\t\t\n\n\x0B\x0B\x0C\x0C\r\r\x0E\x0E\x0F\x0F\0\0\x12\0\0\0q\0\0\0\x12\0\0\0q\0\0\0\x82\0\0\0\x99\0\0\0\xB0\0\0\0\xC7\0\0\0\xB0\0\0\0\xDE\0\0\0\xF5\0\0\0\x0C\x01\0\0q\0\0\0q\0\0\0\x01\0\0\0\0\0\0\0\0\x01\x80\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0#\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x05\x05\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x04\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x04\x05\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x03\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x0E\0\0\0\x01\x01\x02\x02\x03\x06\x07\x07\x08\x08\t\t\n\n\x0B\x0B\x0C\x0C\r\r\x0E\x0E\x0F\x0F\0\0\x12\0\0\0q\0\0\0\x12\0\0\0q\0\0\0\x82\0\0\0\x99\0\0\0\xB0\0\0\0\xC7\0\0\0\xB0\0\0\0\xDE\0\0\0\xF5\0\0\0\x0C\x01\0\0q\0\0\0q\0\0\0\0\x02\0\x03\x05\0\0\x89\x01\0\0\0\0\0\0\0\x02\0\x03\x05\0\0#\x01\0\0\0\0\0\0\0\x04\0\0\0\0\0\0\0#\x01\0\0#\x01\0\0#\x01\0\0#\x01\0\0#\x01\0\0\t\0\0\0\x12\0\0\0\x0C\x01\0\0\0\0\0\0\0\0\0\0#\x01\0\0#\x01\0\0"
} else {
b"rust-regex-automata-dfa-sparse\0\0\0\0\xFE\xFF\0\0\0\x02\0\0\0\0\0\0\0\x0E\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\x01\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x06\x06\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x08\t\t\t\t\t\t\t\t\t\t\t\t\n\x0B\x0B\x0C\r\r\r\x0E\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\0\0\x01\x98\x01\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x0E\x80\0\0\x01\x01\x02\x02\x03\x06\x07\x07\x08\x08\t\t\n\n\x0B\x0B\x0C\x0C\r\r\x0E\x0E\x0F\x0F\0\0\x12\0\0\0q\0\0\0\x12\0\0\0q\0\0\0\x82\0\0\0\x99\0\0\0\xB0\0\0\0\xC7\0\0\0\xB0\0\0\0\xDE\0\0\0\xF5\0\0\0\x0C\x01\0\0q\0\0\0q\0\0\0\x01\0\0\0\0\0\0\0\0\x01\x80\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0#\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x05\x05\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x04\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x04\x05\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x03\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x0E\0\0\0\x01\x01\x02\x02\x03\x06\x07\x07\x08\x08\t\t\n\n\x0B\x0B\x0C\x0C\r\r\x0E\x0E\x0F\x0F\0\0\x12\0\0\0q\0\0\0\x12\0\0\0q\0\0\0\x82\0\0\0\x99\0\0\0\xB0\0\0\0\xC7\0\0\0\xB0\0\0\0\xDE\0\0\0\xF5\0\0\0\x0C\x01\0\0q\0\0\0q\0\0\0\0\x02\0\x03\x05\0\0\x89\x01\0\0\0\0\0\0\0\x02\0\x03\x05\0\0#\x01\0\0\0\0\0\0\0\0\0\0\x04\0\0\0\0#\x01\0\0#\x01\0\0#\x01\0\0#\x01\0\0\0\0\x01#\0\0\0\t\0\0\0\x12\0\0\x01\x0C\0\0\0\0\0\0\0\0\0\0\x01#\0\0\x01#"
})},
const,
unsafe {
crate::provider::SerdeDFA::from_dfa_bytes_unchecked(
if cfg!(target_endian = "little") {
b"rust-regex-automata-dfa-sparse\0\0\xFF\xFE\0\0\x02\0\0\0\0\0\0\0\x0E\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x06\x06\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x08\t\t\t\t\t\t\t\t\t\t\t\t\n\x0B\x0B\x0C\r\r\r\x0E\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x98\x01\0\0\x01\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x0E\x80\0\0\x01\x01\x02\x02\x03\x06\x07\x07\x08\x08\t\t\n\n\x0B\x0B\x0C\x0C\r\r\x0E\x0E\x0F\x0F\0\0\x12\0\0\0q\0\0\0\x12\0\0\0q\0\0\0\x82\0\0\0\x99\0\0\0\xB0\0\0\0\xC7\0\0\0\xB0\0\0\0\xDE\0\0\0\xF5\0\0\0\x0C\x01\0\0q\0\0\0q\0\0\0\x01\0\0\0\0\0\0\0\0\x01\x80\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0#\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x05\x05\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x04\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x04\x05\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x03\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x0E\0\0\0\x01\x01\x02\x02\x03\x06\x07\x07\x08\x08\t\t\n\n\x0B\x0B\x0C\x0C\r\r\x0E\x0E\x0F\x0F\0\0\x12\0\0\0q\0\0\0\x12\0\0\0q\0\0\0\x82\0\0\0\x99\0\0\0\xB0\0\0\0\xC7\0\0\0\xB0\0\0\0\xDE\0\0\0\xF5\0\0\0\x0C\x01\0\0q\0\0\0q\0\0\0\0\x02\0\x03\x05\0\0\x89\x01\0\0\0\0\0\0\0\x02\0\x03\x05\0\0#\x01\0\0\0\0\0\0\0\x04\0\0\0\0\0\0\0#\x01\0\0#\x01\0\0#\x01\0\0#\x01\0\0#\x01\0\0\t\0\0\0\x12\0\0\0\x0C\x01\0\0\0\0\0\0\0\0\0\0#\x01\0\0#\x01\0\0"
} else {
b"rust-regex-automata-dfa-sparse\0\0\0\0\xFE\xFF\0\0\0\x02\0\0\0\0\0\0\0\x0E\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\x01\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x06\x06\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x08\t\t\t\t\t\t\t\t\t\t\t\t\n\x0B\x0B\x0C\r\r\r\x0E\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F\0\0\x01\x98\x01\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x0E\x80\0\0\x01\x01\x02\x02\x03\x06\x07\x07\x08\x08\t\t\n\n\x0B\x0B\x0C\x0C\r\r\x0E\x0E\x0F\x0F\0\0\x12\0\0\0q\0\0\0\x12\0\0\0q\0\0\0\x82\0\0\0\x99\0\0\0\xB0\0\0\0\xC7\0\0\0\xB0\0\0\0\xDE\0\0\0\xF5\0\0\0\x0C\x01\0\0q\0\0\0q\0\0\0\x01\0\0\0\0\0\0\0\0\x01\x80\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0#\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x05\x05\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x04\0\0\x89\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x04\x05\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x05\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x02\x80\x03\x03\0\0z\x01\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\x0E\0\0\0\x01\x01\x02\x02\x03\x06\x07\x07\x08\x08\t\t\n\n\x0B\x0B\x0C\x0C\r\r\x0E\x0E\x0F\x0F\0\0\x12\0\0\0q\0\0\0\x12\0\0\0q\0\0\0\x82\0\0\0\x99\0\0\0\xB0\0\0\0\xC7\0\0\0\xB0\0\0\0\xDE\0\0\0\xF5\0\0\0\x0C\x01\0\0q\0\0\0q\0\0\0\0\x02\0\x03\x05\0\0\x89\x01\0\0\0\0\0\0\0\x02\0\x03\x05\0\0#\x01\0\0\0\0\0\0\0\0\0\0\x04\0\0\0\0#\x01\0\0#\x01\0\0#\x01\0\0#\x01\0\0\0\0\x01#\0\0\0\t\0\0\0\x12\0\0\x01\x0C\0\0\0\0\0\0\0\0\0\0\x01#\0\0\x01#"
},
)
},
icu_list
);
}
Expand Down
2 changes: 1 addition & 1 deletion utils/databake/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions utils/databake/derive/tests/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ pub struct IntExample {
}

#[test]
#[ignore] // https://github.com/rust-lang/rust/issues/98906
fn test_int_example() {
test_bake!(
IntExample,
const: crate::IntExample { x: 17u8, },
test,
);
test_bake!(IntExample, const, crate::IntExample { x: 17u8 }, test,);
}

#[derive(Bake)]
Expand All @@ -30,11 +25,14 @@ pub struct GenericsExample<T> {
}

#[test]
#[ignore] // https://github.com/rust-lang/rust/issues/98906
fn test_generics_example() {
test_bake!(
GenericsExample<isize>,
const: crate::GenericsExample { x: 17u32, y: 100isize },
const,
crate::GenericsExample {
x: 17u32,
y: 100isize
},
test
);
}
Expand All @@ -52,7 +50,8 @@ pub struct CowExample<'a> {
fn test_cow_example() {
test_bake!(
CowExample<'static>,
const: crate::CowExample {
const,
crate::CowExample {
x: 17u8,
y: "foo",
z: alloc::borrow::Cow::Borrowed("bar"),
Expand Down
5 changes: 3 additions & 2 deletions utils/databake/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ where
fn cow() {
test_bake!(
alloc::borrow::Cow<'static, str>,
const: alloc::borrow::Cow::Borrowed("hi"),
const,
alloc::borrow::Cow::Borrowed("hi"),
alloc
);
assert_eq!(
Expand Down Expand Up @@ -54,7 +55,7 @@ where

#[test]
fn vec() {
test_bake!(Vec<u8>, alloc::vec![1u8, 2u8,], alloc);
test_bake!(Vec<u8>, alloc::vec![1u8, 2u8], alloc);
}

impl<T> Bake for alloc::collections::BTreeSet<T>
Expand Down
14 changes: 8 additions & 6 deletions utils/databake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
//! # Testing
//! The [`test_bake`] macro can be used to assert that a particular expression is a `Bake` fixed point.
//!
//! ```no_run
//! # // https://github.com/rust-lang/rust/issues/98906
//! ```
//! # use databake::*;
//! # #[derive(Bake)]
//! # #[databake(path = my_crate)]
Expand All @@ -59,7 +58,7 @@
//! # fn main() {
//! test_bake!(
//! AnotherOne,
//! const: crate::AnotherOne(
//! const, crate::AnotherOne(
//! crate::MyStruct {
//! number: 17u32,
//! string: "foo",
Expand Down Expand Up @@ -135,7 +134,7 @@ pub trait Bake {
///
/// ```
/// # use databake::test_bake;
/// test_bake!(usize, const: 18usize);
/// test_bake!(usize, const, 18usize);
/// ```
///
/// ## Crates and imports
Expand Down Expand Up @@ -164,7 +163,7 @@ pub trait Bake {
/// `CrateEnv`. The `crate`-replacement crate will always be checked.
#[macro_export]
macro_rules! test_bake {
($type:ty, const: $expr:expr $(, $krate:ident)? $(, [$($env_crate:ident),+])? $(,)?) => {
($type:ty, const, $expr:expr $(, $krate:ident)? $(, [$($env_crate:ident),+])? $(,)?) => {
const _: &$type = &$expr;
$crate::test_bake!($type, $expr $(, $krate)? $(, [$($env_crate),+])?);
};
Expand All @@ -173,8 +172,11 @@ macro_rules! test_bake {
let env = Default::default();
let expr: &$type = &$expr;
let bake = $crate::Bake::bake(expr, &env).to_string();
// `TokenStream::to_string` and the `stringify!` macro seem to disagree on this
// For some reason `TokenStream` behaves differently in this line
let expected_bake = $crate::quote!($expr).to_string().replace("::<", ":: <").replace(">::", "> ::");
// Trailing commas are a mess as well
let bake = bake.replace(" ,)", ")").replace(" ,]", "]").replace(" , }", " }");
let expected_bake = expected_bake.replace(" ,)", ")").replace(" ,]", "]").replace(" , }", " }");
$(
let expected_bake = expected_bake.replace("crate", stringify!($krate));
)?
Expand Down
65 changes: 13 additions & 52 deletions utils/databake/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ literal!(

#[test]
fn literal() {
test_bake!(
u16,
const: 3849u16
);
test_bake!(u16, const, 3849u16);
}

impl<'a, T: ?Sized> Bake for &'a T
Expand All @@ -55,10 +52,7 @@ where

#[test]
fn r#ref() {
test_bake!(
&f32,
const: &934.34f32
);
test_bake!(&f32, const, &934.34f32);
}

impl<T> Bake for [T]
Expand Down Expand Up @@ -128,18 +122,9 @@ where

#[test]
fn array() {
test_bake!(
&[bool; 0],
const: &[]
);
test_bake!(
&[bool; 1],
const: &[true]
);
test_bake!(
&[bool; 2],
const: &[true, false]
);
test_bake!(&[bool; 0], const, &[]);
test_bake!(&[bool; 1], const, &[true]);
test_bake!(&[bool; 2], const, &[true, false]);
}

impl<T> Bake for Option<T>
Expand All @@ -161,14 +146,8 @@ where

#[test]
fn option() {
test_bake!(
Option<&'static str>,
const: Some("hello")
);
test_bake!(
Option<&'static str>,
const: None
);
test_bake!(Option<&'static str>, const, Some("hello"));
test_bake!(Option<&'static str>, const, None);
}

impl<T, E> Bake for Result<T, E>
Expand All @@ -194,14 +173,8 @@ where

#[test]
fn result() {
test_bake!(
Result<&'static str, ()>,
const: Ok("hello")
);
test_bake!(
Result<&'static str, ()>,
const: Err(())
);
test_bake!(Result<&'static str, ()>, const, Ok("hello"));
test_bake!(Result<&'static str, ()>, const, Err(()));
}

macro_rules! tuple {
Expand Down Expand Up @@ -244,18 +217,9 @@ tuple!(A, a, B, b, C, c, D, d, E, e, F, f, G, g, H, h, I, i, J, j);

#[test]
fn tuple() {
test_bake!(
(),
const: ()
);
test_bake!(
(u8,),
const: (0u8,)
);
test_bake!(
(u8, i8),
const: (0u8, 0i8)
);
test_bake!((), const, ());
test_bake!((u8,), const, (0u8,));
test_bake!((u8, i8), const, (0u8, 0i8));
}

impl<T> Bake for PhantomData<T> {
Expand All @@ -268,8 +232,5 @@ impl<T> Bake for PhantomData<T> {

#[test]
fn phantom_data() {
test_bake!(
PhantomData<usize>,
const: ::core::marker::PhantomData
);
test_bake!(PhantomData<usize>, const, ::core::marker::PhantomData);
}
27 changes: 14 additions & 13 deletions utils/litemap/src/databake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,26 @@ fn test_baked_map() {
// Const construction:
test_bake!(
LiteMap<usize, &str, &[(usize, &str)]>,
const: crate::LiteMap::from_sorted_store_unchecked(
&[
(1usize, "one"),
(2usize, "two"),
(10usize, "ten")
]
),
const,
crate::LiteMap::from_sorted_store_unchecked(
&[
(1usize, "one"),
(2usize, "two"),
(10usize, "ten"),
]
),
litemap
);
// Non-const construction:
test_bake!(
LiteMap<usize, String, Vec<(usize, String)>>,
crate::LiteMap::from_sorted_store_unchecked(
alloc::vec![
(1usize, "one".to_owned()),
(2usize, "two".to_owned()),
(10usize, "ten".to_owned()),
]
),
alloc::vec![
(1usize, "one".to_owned()),
(2usize, "two".to_owned()),
(10usize, "ten".to_owned()),
]
),
litemap
);
}
3 changes: 2 additions & 1 deletion utils/pattern/src/frontend/databake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ fn test_baked() {
use alloc::borrow::Cow;
test_bake!(
Pattern<SinglePlaceholder, Cow<str>>,
const: crate::Pattern::<crate::SinglePlaceholder, _>::from_store_unchecked(alloc::borrow::Cow::Borrowed("")),
const,
crate::Pattern::<crate::SinglePlaceholder, _>::from_store_unchecked(alloc::borrow::Cow::Borrowed("")),
icu_pattern
);
}
Loading
Loading