Skip to content

Bug report #40773

Closed
Closed
@U007D

Description

@U007D

fn main() {
let vec_str = vec!["a", "b", "c"];
println!("vec_str: {:?}", vec_str.iter().foo("b").unwrap());
println!("vec_str: {:?} again", vec_str.iter().foo("b").unwrap());
println!();

/* let vec_int = vec![1, 2, 3];
println!("vec_int: {:?}", vec_int.iter().foo(2).unwrap());
println!("vec_int: {:?} again", vec_int.iter().foo(2).unwrap());
println!();
let arr_int = [1, 2, 3];
println!("arr_int: {:?}", arr_int.iter().foo(2).unwrap());
println!("arr_int: {:?} again", arr_int.iter().foo(2).unwrap());
println!();
*/
// println!("Iter: {:?}", std::env::args().foo("./out".to_string()));
// println!("Iter: {:?} again", std::env::args().foo("./out".to_string()));
}
trait IterExtensions where Self: Iterator {
fn foo(&self, param: &str) -> OptionSelf::Item;
}
impl IterExtensions for Iterator<Item = T> where T: Iterator<Item = T>,
Self::Item: PartialEq {
fn foo(&self, param: &str) -> OptionSelf::Item {
self.skip_while(|elem| *elem != &param)
.next()
}
}
/*trait IterExtensions: Iterator {
fn foo(self, param: T) -> OptionSelf::Item
where Self: Iterator + Sized,
for<'a> Self::Item: PartialEq<&'a T> {
foo(self, param)
}
}
impl<T: ?Sized> IterExtensions for T where T: Iterator {}
fn foo<I, T>(iter: I, param: T) -> Option<I::Item>
where I: Iterator,
for<'a> I::Item: PartialEq<&'a T> {
iter.skip_while(|elem| *elem != &param)
.next()
}
*/
rustc 1.16.0 (30cf806 2017-03-10)
error: Self type is used before it's determined
--> :26:43
|
26 | Self::Item: PartialEq {
| ^^^^^^^^^^

error: internal compiler error: /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/ty/mod.rs:1849: No def'n found for DefId { krate: CrateNum(0), node: DefIndex(9) => rust_out/4089d7c8b778d88cec885baf7b69e6df-exe::{{impl}}[0] } in tcx.impl_trait_refs

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

thread 'rustc' panicked at 'Box', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc_errors/lib.rs:416
note: Run with RUST_BACKTRACE=1 for a backtrace.

Compilation failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions