Skip to content

Compilation failure with no explicit error when passing ref std::path::Path to std::fs::File::open #38954

@beamspease

Description

@beamspease

I'm fairly new to Rust, so there may be something I'm missing here.

The following code snippet causes the Rust compiler (1.14, beta 1.15, nightly 1.16) to crash without any explicit errors on an up-to-date Arch Linux system immediately after a rustup update.

Cargo.toml
[package] name = "crash" version = "0.1.0"

lib.rs
pub fn from_filepath(ref p: std::path::Path) -> std::io::Result<std::fs::File> { std::fs::File::open(p) }

The only error I see is:
error: Could not compile 'crash'.

If I specify -vv, I just see the full command line (with a return code of -1).

Thanks!

Activity

oli-obk

oli-obk commented on Jan 10, 2017

@oli-obk
Contributor

minimal repro example:

pub fn f(ref p: str) {}

reproduces on playground, can't reproduce with locally installed rust (rustc 1.14.0 (e8a012324 2016-12-16) and rustc 1.16.0-nightly (47c8d9fdc 2017-01-08)) on x86_64 linux

oli-obk

oli-obk commented on Jan 10, 2017

@oli-obk
Contributor

@beamspease: I suggest you use

pub fn from_filepath(p: &std::path::Path)

instead. The missing error message is the issue here. To best of my knowledge the code as you wrote it is illegal, but should report an error.

beamspease

beamspease commented on Jan 10, 2017

@beamspease
Author
Mark-Simulacrum

Mark-Simulacrum commented on May 19, 2017

@Mark-Simulacrum
Member

Seems fine today; we should probably have a test for this, E-needstest.

added
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on May 19, 2017
added a commit that references this issue on May 26, 2017
e988851
added 2 commits that reference this issue on May 26, 2017
076a422
2c3aa91
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-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

      Participants

      @oli-obk@Mark-Simulacrum@beamspease

      Issue actions

        Compilation failure with no explicit error when passing ref std::path::Path to std::fs::File::open · Issue #38954 · rust-lang/rust