i509vcb[m] has quit [Quit: Idle timeout reached: 172800s]
dav1d1 has joined #rust-embedded
dav1d has quit [Ping timeout: 276 seconds]
dav1d1 is now known as dav1d
sroemer has joined #rust-embedded
sroemer has quit [Changing host]
sroemer has joined #rust-embedded
<Noah[m]>
diondokter the bigest problem with using rust errors here is that you cannot select the correct span because you cannot conjure it from thin air and then it just becomes annoying :/ otherwise I would love actual rust errors for something like this :)
<Ralph[m]>
(btw: does this tie in with the discussion whether the embedded WG should stay under the rust foundation? if it isn't associated with the foundation, would the book still be hosted on rust-lang.org?)
<JamesMunns[m]>
or, maybe t-lang docs, which also hosts some other formal/informal books
<JamesMunns[m]>
To answer the "when are they updated" question, iirc r-e org updates on every PR merge, doc r-l org updates whenever we submit a PR to update the submodule (it might be automatic on release now? not sure)
<JamesMunns[m]>
I'd probably treat the r-e org one as canonical, inclusion in the bookshelf is so people can get them with rustup doc (everyone who has rust installed has the embedded book already!)
<JamesMunns[m]>
if you type `rustup doc` in your console, it'll open the bookshelf on your PC, which includes the embedded book already locally :)
<Ralph[m]>
JamesMunns[m]: TIL!
<Ralph[m]>
thanks for your comprehensive answer!
Hallo124 has quit [Remote host closed the connection]
Hallo124 has joined #rust-embedded
dngrs[m] has joined #rust-embedded
<dngrs[m]>
<diondokter[m]> "Yeah, there's no Rust input" <- maybe report the error in the KDL? Not very helpful to rustc I suppose but file:line could still be beneficial for the user
<dngrs[m]>
* suppose but `file:line, * file:line` could
Hallo124 has quit [Remote host closed the connection]
Hallo124 has joined #rust-embedded
<diondokter[m]>
<dngrs[m]> "maybe report the error in the..." <- Yes, I think that's the plan now. Just print the errors and warnings to stdout or stderr so they appear next to the compiler errors/warnings
DominicFischer[m has quit [Quit: Idle timeout reached: 172800s]
Hallo124 has quit [Remote host closed the connection]
Hallo124 has joined #rust-embedded
DominicFischer[m has joined #rust-embedded
<DominicFischer[m>
<JamesMunns[m]> "that's useful if you have say..." <- Can this be done without the boxing? I'm now considering this option for control transfers 😄. I'm hoping a `DynPinList<dyn MyTrait>` is feasible without alloc.
<JamesMunns[m]>
<JamesMunns[m]> "that's useful if you have say..." <- Well, you can get something LIKE that, using unsafe vtable methods, which is generally fine if you are only using that interface inside of library code (e.g. not user funcs)
<JamesMunns[m]>
<JamesMunns[m]> "that's useful if you have say..." <- you might be able to put an `&mut dyn Trait` in the node? Not sure offhand, would have to try
<DominicFischer[m>
<JamesMunns[m]> "you might be able to put an `&..." <- I think this would force me to declare a lifetime on the T in PinList
<JamesMunns[m]>
<JamesMunns[m]> "you might be able to put an `&..." <- Ah yes, it would, which wouldn't work
<JamesMunns[m]>
<JamesMunns[m]> "you might be able to put an `&..." <- (unless that lifetime was 'static, e.g. you use a staticcell)
<JamesMunns[m]>
<JamesMunns[m]> "you might be able to put an `&..." <- As @dngrs linked, I think you could make a "proxy" struct that impls the trait (or just a struct has safe wrapper methods of the unsafe vtable fns), but I dunno exactly what you need/want, API wise
<JamesMunns[m]>
But yeah, this is more like what ergot/cfg-noodle do, using the other half of the type erasure, to give you something morally equivalent to `Mutex<Vec<dyn Trait>>`, but currently I don't have a pleasant wrapper for the second half of that.
<JamesMunns[m]>
It's very possible to get something that BEHAVES that way, even if it's not as directly pleasant to use. Very open to suggestions on how to make an actual library API for that, instead of a squishy unsafe pattern
<DominicFischer[m>
Ah thanks, that helps, I think I have an idea of how to do this. Or at least what I want the API to look like
<JamesMunns[m]>
You probably can't use PinList for type erasure, because you need to iterate over `NonNull<NodeHeader>` types, so you can do the type-punning in a way that is sound wrt provenance. cordyceps can do it, but pinlist can't
<JamesMunns[m]>
(PinList gives you *references*, which are only valid for the T they reference, whereas `NonNull<T>` can be casted to `NonNull<StartsWithTButHasMore>` as long as it was *created* from a `StartsWithTButHasMore` ptr
<DominicFischer[m>
let list: DynPinList<dyn MyTrait> = DynPinList::new();
<JamesMunns[m]>
yeah, maybe, you might get yourself in trouble with using references, because you want all the nodes (regardless of their actual type) to START with a common header you can use for iteration (and erasing generics/lifetimes), but once you make a REFERENCE of the header, you've truncated the provenance to only the header and not the entire object
Hallo124 has quit [Remote host closed the connection]
<JamesMunns[m]>
definitely poke around how cfg-noodle and ergot do it. I do it in a VERY specific way for VERY specific soundness reasons.
Hallo124 has joined #rust-embedded
<JamesMunns[m]>
(there's probably other ways, but this is one way I'm fairly certain is sound)
<JamesMunns[m]>
you also CAN'T just turn the &mut into the NonNull, because the &mut MyHeader ONLY has provenance for that range, so turning it into a ptr and then going out of range is still unsound
<JamesMunns[m]>
@Dominic Fischer ^
<JamesMunns[m]>
since PinList ALWAYS creates references, you'd need to change pinlist a lot, to always use RawIter from cordyceps instead of Iter/IterMut/IterPinMut
<JamesMunns[m]>
but yeah, maybe as a totally separate PinListDyn or so.
<DominicFischer[m>
Oh yeah, I 100% meant having a separate type from PinList.
SanchayanMaity has quit [Quit: Connection closed for inactivity]
Hallo124 has quit [Remote host closed the connection]
Hallo124 has joined #rust-embedded
jannic[m] has quit [Quit: Idle timeout reached: 172800s]
sroemer has quit [Quit: WeeChat 4.5.2]
jasperw has quit [Read error: Connection reset by peer]
jasperw- has joined #rust-embedded
RockBoynton[m] has joined #rust-embedded
<RockBoynton[m]>
what is the recommended way to link data to specific RAM regions, now that static mut is heavily discouraged?
<JamesMunns[m]>
whatcha wanna do with that region of RAM?
<JamesMunns[m]>
In general, an issue with putting stuff outside of RAM is that the default init won't initialize it.
<JamesMunns[m]>
So: you can either explicitly make it uninit, and init it before you use it (the `grounded` crate can help with this), use pre-init (probably with some asm) to init it, or do your own init (outside of cmrt)
<RockBoynton[m]>
Stick some large static data structure in it
<RockBoynton[m]>
Right, before I would use static mut with MaybeUninit and init in my application init code
<DominicFischer[m>
Putting aside the use nightly (which could be skipped by doing the lambda thing), I love the way the API turned out.
<DominicFischer[m>
Now tell me why it's unsound 😂
<DominicFischer[m>
(Check out the tests at the bottom first)
<JamesMunns[m]>
looks neat!
<JamesMunns[m]>
I'd probably need to poke it a bit to form a better opinion, but looks promising!
<JamesMunns[m]>
you can try running your tests with miri to see if it immediately objects to something :)
<DominicFischer[m>
Ah, I've never used miri, I'll give it a shot
<DominicFischer[m>
<JamesMunns[m]> "you can try running your tests..." <- `cargo miri test` looks clean. Are there any recommended flags I should pass or is the default the strictest?
<JamesMunns[m]>
default is reasonable imo
<JamesMunns[m]>
it's a sanitizer, so it can only call out ub it sees at runtime
<JamesMunns[m]>
but if your basic tests pass, that's a good sign!
Hallo124 has quit [Remote host closed the connection]
Hallo124 has joined #rust-embedded
therealprof[m] has joined #rust-embedded
<therealprof[m]>
<JamesMunns[m]> "yeah, that tracks" <- The most annoying thing above sigrok is (maybe was) the build process. Now that I mentioned that I'll probably start having nightmares again...