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

FileExt methods cause compiler warnings on rust 1.84 #50

Open
eric-seppanen opened this issue Nov 27, 2024 · 2 comments
Open

FileExt methods cause compiler warnings on rust 1.84 #50

eric-seppanen opened this issue Nov 27, 2024 · 2 comments

Comments

@eric-seppanen
Copy link

eric-seppanen commented Nov 27, 2024

Using the lock methods from fs2 cause rustc warnings on rust 1.84:

pub fn read_file(filename: &str) -> String {
    let mut file = std::fs::File::open(filename).unwrap();
    file.lock_shared().unwrap();
    let mut data = String::new();
    file.read_to_string(&mut data).unwrap();
    data
}
warning: a method with this name may be added to the standard library in the future
 --> src/lib.rs:8:10
  |
8 |     file.lock_shared().unwrap();
  |          ^^^^^^^^^^^
  |
  = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
  = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
  = help: call with fully qualified syntax `lock_shared(...)` to keep using the current method
  = note: `#[warn(unstable_name_collisions)]` on by default

The name collision happens for lock_shared, try_lock_shared, and unlock.

@danburkert
Copy link
Owner

danburkert commented Nov 27, 2024 via email

@eric-seppanen
Copy link
Author

It may be annoying but the lint is correct: if the file_lock feature gets stabilized, code that was calling the fs2 methods will silently switch over to the std methods instead.

@eric-seppanen eric-seppanen changed the title FileExt methods cause compiler warnings on rust 1.83 FileExt methods cause compiler warnings on rust 1.84 Nov 27, 2024
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

2 participants