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

error[E0433]: failed to resolve: could not find Advice in memmap2 #107

Closed
hornta opened this issue Dec 8, 2023 · 1 comment
Closed

error[E0433]: failed to resolve: could not find Advice in memmap2 #107

hornta opened this issue Dec 8, 2023 · 1 comment

Comments

@hornta
Copy link

hornta commented Dec 8, 2023

I'm trying to build a rust project on Windows 11 but it yields an error.

I've never built anything before in rust so I don't know what I should troubleshoot.

cargo version: cargo 1.74.1 (ecb9851af 2023-10-18)

rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.74.1 (a28077b28 2023-12-04)`
error[E0433]: failed to resolve: could not find `Advice` in `memmap2`
  --> src\main.rs:83:30
   |
83 |         mmap.advise(memmap2::Advice::HugePage).unwrap();
   |                              ^^^^^^ could not find `Advice` in `memmap2`

error[E0599]: no method named `advise` found for struct `memmap2::Mmap` in the current scope
  --> src\main.rs:83:14
   |
83 |         mmap.advise(memmap2::Advice::HugePage).unwrap();
   |              ^^^^^^ method not found in `Mmap`

Some errors have detailed explanations: E0433, E0599.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `parser` (bin "parser") due to 2 previous errors
@adamreichold
Copy link

The problem is that this functionality is not available on Windows but only Unix-like systems, hence the compiler cannot find it.

If you are working on a cross-platform project and you want to optionally use this code on Unix-like systems, you could use conditional compilation via the #[cfg(unix)] attribute to include it only where the functionality is available.

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