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

Paths and filenames are not necessarily UTF-8 #7225

Closed
huonw opened this issue Jun 19, 2013 · 4 comments · Fixed by #9655
Closed

Paths and filenames are not necessarily UTF-8 #7225

huonw opened this issue Jun 19, 2013 · 4 comments · Fixed by #9655
Labels
A-Unicode Area: Unicode
Milestone

Comments

@huonw
Copy link
Member

huonw commented Jun 19, 2013

$ mkdir empty
$ cd empty
$ ls
$ touch $(echo -e "\xff") # `ÿ` in latin1, invalid UTF8, but valid filename
$ ls
?
$ rusti
WARNING: The Rust REPL is experimental and may be
unstable. If you encounter problems, please use the
compiler instead. Type :help for help.
rusti> std::os::list_dir(&Path("."))
rust: task failed at 'assertion failed: is_utf8(v)', /home/huon/rust/src/libstd/str.rs:758
terminate called after throwing an instance of 'rust_task*'
Aborted

Path and all interfaces directly with the file-system should probably use [u8] rather than trying to coerce str to handle these cases. (Similar issue to #7188.)

@bblum
Copy link
Contributor

bblum commented Jul 3, 2013

nominating feature-complete

@catamorphism
Copy link
Contributor

Accepted for backwards-compatible

@lilyball
Copy link
Contributor

My last referenced commit is a month old, but I'm still working on this issue (currently finishing up the support for Windows paths).

@pnkfelix
Copy link
Member

The issues here of dealing with filesystems that are not utf8 seem related to #2253, at least tangentially.

MicahChalmer added a commit to MicahChalmer/rust-fuse-mc-original that referenced this issue Sep 30, 2013
This commit was originally a sequence of trial-and-error commits that
are a bit of a mess. Rather than include them, or trying to turn them
retroactively into a separate commit for each of the below, I'm just
squashing them into here.  The changes in a nutshell:

There are now tests that can run under src/test.  So far it just checks
that the hello world filesystem works.

I no longer start an OS thread for each FS operation.  There is one
thread for the C API, which passes all commands back to a "dispatch
task" running on the default scheduler, which in turn starts a new task
on the default scheduler for each command.

I don't try to turn byte strings I get from FUSE into utf-8.  I still
use std::path in the public API, and therefore could run into some
problems due to rust-lang/rust#7225 but that will be addressed here when
the underlying problem in std::path is taken care of.

The public API now consists of a FuseMount object whose existence is
tied to the mounting of a filesystem via FUSE.

There is a Makefile whose main purpose is to allow you to quickly run
the tests.  Once "rustpkg test" works, it may not be needed anymore.
lilyball added a commit to lilyball/rust that referenced this issue Oct 16, 2013
As documented in rust-lang#7225, we cannot rely on paths being representable in
utf-8. Specifically, Linux allows anything (besides NUL) in a path.
Redesign GenericPath in light of this.

PosixPath hasn't been reimplemented yet for ~[u8].
@bors bors closed this as completed in 40180cd Oct 16, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue May 20, 2021
…r=llogiq

New lint: `unused_async`

changelog: Adds a lint, `unused_async`, which checks for async functions with no await statements

`unused_async` is a lint that reduces code smell and overhead by encouraging async functions to be refactored into synchronous functions.

Fixes rust-lang#7176

### Examples

```rust
async fn get_random_number() -> i64 {
    4 // Chosen by fair dice roll. Guaranteed to be random.
}
```

Could be written as:

```rust
fn get_random_number() -> i64 {
    4 // Chosen by fair dice roll. Guaranteed to be random.
}
```

Something like this, however, should **not** be caught by clippy:
```rust
#[async_trait]
trait AsyncTrait {
    async fn foo();
}

struct Bar;

#[async_trait]
impl AsyncTrait for Bar {
    async fn foo() {
        println!("bar");
    }
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Unicode Area: Unicode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants