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 - failure with Deserialize #5799

Closed
ExpHP opened this issue Jul 26, 2018 · 2 comments · Fixed by rust-lang/rust#52756
Closed

cargo fix - failure with Deserialize #5799

ExpHP opened this issue Jul 26, 2018 · 2 comments · Fixed by rust-lang/rust#52756
Assignees

Comments

@ExpHP
Copy link
Contributor

ExpHP commented Jul 26, 2018

cc @alexcrichton

Oh dear these issues sound bad! Are you sure you were testing with an up-to-date nightly? Recent changes in lint emissions should supress lints related to foreign macros (like derive in these cases) but if they’re still showing up that’s a bug!

Would you be able to share some test cases if it’s still showing problems?


#![feature(rust_2018_preview)]

extern crate serde;
#[macro_use]
extern crate serde_derive;

#[derive(Deserialize)]
pub struct Struct(::module::Thing);

mod module {
    #[derive(Deserialize)]
    pub struct Thing;
}

A complete source tree: deserialize-test-case.tar.gz

This test case will be "magically" fixed when the additions to the proc-macro crate wrapped by proc-macro2 become stable.


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

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: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/lib.rs:8:19
  |
8 | pub struct Struct(::module::Thing);
  |                   ^^^^^^^^^^^^^^^ help: use `crate`: `crate::module::Thing`
  |
  = 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: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/lib.rs:7:10
  |
7 | #[derive(Deserialize)]
  |          ^^^^^^^^^^^ help: use `crate`: `crate::Deserialize`
  |
  = 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/lib.rs:8:19
  |
8 | pub struct Struct(::module::Thing);
  |                   ^^^^^^^^^^^^^^^ help: use `crate`: `crate::module::Thing`
  |
  = 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: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/lib.rs:7:10
  |
7 | #[derive(Deserialize)]
  |          ^^^^^^^^^^^ help: use `crate`: `crate::Deserialize`
  |
  = 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

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

Tested on rustc 1.29.0-nightly (6a1c0637c 2018-07-23)

@alexcrichton
Copy link
Member

Thanks for the report! Unfortunately this is a case that won't be fixed with an update to various crates, the issue here is:

  • First, the ::module::Thing path should be using a crate-relative path, and rustc warns about this with a correct suggestion.
  • Next, presumably somewhere in the generated code of #[derive(Deserialize)], it also mentions the path the user has written down, as ::module::Thing. This is also warned against as it needs a fix, but the span information here is incorrect. That means the suggestion becomes nonsensical (crate::Deserialize in derive)

The bug here is that the compiler is marking the second suggestion as automatically fixable, when it's not. I'll look into that.

@alexcrichton alexcrichton added this to the Edition Preview 2 milestone Jul 26, 2018
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jul 30, 2018
Recent changes to lints disallowed lints from being emitted against code located
in foreign macros, except for future-incompatible lints. For a future
incompatible lint, however, the automatic suggestions may not be applicable!

This commit updates this code path to force all applicability suggestions made
to foreign macros to never be `MachineApplicable`. This should avoid rustfix
actually attempting fixing these suggestions, causing non-compiling code to be
produced.

Closes rust-lang/cargo#5799
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 30, 2018
rustc: Disallow machine applicability in foreign macros

Recent changes to lints disallowed lints from being emitted against code located
in foreign macros, except for future-incompatible lints. For a future
incompatible lint, however, the automatic suggestions may not be applicable!

This commit updates this code path to force all applicability suggestions made
to foreign macros to never be `MachineApplicable`. This should avoid rustfix
actually attempting fixing these suggestions, causing non-compiling code to be
produced.

Closes rust-lang/cargo#5799
@alexcrichton alexcrichton self-assigned this Jul 31, 2018
@alexcrichton
Copy link
Member

I've confirmed this is fixed by rust-lang/rust#52756, so I'm going to close in favor of that.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Aug 1, 2018
rustc: Disallow machine applicability in foreign macros

Recent changes to lints disallowed lints from being emitted against code located
in foreign macros, except for future-incompatible lints. For a future
incompatible lint, however, the automatic suggestions may not be applicable!

This commit updates this code path to force all applicability suggestions made
to foreign macros to never be `MachineApplicable`. This should avoid rustfix
actually attempting fixing these suggestions, causing non-compiling code to be
produced.

Closes rust-lang/cargo#5799
bors added a commit to rust-lang/rust that referenced this issue Aug 1, 2018
rustc: Disallow machine applicability in foreign macros

Recent changes to lints disallowed lints from being emitted against code located
in foreign macros, except for future-incompatible lints. For a future
incompatible lint, however, the automatic suggestions may not be applicable!

This commit updates this code path to force all applicability suggestions made
to foreign macros to never be `MachineApplicable`. This should avoid rustfix
actually attempting fixing these suggestions, causing non-compiling code to be
produced.

Closes rust-lang/cargo#5799
djrenren pushed a commit to djrenren/compiletest that referenced this issue Aug 26, 2019
Recent changes to lints disallowed lints from being emitted against code located
in foreign macros, except for future-incompatible lints. For a future
incompatible lint, however, the automatic suggestions may not be applicable!

This commit updates this code path to force all applicability suggestions made
to foreign macros to never be `MachineApplicable`. This should avoid rustfix
actually attempting fixing these suggestions, causing non-compiling code to be
produced.

Closes rust-lang/cargo#5799
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants