Skip to content

Internal compiler error passing an iterator as a parameter. #10467

Closed

Description

@dradtke

While practicing my Rust skills by writing a version of GNU cat, I ran into an error that told me to report the results here. The file and the error are included in this gist:

https://gist.github.com/dradtke/7458284

The error only occurs when I try to have cat_files accept an Iterator. If I refactor the code so that it accepts a borrowed pointer to an owned vector of owned strings, then it works.

Activity

  1. alexcrichton commented on Nov 13, 2013

    @alexcrichton
    Member

    What version of the compiler were you running this with? If you updated to the most recent version of master, I think that you'll probably see a better error (not certain, just a guess from looking at the program)

  2. huonw commented on Nov 13, 2013

    @huonw
    Contributor

    With rustc 0.9-pre (825b127 2013-11-12 18:56:13 -0800), I see

    10467.rs:5:4: 5:13 error: internal compiler error: Cannot relate bound region: ReLateBound(6, BrNamed(syntax::ast::DefId{crate: 0, node: 20}, self)) <= ReInfer(70)
    This message reflects a bug in the Rust compiler. 
    We would appreciate a bug report: https://github.com/mozilla/rust/wiki/HOWTO-submit-a-Rust-bug-report
    10467.rs:5     cat_files(&args.iter().skip(1));
                   ^~~~~~~~~
    task 'rustc' failed at 'explicit failure', /home/huon/rust/src/libsyntax/diagnostic.rs:75
    task '<main>' failed at 'explicit failure', /home/huon/rust/src/librustc/lib.rs:396
    

    when running on the reduced

    fn cat_files<'self, T: Iterator<&'self ~str>>(_: &T) {}
    
    fn main() {
        let args = [~"foo"];
        cat_files(&args.iter().skip(1));
    }

    It's the same error message as #10391, but appears to be a possibly different cause.

  3. nikomatsakis commented on Nov 14, 2013

    @nikomatsakis
    Contributor

    cc me. I've been negligent and not looked at #10391 yet, I'll see if I can peel off some time today to look at both of these.

  4. nikomatsakis commented on Nov 15, 2013

    @nikomatsakis
    Contributor

    This is in fact a dup of #5121

  5. nikomatsakis commented on Nov 15, 2013

    @nikomatsakis
    Contributor

    In particular we don't (yet) support a function like:

    fn cat_files<'self, T: Iterator<&'self ~str>>(_: &T) {}
    

    because 'self appears within the trait bound for T.

  6. added a commit that references this issue on Mar 10, 2023
  7. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions