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

E0603 "note: the trait … is defined here" not showing any detail #100704

Closed
kpreid opened this issue Aug 17, 2022 · 4 comments
Closed

E0603 "note: the trait … is defined here" not showing any detail #100704

kpreid opened this issue Aug 17, 2022 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kpreid
Copy link
Contributor

kpreid commented Aug 17, 2022

Given the following code:

type Foo = Box<dyn std::pin::Unpin>;

The current output is:

error[E0603]: trait `Unpin` is private
 --> src/lib.rs:1:30
  |
1 | type Foo = Box<dyn std::pin::Unpin>;
  |                              ^^^^^ private trait
  |
note: the trait `Unpin` is defined here

The note is useless and confusing since it doesn't say what “here” is. Better output would be any of:

  • A suggestion to use the public path (std::marker::Unpin in this case) would be most helpful to anyone using an unfamiliar type (this could occur in third-party libraries as well as std).
  • Include file and code snippet (this might depend on having rust-src installed in this case?)
  • Hide the note entirely if nothing better can be said

Occurs on stable 1.63 and current nightly, in the Rust Playground.

Previous similar issue: #89159

@kpreid kpreid added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 17, 2022
@compiler-errors
Copy link
Member

Probably just need to check the span of the note with rustc_span::DUMMY_SP (there's Span::is_dummy to do this)

@compiler-errors
Copy link
Member

We also probably have the visible_parent_map and could use that to suggest the correct path here.... I think? At least for foreign traits that we have the cmeta for.

@jieyouxu
Copy link
Member

jieyouxu commented Jun 2, 2023

This seems to have been fixed on stable (1.70.0):

error[E0603]: trait `Unpin` is private
   --> test.rs:1:30
    |
1   | type Foo = Box<dyn std::pin::Unpin>;
    |                              ^^^^^ private trait
    |
note: the trait `Unpin` is defined here
   --> /home/jieyouxu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/pin.rs:387:28
    |
387 | use crate::marker::{Sized, Unpin};
    |                            ^^^^^

error: aborting due to previous error
rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2

@compiler-errors
Copy link
Member

👍

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 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

3 participants