Skip to content

Discrepancy between compilation of crates and single-file executables. #15348

Closed
@nwin

Description

@nwin

I have two files:

module.rs

#[main]
fn main() {
    println!("{}", std::str::from_utf8_lossy(b"Hello, world!"));
}

lib.rs

#![crate_id = "testcrate"]
#![crate_type = "bin"]

mod module;

rustc module.rs compiles without any problems. rustc lib.rs yields the error message:

module.rs:3:17: 3:42 error: unresolved name `std::str::from_utf8_lossy`.
module.rs:3     println!("{}", std::str::from_utf8_lossy(b"Hello, world!"));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions