Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for loop over trait that inherits Iterator gives error #16394

Closed
detzgk opened this issue Aug 10, 2014 · 2 comments
Closed

for loop over trait that inherits Iterator gives error #16394

detzgk opened this issue Aug 10, 2014 · 2 comments

Comments

@detzgk
Copy link

detzgk commented Aug 10, 2014

If a trait inherits Iterator, it used to be (rust-0.11) usable as the expression in a for loop. In recent nightlies (a1429bc 2014-08-08 21:36:11 +0000) this seems to be broken.

pub trait Foo : Iterator<int> {
}

fn main() {
    let f : &Foo;
    for item in f {
    }
}

This gives me:

test.rs:6:14: 6:15 error: for loop expression does not implement the Iterator trait
test.rs:6 for i in f {

@detzgk
Copy link
Author

detzgk commented Aug 10, 2014

sfackler on IRC says some work was done on for loops recently.
/cc @pcwalton

@alexcrichton
Copy link
Member

I believe that this is technically correct as the trait object &Foo does not implement the Iterator trait. This is similar to how the Writer trait is not implemented for &mut Writer, but rather there is a manual implementation for it. The fix you'll need is impl<'a> Iterator<int> for &'a Foo { /* ... */ }

For now, however, this is working as intended, so I'm going to close this.

matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue Feb 5, 2024
…ans, r=Veykril

internal: add some `tracing` to {Request, Notification}Dispatch

Some of the tracing config would need to be changed in order to benefit more from this (especially `.with_span_events(FmtSpan::CLOSE)`), which provides span events like the following:

```
2024-01-18T02:41:06.675779Z  INFO request{method="textDocument/codeLens" request_id=RequestId(I32(17))}: rust_analyzer::dispatch: close time.busy=61.8µs time.idle=5.29µs
```

I dunno if y'all need `LoggerFormatter` in here, but if you don't, I'd be happy to yeet it out of rust-analyzer. In any case, this provided a pretty decent amount of information in the logs, and I can expand this as needed or we can land this PR and expand later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants