rust-lang/rustfix

Bug report generated for a fix which breaks custom checks in proc macro

Closed this issue · 5 comments

I ran cargo +nightly fix --prepare-for 2018 --allow-dirty on a toy project, and it asked me to report the output as an issue. I assume it's because of the macro usage in rocket?

warning: failed to automatically apply fixes suggested by rustc to crate `hello_rocket`

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

  * src/auth.rs

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

warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/db/models/user.rs:1:5
  |
1 | use db::models::schema::user::dsl::*;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::db::models::schema::user::dsl::*`
  |
  = note: `-W absolute-paths-not-starting-with-crate` implied by `-W rust-2018-compatibility`
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue TBD

warning: unused import: `db::models::schema::user::dsl::*`
 --> src/db/models/user.rs:1:5
  |
1 | use db::models::schema::user::dsl::*;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/forms/login.rs:7:5
  |
7 | use fields::{EmailField, PasswordField};
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::fields::{EmailField, PasswordField}`
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue TBD

warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/forms/login.rs:8:5
  |
8 | use db::models::user;
  |     ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::db::models::user`
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue TBD

warning: unused import: `db::models::user`
 --> src/forms/login.rs:8:5
  |
8 | use db::models::user;
  |     ^^^^^^^^^^^^^^^^

warning: unused import: `Form`
 --> src/fields/mod.rs:2:23
  |
2 | use rocket::request::{Form, FromFormValue};
  |                       ^^^^

warning: unused imports: `Cookie`, `Cookies`
 --> src/fields/mod.rs:3:20
  |
3 | use rocket::http::{Cookie,Cookies, RawStr};
  |                    ^^^^^^ ^^^^^^^

warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/auth.rs:6:5
  |
6 | use forms::login::LoginForm;
  |     ^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::forms::login::LoginForm`
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue TBD

warning: unused imports: `Cookie`, `RawStr`
 --> src/home.rs:3:20
  |
3 | use rocket::http::{Cookie,Cookies, RawStr};
  |                    ^^^^^^          ^^^^^^

warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/home.rs:6:5
  |
6 | use forms::login;
  |     ^^^^^^^^^^^^ help: use `crate`: `crate::forms::login`
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue TBD

warning: unused variable: `login_form`
  --> src/auth.rs:11:40
   |
11 | pub fn login<'r>(mut cookies: Cookies, login_form: Form<'r, LoginForm<'r>>) -> Redirect {
   |                                        ^^^^^^^^^^ help: consider using `_login_form` instead
   |
   = note: #[warn(unused_variables)] on by default

warning: unused variable: `cookie`
  --> src/home.rs:10:6
   |
10 |     let cookie = cookies.get_private("user_id").unwrap();
   |         ^^^^^^ help: consider using `_cookie` instead

warning: unused variable: `v`
  --> src/fields/mod.rs:26:21
   |
26 |     fn from_form_value(v: &'v RawStr) -> Result<Self, Self::Error> {
   |                        ^ help: consider using `_v` instead

warning: struct is never used: `User`
 --> src/db/models/user.rs:4:1
  |
4 | pub struct User {
  | ^^^^^^^^^^^^^^^
  |
  = note: #[warn(dead_code)] on by default

warning: method is never used: `conn`
  --> src/db/mod.rs:29:2
   |
29 |     pub fn conn(&self) -> &SqliteConnection {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    Finished dev [unoptimized + debuginfo] target(s) in 2m 36s


Thanks for the report! The issue here is with these two lines. The compiler suggests renaming the unused login_form variable to _login_form which then causes rocket's macros to generate an error here because it no longer matches the data="..." field.

Unfortunately I'm not sure what to do about this. Ideally we wouldn't classify this as our own bug in rustfix/rustc but would instead leave the warning as-is.

No, this is definitely a rustfix bug, --prepare-for-2018 should only be applying edition lint fixes and not other suggestions

@Manishearth can you open a dedicated bug for that?

Ok, I'm gonna close this in favor of #129