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

Suggestions for miniz_oxide included in diagnostics in crate with no dependencies #88696

Closed
m-ou-se opened this issue Sep 6, 2021 · 10 comments · Fixed by #111076
Closed

Suggestions for miniz_oxide included in diagnostics in crate with no dependencies #88696

m-ou-se opened this issue Sep 6, 2021 · 10 comments · Fixed by #111076
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Sep 6, 2021

So, I was just chatting a bit with rustc and I was saying:

#![feature(never_type)]

fn a() -> Result<!, i32> {
    Err(1)
}

fn b() -> Result<u32, i32> {
    a().into()
}

fn main() {
    let _ = dbg!(b());
}

And then rustc said:

error[E0277]: the trait bound `Result<u32, i32>: From<Result<!, i32>>` is not satisfied
 --> src/main.rs:8:9
  |
8 |     a().into()
  |         ^^^^ the trait `From<Result<!, i32>>` is not implemented for `Result<u32, i32>`
  |

And I was like, sure, whatever you say.

But then rustc told me:

  = help: the following implementations were found:
            <Result<miniz_oxide::MZStatus, miniz_oxide::MZError> as From<&miniz_oxide::StreamResult>>
            <Result<miniz_oxide::MZStatus, miniz_oxide::MZError> as From<miniz_oxide::StreamResult>>

And I was like, excuse me what??


This crate has no dependencies. (Just an empty cargo new .. package.)

This happens on at least:

  • rustc 1.55.0-nightly (014026d 2021-07-19)
  • rustc 1.56.0-nightly (ccffcaf 2021-08-11)
  • rustc 1.57.0-nightly (5d2a410 2021-09-04)

(On x86_64-unknown-linux-gnu and other platforms where backtrace is enabled in std, such that miniz_oxide is pulled in as a dependency of std.)

@m-ou-se m-ou-se added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-confusing Diagnostics: Confusing error or lint that should be reworked. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Sep 6, 2021
@m-ou-se
Copy link
Member Author

m-ou-se commented Sep 6, 2021

miniz_oxide is a (private) dependency of std, but it shouldn't show up in diagnostics for any program using std like this.

@m-ou-se m-ou-se added A-diagnostics Area: Messages for errors, warnings, and lints and removed A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` labels Sep 6, 2021
@camelid camelid added the A-trait-system Area: Trait system label Sep 6, 2021
@camelid
Copy link
Member

camelid commented Sep 6, 2021

And, even aside from miniz_oxide being a private dependency, the suggestions seem very unrelated to the input code. I guess just because they're From impls on Result? I would have thought other From impls would have come up too though.

@camelid
Copy link
Member

camelid commented Sep 6, 2021

I wonder if this is specific to never_type or not.

@camelid camelid added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Sep 6, 2021
@hellow554
Copy link
Contributor

I think the suggestion should not show up anymore if #87349 would have been merged.

Can you try that out? Would that be feasible for you?

@m-ou-se
Copy link
Member Author

m-ou-se commented Sep 7, 2021

Ah that looks relevant. Trying that PR now..

@m-ou-se
Copy link
Member Author

m-ou-se commented Sep 7, 2021

Nope. Same output with #87349.

@hellow554
Copy link
Contributor

@In-line can you maybe say why your PR doesn't cover this case? :/

@apiraino
Copy link
Contributor

apiraino commented Sep 8, 2021

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 8, 2021
@QuineDot
Copy link

QuineDot commented Mar 5, 2022

I just got this too, in code with zero dependencies which is not at all exotic. All the non-std types here are just enums.

error[E0277]: the trait bound `Result<Option<Score>, build::Error>: From<Result<_, EntryError>>` is not satisfied
   --> src/build.rs:105:33
    |
105 |         Err(EntryError::InvalidScore).into()
    |                                       ^^^^ the trait `From<Result<_, EntryError>>` is not implemented for `Result<Option<Score>, build::Error>`
    |
    = help: the following implementations were found:
              <Result<miniz_oxide::MZStatus, miniz_oxide::MZError> as From<&miniz_oxide::StreamResult>>
              <Result<miniz_oxide::MZStatus, miniz_oxide::MZError> as From<miniz_oxide::StreamResult>>
    = note: required because of the requirements on the impl of `Into<Result<Option<Score>, build::Error>>` for `Result<_, EntryError>`

"miniz_oxide" doesn't cry out "implicit stdlib thing" so I spent awhile trying to figure out how an unrelated project was polluting this one, running cargo clean in various places, etc.

@jirutka
Copy link

jirutka commented Apr 9, 2023

miniz_oxide is a (private) dependency of std, but it shouldn't show up in diagnostics for any program using std like this.

The real question is, why is minz_oxide pulled into a trivial program (binary) in the first place? It’s not a small dependency.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 15, 2023
…e-dep-trait-impl-suggestions, r=cjgillot

diagnostics: exclude indirect private deps from trait impl suggest

Fixes rust-lang#88696
bors added a commit to rust-lang-ci/rust that referenced this issue May 31, 2023
…dep-trait-impl-suggestions, r=cjgillot

diagnostics: exclude indirect private deps from trait impl suggest

Fixes rust-lang#88696
@bors bors closed this as completed in 674a3d5 May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
8 participants