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

Incorrect example at using Path #10241

Closed
tredoe opened this issue Nov 3, 2013 · 2 comments
Closed

Incorrect example at using Path #10241

tredoe opened this issue Nov 3, 2013 · 2 comments

Comments

@tredoe
Copy link

tredoe commented Nov 3, 2013

Use of path::Path incorrect in http://static.rust-lang.org/doc/master/std/rt/io/file/fn.open.html

Instead of let p = &Path("/some/file/path.txt");, should be let p = &Path::new("/some/file/path.txt");

@huonw
Copy link
Member

huonw commented Nov 3, 2013

Hi, thanks for the report; looks like you are correct, but this function is being removed in #10179 (replaced by std::rt::io::File::{open, create, open_mode} depending on the exact requirements) so this can be closed when that lands.

(In any case, this prompted me to go and double check the documentation @alexcrichton had written there, and caught a few similar mistakes, so perfect timing. :) )

@alexcrichton
Copy link
Member

Ah yes, thanks for pointing this out! I should have fixed all of the examples in std::rt::io::fs at this point now (and hopefully it'll land soon as well).

alexcrichton added a commit to alexcrichton/rust that referenced this issue Nov 3, 2013
This renames the `file` module to `fs` because that more accurately describes
its current purpose (manipulating the filesystem, not just files).

Additionally, this adds an UnstableFileStat structure as a nested structure of
FileStat to signify that the fields should not be depended on. The structure is
currently flagged with #[unstable], but it's unlikely that it has much meaning.

Closes rust-lang#10241
Jarcho pushed a commit to Jarcho/rust that referenced this issue Feb 26, 2023
manual_let_else: do not suggest semantically different replacements

The problem is that this lint does not consider the possibility that the divergent branch can come first and that the patterns may overlap. This led to incorrect suggestions, previously registered as correct in the tests themselves:

```rust
let v = match build_enum() {
    _ => continue,
    Variant::Bar(v) | Variant::Baz(v) => v,
};
```

had a `let Variant::Bar(v) | Variant::Baz(v) = v else { continue; }` suggestion, which is obviously wrong as the original code `continue`s in any case. Issue rust-lang#10241 gives another example.

The code now checks that the divergent branch comes second. It could be extended later (I've added a TODO) to check for non-overlapping patterns.

Fixes rust-lang#10241.

changelog: [`manual_let_else`] do not suggest non equivalent replacements in `match`
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

No branches or pull requests

3 participants