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

Correct error types for icu_provider_fs #3682

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

robertbastian
Copy link
Member

@robertbastian robertbastian commented Jul 14, 2023

Blocked on #3680

Fixes #3610

@robertbastian robertbastian requested review from sffc and a team as code owners July 14, 2023 12:59
Manishearth
Manishearth previously approved these changes Jul 14, 2023
Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is sad

@robertbastian
Copy link
Member Author

Yes this requires 1.64

@robertbastian robertbastian merged commit 2075d9e into unicode-org:main Jul 20, 2023
23 checks passed
@robertbastian robertbastian deleted the errs branch July 20, 2023 13:53
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(requesting changes)

provider/adapters/src/fork/by_error.rs Show resolved Hide resolved
@@ -10,6 +10,9 @@ use icu_provider::prelude::*;
///
/// [`ForkByErrorProvider`]: super::ForkByErrorProvider
pub trait ForkByErrorPredicate {
/// The error to return if there are zero providers.
const ERROR: DataErrorKind = DataErrorKind::MissingDataKey;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: NO_PROVIDER_ERROR_KIND or FALLBACK_ERROR_KIND would be more clear because ForkByErrorPredicate normally uses the predicate function to test its error type.

let mut path_buf = self.root.clone().into_os_string();
write!(
&mut path_buf,
"/{key}/{locale}.{}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue, here and elsewhere: using / is not good because Windows and other OSes need different separators. That is what PathBuf::push handles for us. I don't think either write! or Path::new fixes it for us since write! is writing directly to a string and Path::new tries to borrow where possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently this works because Windows tests are not failing. Note that before we used push(&str), which used AsRef<Path> for &str, so the slashes in the str were still forward slashes (and push itself doesn't replace them).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so before we were appending individual path segments for root, key, and locale, but the key can contain a slash which wasn't being processed.

I wouldn't be surprised if Windows accepts these characters but does some weird handling with them.

@eggrobin and @makotokato are the two ICU4X engineers who routinely use Windows and might be able to provide some insight here.

provider/fs/src/export/fs_exporter.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No provider should fail with MissingDataKey if it was built with a key but that key has no locales
3 participants