-
Notifications
You must be signed in to change notification settings - Fork 242
Spawn local without attribute #1116
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
base: master
Are you sure you want to change the base?
Conversation
9feaf99 to
623d8b1
Compare
|
Well this breaks a lot of inference stuff, so probably not a great solution... |
623d8b1 to
669a362
Compare
| incrementer::spawn(cx.local.wait_queue).ok().unwrap(); | ||
| waiter::spawn(cx.local.wait_queue).ok().unwrap(); | ||
| incrementer::spawn(&*cx.local.wait_queue).ok().unwrap(); | ||
| waiter::spawn(&*cx.local.wait_queue).ok().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change. For some reason the compiler can not auto demote &mut T to &T when generics are involved (not sure of the rules here).
Without the above fix, we get
error[E0271]: type mismatch resolving `<&mut DoublyLinkedList<Waker> as Dummy>::T == &DoublyLinkedList<Waker>`
--> examples/wait-queue.rs:31:28
|
31 | incrementer::spawn(cx.local.wait_queue).ok().unwrap();
| ------------------ ^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<&mut DoublyLinkedList<Waker> as Dummy>::T == &DoublyLinkedList<Waker>`
| |
| required by a bound introduced by this call
|
note: expected this to be `&'static DoublyLinkedList<Waker>`
--> examples/wait-queue.rs:11:1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying AfoHT's link on matrix: https://doc.rust-lang.org/reference/type-coercions.html#r-coerce.types.mut-reborrow
7809d1a to
6296126
Compare
6296126 to
d241893
Compare
rtic/src/export/dummy.rs
Outdated
| // TODO: What should we name this? | ||
|
|
||
| /// Dummy trait which will only ever be implemented where type T is Self | ||
| pub trait Dummy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions for what to call this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used because we can not have a function with a where clause which requires a concrete type to be Send if that type is not Send. The compiler will error out on us.
However hiding that behind a dummy trait which is only implemented for that same type then we defer the error to when the user tries to call the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with TaskArg for now
This is an alternative to #1108 for solving #1107 that does not require the
local_taskattribute.Breaking change
Note this is a breaking change.
Inference will no longer accept
So that would have to be changed to
Similarly with
&mut Tfor task argument no longer auto converted into&T.instead do