Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
beamspease opened this issue Jan 10, 2017 · 4 comments · Fixed by #42230
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@beamspease
Copy link

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!

@oli-obk
Copy link
Contributor

oli-obk commented Jan 10, 2017

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
Copy link
Contributor

oli-obk commented Jan 10, 2017

@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
Copy link
Author

beamspease commented Jan 10, 2017 via email

@Mark-Simulacrum
Copy link
Member

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

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 19, 2017
venkatagiri added a commit to venkatagiri/rust that referenced this issue May 25, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 26, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 26, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants