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

Regression in what path is chosen for error messages #45070

Closed
dtolnay opened this issue Oct 6, 2017 · 8 comments
Closed

Regression in what path is chosen for error messages #45070

dtolnay opened this issue Oct 6, 2017 · 8 comments
Labels
C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Oct 6, 2017

#[macro_use]
extern crate serde_derive;

#[derive(Serialize)]
struct S;

fn main() {
    i32::from(""); // error
}

Error with rustc 1.21.0-beta.3 (ea1fd7d 2017-09-15):

error[E0277]: the trait bound `i32: std::convert::From<&str>` is not satisfied
 --> src/main.rs:8:5
  |
8 |     i32::from(""); // error
  |     ^^^^^^^^^ the trait `std::convert::From<&str>` is not implemented for `i32`

Error with rustc 1.22.0-nightly (417c738 2017-10-05):

error[E0277]: the trait bound `i32: _IMPL_SERIALIZE_FOR_S::_serde::export::From<&str>` is not satisfied
 --> src/main.rs:8:5
  |
8 |     i32::from(""); // error
  |     ^^^^^^^^^ the trait `_IMPL_SERIALIZE_FOR_S::_serde::export::From<&str>` is not implemented for `i32`

I would expect the error message to show std::convert::From, not Serde's re-export at least in code that has nothing to do with Serde.

@ExpHP
Copy link
Contributor

ExpHP commented Oct 12, 2017

d93036a...dead08c

Only two big merges in this timeframe. cc @alexcrichton?

@alexcrichton
Copy link
Member

Sorry I don't know what there may have led to this :(

@najamelan
Copy link
Contributor

@dtolnay I have the impression this is fixed on 1.23, can you confirm?

@dtolnay
Copy link
Member Author

dtolnay commented Nov 20, 2017

Seems like it. Thanks!

@dtolnay dtolnay closed this as completed Nov 20, 2017
@dtolnay dtolnay reopened this Nov 26, 2017
@dtolnay
Copy link
Member Author

dtolnay commented Nov 26, 2017

Reopening because while the original code now gives a reasonable error, I am still seeing serde::export in error messages seemingly at random. With rustc 1.23.0-nightly (e97ba83 2017-11-25):

extern crate serde;

fn main() {
    struct S;
    S.clone();
}
error[E0599]: no method named `clone` found for type `main::S` in the current scope
 --> src/main.rs:5:7
  |
4 |     struct S;
  |     --------- method `clone` not found for this
5 |     S.clone();
  |       ^^^^^
  |
  = help: items from traits can only be used if the trait is implemented and in scope
  = note: the following trait defines an item `clone`, perhaps you need to implement it:
          candidate #1: `serde::export::Clone`

Adding extern crate chrono before extern crate serde fixes the message, but adding it after and the message is still wrong.

@najamelan
Copy link
Contributor

I also see error messages that change when the order of use statements is changed, which was unexpected for me. But maybe that's for a different issue? I agree that in the code example you show above it is undesirable to mention serde in the error, but maybe I miss something fundamental about how serde interacts with compilation.

@dtolnay dtolnay added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Dec 14, 2017
@dtolnay
Copy link
Member Author

dtolnay commented Dec 24, 2017

#46112 has some more examples of what looks like the same bug.

@dtolnay dtolnay added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 24, 2017
@dtolnay
Copy link
Member Author

dtolnay commented Dec 25, 2017

Fixed by #46708 and #46838.

@dtolnay dtolnay closed this as completed Dec 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants