oxidecomputer / oxidecomputer/ingot
Can't define headers in `fn` items (or doctests)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Code like the following which attempts to define a header within a fn breaks horribly:
fn hello() {
#[derive(Ingot)]
pub struct Broken {
pub fine: u8,
}
}
error: cannot find type `BrokenRef` in this scope
--> ingot/src/lib.rs:180:16
|
180 | pub struct Broken {
| ^^^^^^ names from parent modules are not accessible without an explicit import
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default
Although the types in question are not defined in a mod, all of them are referenced within the implementation-private module created to hold a header's chunk types and other generated artefacts.
An unfortunate victim of this is that doctests cannot include packet definitions, since they compile to a fn.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ingot/src/lib.rs around line 180 and inspect the derive-generated implementation-private module and its references. Reproduce the shown nested fn example, then verify that a header defined inside a function and in a doctest compiles without the BrokenRef resolution error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100