Skip to content

unused_imports redundant import is already defined here points to self #121915

Closed
@correabuscar

Description

@correabuscar

is already defined here doesn't point to the proper place:
playground link
in this output:

   Compiling playground v0.0.1 (/playground)
warning: the item `libc` is imported redundantly
 --> src/main.rs:3:5
  |
3 | use libc;
  |     ^^^^ the item `libc` is already defined here
  |
  = note: `#[warn(unused_imports)]` on by default

warning: `playground` (bin "playground") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.58s
     Running `target/debug/playground`

for this code:

use std::ffi::{CStr, CString};

use libc;

fn main() {
    let lib_name = CString::new("libEGL.so").unwrap();
    let lib_ptr = unsafe { libc::dlopen(lib_name.as_ptr(), libc::RTLD_NOW) };

    if lib_ptr.is_null() {
        let error_msg = unsafe { CStr::from_ptr(libc::dlerror()) }.to_str().unwrap();
        println!("Error loading library: {}", error_msg);
        return;
    }

    // Access functions from the library
    // ...

    unsafe { libc::dlclose(lib_ptr) };
}

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (ef324565d 2024-02-27)
binary: rustc
commit-hash: ef324565d071c6d7e2477a195648549e33d6a465
commit-date: 2024-02-27
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0


initially mentioned it here, on the pull request: #117772 (comment)

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions