You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Trait generic over lifetime causes uses of associated types to fail to infer properly inside default methods #24338
A-inferenceArea: Type inferenceA-lifetimesArea: Lifetimes / regionsA-trait-systemArea: Trait systemC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.P-lowLow priority
traitDictLike<'a>{typeItemsIterator:Iterator<Item=u8>;fnitems(&self) -> Self::ItemsIterator;fnget(&self){for k inself.items(){}// get(self)}}// fn get<'a, X: ?Sized + DictLike<'a>>(x: &X) { for k in x.items() {} }fnmain(){}
<anon>:7:13: 7:14 error: unable to infer enough type information about `_`; type annotations required [E0282]
<anon>:7 for k in self.items() {}
^
Strangely, switching to the commented out form works fine, i.e. just moving the body of the code out of the default method.
Nominating since I am unsure how important we regard inference issues like this to be.
Just thought I'd mention I ran into this bug just now while writing a trait with some associated iterator type - frustrating errors, but managed to side-step it with @huonw 's workaround here.
A-inferenceArea: Type inferenceA-lifetimesArea: Lifetimes / regionsA-trait-systemArea: Trait systemC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.P-lowLow priority
Activity
pnkfelix commentedon Apr 16, 2015
Probably "just-a-bug"; P-low, not 1.0.
eefriedman commentedon Aug 9, 2015
Testcase without for loop desugaring:
mitchmindtree commentedon Sep 14, 2015
Just thought I'd mention I ran into this bug just now while writing a trait with some associated iterator type - frustrating errors, but managed to side-step it with @huonw 's workaround here.
malbarbo commentedon Jun 23, 2016
The test cases in this issue compile fine since rustc 1.4 (Playground for rustc stable).
malbarbo commentedon Sep 30, 2016
Please add E-needstest tag so one can write a regression test an the issue be closed.
add test for rust-lang#24338
Auto merge of #54823 - euclio:needs-test, r=alexcrichton