rust/tests/ui/nll/missing-universe-cause-issue-114907.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
Rust
Raw Normal View History

2023-08-30 14:10:52 +00:00
// This is a non-regression test for issue #114907 where an ICE happened because of missing
// `UniverseInfo`s accessed during diagnostics.
//
// A couple notes:
// - the `FnOnce` bounds need an arg that is a reference
// - a custom `Drop` is needed somewhere in the type that `accept` returns, to create universes
// during liveness and dropck outlives computation
//@ check-fail
trait Role {
type Inner;
}
struct HandshakeCallback<C>(C);
impl<C: FnOnce(&())> Role for HandshakeCallback<C> {
type Inner = ();
}
struct Handshake<R: Role> {
_inner: Option<R::Inner>,
}
impl<R: Role> Drop for Handshake<R> {
fn drop(&mut self) {}
}
fn accept<C: FnOnce(&())>(_: C) -> Handshake<HandshakeCallback<C>> {
todo!()
}
fn main() {
let callback = |_| {};
accept(callback);
//~^ ERROR implementation of `FnOnce` is not general enough
//~| ERROR implementation of `FnOnce` is not general enough
2023-08-30 14:10:52 +00:00
//~| ERROR implementation of `FnOnce` is not general enough
//~| ERROR implementation of `FnOnce` is not general enough
//~| ERROR higher-ranked subtype error
//~| ERROR higher-ranked subtype error
}