Skip to content

extern crate in local scope #42776

Closed
Closed
@aleksander

Description

@aleksander

This code

fn main() {
    extern crate libc;
    println!("Hello, world!");
}

compiled without any errors or warnings, but it's not possible to use any libc's items inside main. Should compiler warn about wrong place for extern crate? Or this is legal to use extern crate in local scope?

Activity

kennytm

kennytm commented on Jun 20, 2017

@kennytm
Member
Mark-Simulacrum

Mark-Simulacrum commented on Jun 20, 2017

@Mark-Simulacrum
Member

Perhaps we should give a diagnostic message here though.. tagging A-diagnostics.

added
A-diagnosticsArea: Messages for errors, warnings, and lints
A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
on Jun 20, 2017
steveklabnik

steveklabnik commented on Dec 25, 2019

@steveklabnik
Member

Triage: now that most code will not use extern crate, and given that it's been over two years with no other people running into this, I'm going to give this a close. If someone wanted to work up a diagnostic, I don't think it would be denied, but I don't think this is ever realistically going to be fixed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@kennytm@aleksander@Mark-Simulacrum

        Issue actions

          extern crate in local scope · Issue #42776 · rust-lang/rust