RFC: Replace all uses of TakeCell with OptionalCell#2360
RFC: Replace all uses of TakeCell with OptionalCell#2360hudson-ayers wants to merge 4 commits intotock:masterfrom
TakeCell with OptionalCell#2360Conversation
|
+1 from me, seems good to deprecate a type if Rust has evolved enough to no longer need it. |
|
@alistair23 This fails the QEMU CI, and I am trying to figure out why. When I locally run ..but I do not get the second debug statement ("Entering main loop"). There is the following note in hifive1's main.rs: // Need two debug!() calls to actually test with QEMU. QEMU seems to have
// a much larger UART TX buffer (or it transmits faster).
debug!("HiFive1 initialization complete.");
debug!("Entering main loop.");Do you know of a reason that the first debug might work, but the second does not? I do not see any issues running on Imix after a couple quick tests. |
|
actually, I am able to reproduce this on Imix...something in the console seems to have broken |
|
Ok, I think I jumped the gun here. The way |
#2360 had some nice insights that are likely valuable to newcomers digging into this part of Tock.
Pull Request Overview
This pull request makes some slight modifications to the
OptionalCellinterface, and then replaces all uses ofTakeCellwithOptionalCell. I have had a couple students in the past few months ask me why Tock included both whenTakeCellseems to just offer a subset of the functionality ofOptionalCell, and after looking into it I found that was in fact the case. I don't think it makes sense to use 2 nearly identical types when there doesn't seem to be a compelling reason for doing so.As part of doing so, this PR removes some functions that artificially required
T: CopywithinOptionalCell, by using the approach that previously existed intake_cell.rsto not do so. This makes it easier to useOptionalCellfor a broader range of types.I do not think this would have been possible when
TakeCellwas first created,Cellhas come a long way since then.There are a few downsides I see in this PR, which is why it is an RFC:
Instead of
#[feature(const_mut_refs)]only applying to thetock-cellscrate, it now applies to all crates that were previously usingTakeCell::empty(). This isn't really different in terms of how the code compiles, but means that it might be easier for developers to accidentally utilize this feature inchips/orcapsules/. However I am not actually that worried by this, as the new peripheral instantiation approach has removed any fundamental need forconstperipheral constructors anyway.I added a
put()method toOptionalCellthat does the same thing asinsert()becauseTakeCellandOptionalCellused different names for this operation (and my IDE's structural-search-and-replace was not working as I expected).Will probably make the tock 2.0 branch harder to merge in unless I apply this diff to it as well.
If anyone is curious, I made most of the rote changes using the following bash script:
Testing Strategy
This pull request was tested by compiling.
TODO or Help Wanted
N/A
Documentation Updated
\doc/Mutable_References.mdto remove allTakeCelldiscussion. Maybe we should expand theOptionalCelldiscussion though?Formatting
make prepush.