Skip to content

Disappearing error in Rust 1.74 #138982

Open
@jonathanpallant

Description

@jonathanpallant

I tried this code:

$ git clone https://github.com/knurling-rs/derive-mmio
$ cd derive-mmio
$ git checkout weird-pub-issue
$ cargo +1.73 run --example array
...
error[E0446]: private type `Uart` in public interface
 --> examples/array.rs:1:10
  |
1 | #[derive(derive_mmio::Mmio)]
  |          ^^^^^^^^^^^^^^^^^ can't leak private type
2 | #[repr(C)]
3 | struct Uart {
  | ----------- `Uart` declared as private
  |
  = note: this error originates in the derive macro `derive_mmio::Mmio` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0446`.
error: could not compile `derive-mmio` (example "array") due to previous error
$ cargo +1.74 run --example array
    Finished dev [unoptimized + debuginfo] target(s) in 4.20s
     Running `target/debug/examples/array`

I expected to see this happen: Both 1.73 and 1.74 would report the same error?

Instead, this happened: 1.74 builds without an error.

Is this because the offending function (pub fn ptr() -> PrivateType) was macro generated?

I think the fix is to change our macro so that fn ptr() is only pub if PrivateType is pub. But it was weird that the error went away.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-discussionCategory: Discussion or questions that doesn't represent real issues.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions