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

Coherence hint wrong for a blanked implementation bounded by a private trait #62194

Closed
nagisa opened this issue Jun 27, 2019 · 4 comments · Fixed by #62696
Closed

Coherence hint wrong for a blanked implementation bounded by a private trait #62194

nagisa opened this issue Jun 27, 2019 · 4 comments · Fixed by #62696
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nagisa
Copy link
Member

nagisa commented Jun 27, 2019

Given code like this:

trait Private {
}

impl<T: Private> Send for T {
}

the diagnostic will read as such:

error[E0119]: conflicting implementations of trait `std::marker::Send` for type `&_`:
 --> src/lib.rs:4:1
  |
4 | impl<T: Private> Send for T {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: conflicting implementation in crate `core`:
          - impl<T> std::marker::Send for &T
            where T: std::marker::Sync, T: ?Sized;
  = note: downstream crates may implement trait `Private` for type `&_`

the last note here is incorrect because the only thing that can implement this trait is the crate which declared the private Private trait.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 27, 2019
@fmckeogh
Copy link
Member

I'd like to work on this if that's ok? :)

@rustbot claim

@rustbot rustbot self-assigned this Jul 15, 2019
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 18, 2019
Check that trait is exported or public before adding hint

Closes rust-lang#62194.

This PR checks the `AccessLevels` of a trait to check whether adding the intercrate ambiguity hint is valid or not.

I am unsure of both the use of `.unwrap()` as well as removing hints for [downstream *and* [upstream](https://github.com/rust-lang/rust/blob/92b0f52584c9375505ecdefdd7855b93a5919d51/src/librustc/traits/select.rs#L112-L142).
@arielb1
Copy link
Contributor

arielb1 commented Aug 4, 2019

reopening because of #63145 - we need to come up with a fix to this issue that actually makes things clearer.

@arielb1 arielb1 reopened this Aug 4, 2019
@JohnTitor JohnTitor added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Apr 16, 2020
@donchoi25
Copy link

Hi! I'd like to work on this.
@rustbot claim

@rustbot rustbot assigned donchoi25 and unassigned rustbot Aug 28, 2020
@nico-abram
Copy link
Contributor

I don't know when this was fixed, but I see the following output on the playground (1.58) https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f0b6bc2bf8ccf0f3eb3f563f8b3287a1 :

trait Private {
}

unsafe impl<T: Private> Send for T {
}
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
 --> src/lib.rs:4:13
  |
4 | unsafe impl<T: Private> Send for T {
  |             ^ type parameter `T` must be used as the type parameter for some local type
  |
  = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
  = note: only traits defined in the current crate can be implemented for a type parameter

I think this can be closed

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 C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants