Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE with polymorphic regioned struct #3154

Closed
bblum opened this issue Aug 8, 2012 · 6 comments
Closed

ICE with polymorphic regioned struct #3154

bblum opened this issue Aug 8, 2012 · 6 comments
Labels
A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@bblum
Copy link
Contributor

bblum commented Aug 8, 2012

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 ()
@bblum
Copy link
Contributor Author

bblum commented Aug 9, 2012

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

@catamorphism
Copy link
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 }
                                  ^~~~~

@bblum
Copy link
Contributor Author

bblum commented Dec 7, 2012

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.

@bblum bblum reopened this Dec 7, 2012
@catamorphism
Copy link
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.

@catamorphism
Copy link
Contributor

See 7a365e4

@bblum
Copy link
Contributor Author

bblum commented Dec 7, 2012

Hot. Thanks!

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
I don't really know what it's trying to do, but forgetting about everything
you've seen before when you see whitespace followed by a semicolon doesn't look
right to me, and absolutely no tests were hitting that.

This check was introduced in 5ecdd07, however
it was wrong even at that point, and now rustfmt still passes that test,
regardless of macro name.

Fixes rust-lang#3154.
RalfJung pushed a commit to RalfJung/rust that referenced this issue Nov 4, 2023
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Update Rust toolchain from nightly-2024-04-19 to nightly-2024-04-20
without any other source changes.
This is an automatically generated pull request. If any of the CI checks
fail, manual intervention is required. In such a case, review the
changes at https://github.com/rust-lang/rust from
rust-lang@e3181b0
up to
rust-lang@f9b1614.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants