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

Allow non-utf8 filenames #150

Closed
jyn514 opened this issue Jan 15, 2020 · 2 comments · Fixed by #151
Closed

Allow non-utf8 filenames #150

jyn514 opened this issue Jan 15, 2020 · 2 comments · Fixed by #151

Comments

@jyn514
Copy link
Collaborator

jyn514 commented Jan 15, 2020

Filenames on Unix can be arbitrary bytes; on Windows they can be arbitrary UTF16 (and I think there's some strangeness around surrogate pairs).

error[E0277]: the trait bound `std::string::String: std::convert::From<std::path::PathBuf>` is not satisfied
   --> src/main.rs:108:27
    |
108 |     let file_id = file_db.add(opt.filename, buf);
    |                           ^^^ the trait `std::convert::From<std::path::PathBuf>` is not implemented for `std::string::String`
    |
    = help: the following implementations were found:
              <std::string::String as std::convert::From<&std::string::String>>
              <std::string::String as std::convert::From<&str>>
              <std::string::String as std::convert::From<rcc::data::LengthError>>
              <std::string::String as std::convert::From<std::borrow::Cow<'a, str>>>
              <std::string::String as std::convert::From<std::boxed::Box<str>>>
    = note: required because of the requirements on the impl of `std::convert::Into<std::string::String>` for `std::path::PathBuf`
@jyn514
Copy link
Collaborator Author

jyn514 commented Jan 15, 2020

I think the proper thing to do would be storing a OsString instead of a String. I can make a PR if it's welcome :)

@brendanzab
Copy link
Owner

Yes, this makes sense! This was my mistake! 🤦‍♂

jyn514 added a commit to jyn514/codespan that referenced this issue Jan 15, 2020
Allows storing arbitrary filenames in `File`

Closes brendanzab#150
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 a pull request may close this issue.

2 participants