-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Send impl error message is too smart #21793
Comments
cc @Manishearth |
I think the Send is not implemented for Rc, you may use Arc instead.
It would work. |
That's not the issue here, the issue is that the error is complaining directly about |
This is particularly bad when its some type hidden deep in internals that is causing the problem, since it can be very non-obvious where the non- use std::sync::mpsc::Sender;
struct Foo {
x: Sender<()>,
}
struct SomethingComplicated; /* lots of fields ... */
struct Bar {
y: SomethingComplicated,
z: Vec<Foo>,
// etc.
}
fn test_sync<T: Sync>() {}
fn main() {
test_sync::<Bar>();
}
It would be nice to do a "call stack", maybe a little like:
(All the In that model, I'm stopping at crate boundaries, but it may also make sense to continue to stop at the first explicit negative impl. |
At some point @flaper87 and I did include a full stack trace. I'm not sure at what point it got lost. |
@nikomatsakis we did it when we landed the negative trait implementation support. I'll check if that code changed but in theory it should still be there. |
If you point me to it I can probably reimplement it. |
I got some similar errors when playing with OIBIT
(I'm using this code for a heap-size deriving which needed an overridable blanket impl) Instead of telling me that |
On nightly, the error message is
Slightly verbose (e.g., we can avoid repeating the span every time) but I think this is solved. |
#28378 has a testcase that shows poor behaviour on a rustc from ~12 days ago; is that any better now? |
I guess we should just not print the span multiple times and we are golden. In general, compiler stack traces are not good error messages, but the stack traces here should be short most times and I can't think of a better message. I mean, after trimming, it would be
|
new error style: ``` path.rs:4:6: 4:7 error: the trait `core::marker::Sized` is not implemented for the type `[u8]` [E0277] path.rs:4 fn f(p: Path) {} ^ path.rs:4:6: 4:7 help: run `rustc --explain E0277` to see a detailed explanation path.rs:4:6: 4:7 note: `[u8]` does not have a constant size known at compile-time path.rs:4:6: 4:7 note: required because it appears within the type `std::sys::os_str::Slice` path.rs:4:6: 4:7 note: required because it appears within the type `std::ffi::os_str::OsStr` path.rs:4:6: 4:7 note: required because it appears within the type `std::path::Path` path.rs:4:6: 4:7 note: all local variables must have a statically known size path.rs:7:5: 7:36 error: the trait `core::marker::Send` is not implemented for the type `alloc::rc::Rc<()>` [E0277] path.rs:7 foo::<BTreeMap<Rc<()>, Rc<()>>>(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ path.rs:7:5: 7:36 help: run `rustc --explain E0277` to see a detailed explanation path.rs:7:5: 7:36 note: `alloc::rc::Rc<()>` cannot be sent between threads safely path.rs:7:5: 7:36 note: required because it appears within the type `collections::btree::node::Node<alloc::rc::Rc<()>, alloc::rc::Rc<()>>` path.rs:7:5: 7:36 note: required because it appears within the type `collections::btree::map::BTreeMap<alloc::rc::Rc<()>, alloc::rc::Rc<()>>` path.rs:7:5: 7:36 note: required by `foo` error: aborting due to 2 previous errors ``` This improves the rust-lang#21793/rust-lang#23286 situation
…sakis new error style: ``` path.rs:4:6: 4:7 error: the trait `core::marker::Sized` is not implemented for the type `[u8]` [E0277] path.rs:4 fn f(p: Path) {} ^ path.rs:4:6: 4:7 help: run `rustc --explain E0277` to see a detailed explanation path.rs:4:6: 4:7 note: `[u8]` does not have a constant size known at compile-time path.rs:4:6: 4:7 note: required because it appears within the type `std::sys::os_str::Slice` path.rs:4:6: 4:7 note: required because it appears within the type `std::ffi::os_str::OsStr` path.rs:4:6: 4:7 note: required because it appears within the type `std::path::Path` path.rs:4:6: 4:7 note: all local variables must have a statically known size path.rs:7:5: 7:36 error: the trait `core::marker::Send` is not implemented for the type `alloc::rc::Rc<()>` [E0277] path.rs:7 foo::<BTreeMap<Rc<()>, Rc<()>>>(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ path.rs:7:5: 7:36 help: run `rustc --explain E0277` to see a detailed explanation path.rs:7:5: 7:36 note: `alloc::rc::Rc<()>` cannot be sent between threads safely path.rs:7:5: 7:36 note: required because it appears within the type `collections::btree::node::Node<alloc::rc::Rc<()>, alloc::rc::Rc<()>>` path.rs:7:5: 7:36 note: required because it appears within the type `collections::btree::map::BTreeMap<alloc::rc::Rc<()>, alloc::rc::Rc<()>>` path.rs:7:5: 7:36 note: required by `foo` error: aborting due to 2 previous errors ``` This improves the #21793/#23286 situation r? @nikomatsakis
…sakis new error style: ``` path.rs:4:6: 4:7 error: the trait `core::marker::Sized` is not implemented for the type `[u8]` [E0277] path.rs:4 fn f(p: Path) {} ^ path.rs:4:6: 4:7 help: run `rustc --explain E0277` to see a detailed explanation path.rs:4:6: 4:7 note: `[u8]` does not have a constant size known at compile-time path.rs:4:6: 4:7 note: required because it appears within the type `std::sys::os_str::Slice` path.rs:4:6: 4:7 note: required because it appears within the type `std::ffi::os_str::OsStr` path.rs:4:6: 4:7 note: required because it appears within the type `std::path::Path` path.rs:4:6: 4:7 note: all local variables must have a statically known size path.rs:7:5: 7:36 error: the trait `core::marker::Send` is not implemented for the type `alloc::rc::Rc<()>` [E0277] path.rs:7 foo::<BTreeMap<Rc<()>, Rc<()>>>(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ path.rs:7:5: 7:36 help: run `rustc --explain E0277` to see a detailed explanation path.rs:7:5: 7:36 note: `alloc::rc::Rc<()>` cannot be sent between threads safely path.rs:7:5: 7:36 note: required because it appears within the type `collections::btree::node::Node<alloc::rc::Rc<()>, alloc::rc::Rc<()>>` path.rs:7:5: 7:36 note: required because it appears within the type `collections::btree::map::BTreeMap<alloc::rc::Rc<()>, alloc::rc::Rc<()>>` path.rs:7:5: 7:36 note: required by `foo` error: aborting due to 2 previous errors ``` Fixes #21793 Fixes #23286 r? @nikomatsakis
The lack of an impl of Send for Rc is the problem, but the more pertinent problem is that BTreeMap itself is not Send. The Rc detail is a great piece of additional information, though.
The text was updated successfully, but these errors were encountered: