Closed
Description
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.