Recently I saw all the advancements in Swift MMIO and the Embedded ecosystem so I decided to try them out. However I noticed that with recent main-snapshot builds, 2025-10-17 or later, I start getting different behavior for code that extends MMIO-defined structures. For example, here are some of the errors I get with my swift-stm32c011 project:
~/swift-stm32c011/Sources/STM32C011/Extensions/ADC+Helpers.swift:117:13: error: instance method 'modify' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'MMIO' was not imported by this file
115 | public func enable() {
116 | // Enable ADC
117 | self.cr.modify { rw in
| `- error: instance method 'modify' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'MMIO' was not imported by this file
118 | rw.raw.aden = 1
119 | }
~/swift-stm32c011/Sources/STM32C011/Extensions/ADC+Helpers.swift:118:10: error: property 'raw' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'MMIO' was not imported by this file
116 | // Enable ADC
117 | self.cr.modify { rw in
118 | rw.raw.aden = 1
| `- error: property 'raw' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'MMIO' was not imported by this file
119 | }
120 |
~/swift-stm32c011/Sources/STM32C011/Extensions/ADC+Helpers.swift:121:19: error: instance method 'read()' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'MMIO' was not imported by this file
119 | }
120 |
121 | while self.cr.read().raw.aden != 1 {
| `- error: instance method 'read()' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'MMIO' was not imported by this file
122 | // wait for ADC to be enabled/disabled
123 | }
This repeats for every other extension module I have. If I just add import MMIO to all the files that use MMIO structures it works. However I’m not sure if this is necessarily “correct”, or even what @_neverEmitIntoClient is. Should I be marking the embedded functions with @_neverEmitIntoClien instead of just doing import MMIO to fix it?
If you need more context about what’s in the file that is erroring out, the code is here. You can also see the rest of the project setup there too.
I am building my project with a toolset file instead of a Swift SDK as I was doing before. This seems to work fine with Swift 6.2 and main-snapshot versions up to 2025-10-16, which is why this looks like “new behavior” to me, or maybe it’s a bug.
Any ideas @Douglas_Gregor @rauhul ?