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 #31

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

FileExt methods cause compiler warnings on rust 1.84 #31

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

Comments

@eric-seppanen
Copy link

eric-seppanen commented Nov 27, 2024

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

use fs4::fs_std::FileExt;

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
}
$ cargo +beta-2024-11-27 check

warning: a method with this name may be added to the standard library in the future
  --> src/lib.rs:10:10
   |
10 |     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, which are tracked by the file_lock feature (rust-lang/rust#130994).

@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
mstange added a commit to mstange/samply that referenced this issue Jan 19, 2025
vcfxb added a commit to vcfxb/wright-lang that referenced this issue Jan 31, 2025
@al8n
Copy link
Owner

al8n commented Feb 23, 2025

Hi, is the warning still there in the latest version? I test it on the my local machine, it seems that no warnings anymore.

@ofek
Copy link

ofek commented Feb 23, 2025

I still see the warnings on the latest version and is making CI fail.

@al8n
Copy link
Owner

al8n commented Feb 23, 2025

I still see the warnings on the latest version and is making CI fail.

Which OS are you using? In fs4's CI, there are no warnings. Maybe using FileExt::lock_* instead of using file.lock_* can solve the problem?

@ofek
Copy link

ofek commented Feb 23, 2025

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