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

More ICE with higher-ranked lifetimes #57485

Closed
asajeffrey opened this issue Jan 10, 2019 · 2 comments
Closed

More ICE with higher-ranked lifetimes #57485

asajeffrey opened this issue Jan 10, 2019 · 2 comments
Labels
A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@asajeffrey
Copy link

Another example which generates an ICE due to higher-ranked lifetimes: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=024d07b4bae19579bb758798877e2325

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: librustc/traits/codegen/mod.rs:68: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src/main.rs:43:33: 51:6] as std::ops::FnOnce<(&mut <Tree as Container<'_>>::Root, &mut Cache<'_, <Tree as Container<'_>>::Data>)>>), Binder(<[closure@src/main.rs:43:33: 51:6] as std::ops::FnOnce<(&mut Tree, &mut Cache<Node>)>>), Sorts(ExpectedFound { expected: Tree, found: <Tree as Container<'_>>::Root }))` selecting `Binder(<[closure@src/main.rs:43:33: 51:6] as std::ops::FnOnce<(&mut Tree, &mut Cache<Node>)>>)` during codegen

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:600:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error


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

note: rustc 1.31.1 (b6c32da9b 2018-12-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Possibly a dupe of #33364.

@dlrobertson
Copy link
Contributor

Slightly reduced snippet that hits the same ICE

use std::marker::PhantomData;
use std::mem;

trait Container<'a> {
    type Root: 'a;
}

type RootOf<'a, T> = <T as Container<'a>>::Root;

struct Test<'a, T> where T: Container<'a> {
    pub root: T::Root,
    marker: PhantomData<&'a mut &'a mut ()>,
}

impl<'a, 'b> Container<'b> for &'a str {
    type Root = &'b str;
}

impl<'a, T> Test<'a, T> where T: for<'b> Container<'b> {
    fn new(root: RootOf<'a, T>) -> Test<'a, T> {
        Test {
            root: root,
            marker: PhantomData
        }
    }

    fn with_mut<F, R>(&mut self, f: F) -> R where
            F: for<'b> FnOnce(&'b mut RootOf<'b, T>) -> R {
        f(unsafe { mem::transmute(&mut self.root) })
    }
}

fn main() {
    let val = "root";
    let mut test: Test<&str> = Test::new(val);
    test.with_mut(|_| { });
}

@matthewjasper matthewjasper added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 10, 2019
@jonas-schievink jonas-schievink added A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 6, 2019
@pnkfelix
Copy link
Member

closing as duplicate of #62529, which is where I will try to track future instances of this field of ICE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants