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

"cargo fix" produces an error message and fails to apply the suggested fixes to the file #5808

Closed
dthul opened this issue Jul 26, 2018 · 2 comments

Comments

@dthul
Copy link

dthul commented Jul 26, 2018

I used cargo fix to transition my project to Rust 2018 and noticed that one of my source files made it error out so I extracted the following minimal example:

Cargo.toml

[package]
name = "cargofixtest"
version = "0.1.0"
authors = ["Daniel Thul <daniel.thul@gmail.com>"]

[dependencies]
pyo3 = "0.3.1"

lib.rs

#![feature(use_extern_macros, specialization)]

extern crate pyo3;
use pyo3::prelude::*;

#[pyclass]
pub struct Test {
    token: PyToken,
}

#[pymethods]
impl Test {
    #[new]
    fn __new__(obj: &PyRawObject) -> PyResult<()> {
        obj.init(|token| Test { token: token })
    }

    fn fun(&self, py: Python) -> PyResult<()> {
        Ok(())
    }
}

cargo fix tries to replace fun(&self, py: Python) with fun(&self, _py: Python) but fails with the following output:

    Checking cargofixtest v0.1.0 (file:///C:/Users/dthul/repos/cargofix)
warning: failed to automatically apply fixes suggested by rustc to crate `cargofix`

after fixes were automatically applied the compiler reported errors within these files:

  * src\lib.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/cargo/issues
quoting the full output of this command we'd be very appreciative!

warning: unused variable: `py`
  |
  = note: #[warn(unused_variables)] on by default

    Finished dev [unoptimized + debuginfo] target(s) in 0.59s

It does not fail when removing the __new__ method and its #[new] annotation.

@dthul
Copy link
Author

dthul commented Jul 26, 2018

Looks like similar problems have already been reported (#5775, #5785, #5798, #5799).
Sorry for the duplicate.

@alexcrichton
Copy link
Member

Thanks for the report and no worries if this is a duplicate! This issue is sort of a blending of #5738 and #5799, with two bugs here:

In that sense I'm gonna close this issue in favor of those two issues. Thanks regardless though for the report! I'd rather close duplicate issues than not know about issues :)

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

No branches or pull requests

2 participants