I tried this code:
struct Foo<'a,R>{
phantom: std::marker::PhantomData<&'a R>
}
#[derive(Debug)]
pub struct FooIter<'a, R>
{
reader: &'a mut R,
}
impl<R:'static> Iterator for FooIter<'_, R>
{
type Item = Foo<R>;
fn next(&mut self) -> Option<Self::Item> {
None
}
}
I expected to see this happen: Not sure, but not this
Instead, this happened:
Compiling playground v0.0.1 (/playground)
error[E0106]: missing lifetime specifier
--> src/lib.rs:12:21
|
12 | type Item = Foo<R>;
| ^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
|
12 | type Item<'a> = Foo<<'a>R>;
| ^^^^ ^^^^
This occurs both on my local machine and on the playground LINK
Looks like it returns an error with valid syntax at least on nightly, which just leads to GATs.
error[E0106]: missing lifetime specifier
--> src/lib.rs:12:21
|
12 | type Item = Foo<R>;
| ^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
|
12 | type Item<'a> = Foo<'a, R>;
| ^^^^ ^^^
rustc --version --verbose:
rustc 1.45.2 (d3fb005a3 2020-07-31)
binary: rustc
commit-hash: d3fb005a39e62501b8b0b356166e515ae24e2e54
commit-date: 2020-07-31
host: x86_64-pc-windows-msvc
release: 1.45.2
LLVM version: 10.0
Backtrace
<backtrace>
@drewkett it looks like this is fixed on nightly if I understand correctly? Is there a reason you opened a bug?
I think the reason is that the error recommends an unstable feature?
Also, even after enabling the GAT feature, the suggested code doesn't build: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=13b837b2fc863b1e1008d7ddbdf52b69
@drewkett it looks like this is fixed on nightly if I understand correctly? Is there a reason you opened a bug?
The main reason is that I wasn't sure of is that if something was fixed on nightly if that was necessarily intentional and necessarily would propagate to stable. I'm just not very familiar with exactly how nightly interacts with stable. And since I couldn't find this specific bug in an existing issue, I figured I'd raise it just so someone sees it.
I'm just not very familiar with exactly how nightly interacts with stable.
https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
But it sounds like there is a separate issue even on nightly.
Most helpful comment
I think the reason is that the error recommends an unstable feature?
Also, even after enabling the GAT feature, the suggested code doesn't build: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=13b837b2fc863b1e1008d7ddbdf52b69