Carl, David (cc'ing rust-dev)_

Note that #6396 is about the 'self lifetime.

That may or may not be related to the rustc assertion failure that David mentions in one of his comments, but I think the bulk of his example does not use lifetimes at all. (So I'm assuming that his main issues about `impl Inner for @Inner` are something else.)

-Felix

On 12/09/2013 17:49, Carl Eastlund wrote:
This looks like bug 6396; function lifetimes don't work when named "self" apparently. Try naming it something else.

https://github.com/mozilla/rust/issues/6396

Carl Eastlund


On Thu, Sep 12, 2013 at 11:16 AM, David Brown <[email protected] <mailto:[email protected]>> wrote:

    Consider the following code
    ----------------------------------------------------------------------
    pub trait Inner {
       fn secret(&self);
    }

    // This doesn't seem to help.
    impl Inner for @Inner {
       fn secret(&self) { self.secret(); }
    }

    pub trait Wrapper {
       fn blort(&self);
    }

    impl<T: Inner> Wrapper for T {
       fn blort(&self) { self.secret(); }
    }

    // This function causes an assertion failure in rustc:
    // task <unnamed> failed at 'assertion failed: rp.is_none()',
    /home/davidb/rust/rust/src/librustc/middle/typeck/collect.rs:1108
    <http://collect.rs:1108>
    // fn blort<'self, T: Inner>(item: &'self @T) {
       // item.secret();
    // }

    struct Client;

    impl Inner for Client {
       fn secret(&self) { }
    }

    fn main() {
       let buf = @Client;
       buf.secret(); // Works

       // error: failed to find an implementation of trait Inner for
       // @Client
       buf.blort();
    }
    ----------------------------------------------------------------------

    This fails to compile:
     wrap.rs:32:4: 41:5 error: type `Client` does not implement any
    method in scope named `with_data`

    I'm modeling this after looking at the code in libstd/io.rs
    <http://io.rs>, but I'm
    not sure what I'm missing.

    I seem to be able to make it work by using 'impl Inner for @Client',
    but I'm not sure why that is required.

    Also, the commented out function causes an assertion failure in the
    compiler (it was a workaround attempt).

    Thanks,
    David
    _______________________________________________
    Rust-dev mailing list
    [email protected] <mailto:[email protected]>
    https://mail.mozilla.org/listinfo/rust-dev




_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev


--
irc: pnkfelix on irc.mozilla.org
email: {fklock, pnkfelix}@mozilla.com

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to