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

The compiler proposes to import non-existing trait #39978

Closed
iamnotacake opened this issue Feb 20, 2017 · 2 comments
Closed

The compiler proposes to import non-existing trait #39978

iamnotacake opened this issue Feb 20, 2017 · 2 comments

Comments

@iamnotacake
Copy link

I am using rustc 1.15.1 (021bd294c 2017-02-08), installed with rustup on Arch Linux

Here is code:

// use std::os::ext::fs::MetadataExt;

fn main() {
    let file = std::fs::File::open("/dev/null").unwrap();
    let metadata = file.metadata().unwrap();

    println!("{:?}", metadata.mode());
}

When I try to compile this, I get

error: no method named `mode` found for type `std::fs::Metadata` in the current scope
 --> src/main.rs:9:31
  |
9 |     println!("{:?}", metadata.mode());
  |                               ^^^^
  |
  = help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
  = help: candidate #1: `use std::os::ext::fs::MetadataExt;`

but when I uncomment first line, I get

error[E0432]: unresolved import `std::os::ext::fs::MetadataExt`
 --> src/main.rs:3:5
  |
3 | use std::os::ext::fs::MetadataExt;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find `ext` in `os`

The solution is to use std::os::linux::fs::MetadataExt; and then use st_mode() instead of mode() but that's not good. Compiler must not give me bad advices.

@aidanhs
Copy link
Member

aidanhs commented Feb 20, 2017

This looks the same as #26454

@Aatch
Copy link
Contributor

Aatch commented Feb 21, 2017

Duplicate of #26454

@Aatch Aatch closed this as completed Feb 21, 2017
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