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]> 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, 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]
> https://mail.mozilla.org/**listinfo/rust-dev<https://mail.mozilla.org/listinfo/rust-dev>
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to