Skip to content

use std::*; makes fail! fail #7580

Closed
Closed

Description

@chris-morgan

Minimal test case:

use std::*;
fn main() {
    fail!("");
}

rustc output:

<core-macros>:45:12: 45:48 error: unresolved import: could not find `sys` in `std::std`.
<core-macros>:45             ::std::sys::FailWithCause::fail_with($msg, file!(), line!())
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<core-macros>:40:4: 50:5 note: in expansion of fail!
x.rs:3:1: 3:11 note: expansion site
<core-macros>:45:12: 45:48 error: use of undeclared module `::std::sys::FailWithCause`
<core-macros>:45             ::std::sys::FailWithCause::fail_with($msg, file!(), line!())
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<core-macros>:40:4: 50:5 note: in expansion of fail!
x.rs:3:1: 3:11 note: expansion site
<core-macros>:45:12: 45:48 error: unresolved name `std::sys::FailWithCause::fail_with`.
<core-macros>:45             ::std::sys::FailWithCause::fail_with($msg, file!(), line!())
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<core-macros>:40:4: 50:5 note: in expansion of fail!
x.rs:3:1: 3:11 note: expansion site
error: aborting due to 3 previous errors

Rust 0.7, Ubuntu 13.04, 64-bit.

Activity

  1. brson commented on Jul 10, 2013

    @brson
    Contributor

    Funny. This is because std exports an inner module called std that shadows std.

  2. brson commented on Jul 10, 2013

    @brson
    Contributor

    There are probably other lurking bugs due to this.

  3. thestinger commented on Sep 16, 2013

    @thestinger
    Contributor

    This evil inner module is still around. We couls probably just special case the macro injection via an attribute like #[module_is_std];.

  4. alexcrichton commented on Sep 16, 2013

    @alexcrichton
    Member

    This could probably use a similar fix as #8242, something at the top of the file which says that the path to libstd is.

  5. huonw commented on Oct 20, 2013

    @huonw
    Contributor

    Fixed by the privacy changes that meant that std module in std can be private. This works:

    use std::*;
    fn main() {
        io::println("ok");
        fail!()
    }

    Flagging as needstest.

  6. added a commit that references this issue on Aug 21, 2026
    835cf55
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

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions