<p dir="auto">I think it would be great if this sort of thing worked:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="trait Shizzle {
    static fn shizzle();
}

trait Shozzle : Shizzle {
    static fn shizzle() {
        io::println(~&quot;shizzle! &quot; + shozzle::&lt;self&gt;());
    }
    static fn shozzle() -&gt; ~str;
}

impl int : Shozzle {
    static fn shozzle() -&gt; ~str { ~&quot;i'm an int!&quot; }
}

fn main() {
    shizzle::&lt;int&gt;();
}"><pre class="notranslate"><code class="notranslate">trait Shizzle {
    static fn shizzle();
}

trait Shozzle : Shizzle {
    static fn shizzle() {
        io::println(~"shizzle! " + shozzle::&lt;self&gt;());
    }
    static fn shozzle() -&gt; ~str;
}

impl int : Shozzle {
    static fn shozzle() -&gt; ~str { ~"i'm an int!" }
}

fn main() {
    shizzle::&lt;int&gt;();
}
</code></pre></div>
<p dir="auto">Currently it fails with this error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test-trait-inheritance.rs:12:4: 12:23 error: duplicate definition of value shizzle
test-trait-inheritance.rs:12     static fn shizzle() {
                                 ^~~~~~~~~~~~~~~~~~~
test-trait-inheritance.rs:5:4: 5:23 note: first definition of value shizzle here:
test-trait-inheritance.rs:5     static fn shizzle();
                                ^~~~~~~~~~~~~~~~~~~
error: aborting due to previous error"><pre class="notranslate"><code class="notranslate">test-trait-inheritance.rs:12:4: 12:23 error: duplicate definition of value shizzle
test-trait-inheritance.rs:12     static fn shizzle() {
                                 ^~~~~~~~~~~~~~~~~~~
test-trait-inheritance.rs:5:4: 5:23 note: first definition of value shizzle here:
test-trait-inheritance.rs:5     static fn shizzle();
                                ^~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
</code></pre></div>
<p dir="auto">When generating a public fn with <code class="notranslate">impl</code> code, the <code class="notranslate">pub</code> keyword is ignored, and the resulting function is private (and raises a <code class="notranslate">dead_code</code> warning).</p>
<p dir="auto">It is also not possible to move the pub keyword into the macro, as it then causes an error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" expected one of `extern`, `fn`, or `unsafe`, found `pub`"><pre class="notranslate"><code class="notranslate"> expected one of `extern`, `fn`, or `unsafe`, found `pub`
</code></pre></div>
<p dir="auto">Related issues: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="10298360" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/4621" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/4621/hovercard" href="https://github.com/rust-lang/rust/issues/4621">#4621</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="25236308" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/11403" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/11403/hovercard" href="https://github.com/rust-lang/rust/issues/11403">#11403</a></p>
<p dir="auto">The workaround suggested in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="10298360" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/4621" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/4621/hovercard" href="https://github.com/rust-lang/rust/issues/4621">#4621</a> (generating multiple <code class="notranslate">impl</code> blocks) is  unsatisfactory for public impl functions, as it does not allow for documenting the function, and produces doc output with repeated <code class="notranslate">impl Type</code> headers for each function.</p>
<p dir="auto">The use case for this is generating code for library bindings.</p>
<p dir="auto">The following code reproduces the issue:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="macro_rules! defn {
    ($n:ident) =&gt; (
        fn $n (&amp;self) -&gt; i32 { 1 } )
}

#[derive(Copy)]
pub struct S;

impl S {
    pub defn!(f);
}


#[cfg(test)]
mod tests {
    use super::S;

    #[test]
    fn test_f() {
        let s=S;
        assert_eq!(1, s.f());
    }
}"><pre class="notranslate"><code class="notranslate">macro_rules! defn {
    ($n:ident) =&gt; (
        fn $n (&amp;self) -&gt; i32 { 1 } )
}

#[derive(Copy)]
pub struct S;

impl S {
    pub defn!(f);
}


#[cfg(test)]
mod tests {
    use super::S;

    #[test]
    fn test_f() {
        let s=S;
        assert_eq!(1, s.f());
    }
}
</code></pre></div>