Skip to content

ICE with polymorphic regioned struct #3154

Closed

Description

@bblum
struct thing<Q> {
    x: &Q;
    new(x: &Q) { self.x = x; }
}

fn main() {
    thing(&());
}

Backtrace:

#0  upcall_fail (expr=0x7fffe4380fc0 "option::get none",  ...)
#1  0x00007ffff5c978c3 in middle::ty::subst::do_subst::anon ()
#2  0x00007ffff5c9529a in middle::ty::fold_regions_and_ty ()
#3  0x00007ffff5c976ff in middle::ty::subst::do_subst ()
#4  0x00007ffff5ba5363 in middle::ty::subst ()
#5  0x00007ffff5b6c5d7 in middle::ty::lookup_field_type ()
#6  0x00007ffff5b6c459 in middle::trans::type_of::type_of::anon ()
#7  0x00007ffff5b6c395 in vec::map5742 ()
#8  0x00007ffff5b5ee95 in middle::trans::type_of::type_of ()
#9  0x00007ffff5b5d3d3 in middle::trans::type_of::type_of ()
#10 0x00007ffff5b67c24 in middle::trans::type_of::type_of_fn ()
#11 0x00007ffff5b92502 in middle::trans::base::monomorphic_fn ()
#12 0x00007ffff6028c20 in __morestack ()
#13 0x00007ffff5bbfe8e in middle::trans::base::lval_static_fn_inner ()
#14 0x00007ffff5bbf68d in middle::trans::base::lval_static_fn ()
#15 0x00007ffff5bc2353 in middle::trans::base::trans_var ()
#16 0x00007ffff5bc1fec in middle::trans::base::trans_path ()
#17 0x00007ffff5bc4f85 in middle::trans::base::trans_callee ()
#18 0x00007ffff5bd3b34 in middle::trans::base::trans_call_inner::anon ()
#19 0x00007ffff5bd3939 in middle::trans::base::with_scope ()
#20 0x00007ffff5b9e3fb in middle::trans::base::trans_call_inner ()
#21 0x00007ffff5bcb7dd in middle::trans::base::trans_call ()
#22 0x00007ffff5bd91c0 in middle::trans::base::trans_expr::unrooted ()
#23 0x00007ffff5b9ee23 in middle::trans::base::trans_expr ()
#24 0x00007ffff5be31d6 in middle::trans::base::trans_stmt ()
#25 0x00007ffff5ba72d1 in middle::trans::base::trans_block ()
#26 0x00007ffff5beb805 in middle::trans::base::trans_closure ()
#27 0x00007ffff5bb108c in middle::trans::base::trans_fn ()

Activity

  1. bblum commented on Aug 9, 2012

    @bblum
    ContributorAuthor

    I had to work around this here: 604e4ad#L0R74

  2. catamorphism commented on Dec 6, 2012

    @catamorphism
    Contributor

    As of b60a0be, this fails with a borrow check error, rather than ICEing.

    struct thing<Q> {
        x: &Q
    }
    
    fn thing<Q>(x: &Q) -> thing<Q> {
        thing{ x: x }
    }
    
    fn main() {
        thing(&());
    }
    

    yields:

    test/run-pass/issue-3154.rs:6:4: 6:9 error: cannot infer an appropriate lifetime due to conflicting requirements
    test/run-pass/issue-3154.rs:6     thing{ x: x }
                                      ^~~~~
    test/run-pass/issue-3154.rs:5:31: 7:1 note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the block at 5:31...
    test/run-pass/issue-3154.rs:5 fn thing<Q>(x: &Q) -> thing<Q> {
    test/run-pass/issue-3154.rs:6     thing{ x: x }
    test/run-pass/issue-3154.rs:7 }
    test/run-pass/issue-3154.rs:6:14: 6:15 note: ...due to the following expression
    test/run-pass/issue-3154.rs:6     thing{ x: x }
                                                ^
    test/run-pass/issue-3154.rs:5:31: 7:1 note: but, the lifetime must be valid for the anonymous lifetime #2 defined on the block at 5:31...
    test/run-pass/issue-3154.rs:5 fn thing<Q>(x: &Q) -> thing<Q> {
    test/run-pass/issue-3154.rs:6     thing{ x: x }
    test/run-pass/issue-3154.rs:7 }
    test/run-pass/issue-3154.rs:6:4: 6:9 note: ...due to the following expression
    test/run-pass/issue-3154.rs:6     thing{ x: x }
                                      ^~~~~
    
  3. bblum commented on Dec 7, 2012

    @bblum
    ContributorAuthor

    I'm not convinced a borrow-check error is grounds for closing this. Tentatively reopening.

    Would you mind trying to merge struct SemRelease and struct SemAndSignalRelease in libstd/sync.rs? They should be able to be merged into a single struct SemRelease<Q> { sem: &Sem<Q> } and likewise share one implementation.

    I don't expect any borrow-check errors there, since the lifetimes work out with the currently-hand-monomorphised version.

  4. reopened this on Dec 7, 2012
  5. catamorphism commented on Dec 7, 2012

    @catamorphism
    Contributor

    I was able to merge the two structs and haven't gotten any compile errors yet, but I'm still waiting for tests to run.

  6. catamorphism commented on Dec 7, 2012

    @catamorphism
    Contributor
  7. bblum commented on Dec 7, 2012

    @bblum
    ContributorAuthor

    Hot. Thanks!

  8. added a commit that references this issue on May 15, 2021
    4a82252
  9. added a commit that references this issue on Nov 4, 2023
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

    A-lifetimesArea: Lifetimes / regionsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions