-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
internal error: entered unreachable code: we captured two identical projections #104649
Comments
I will try to reduce this to an MCVE. |
Changing |
Minimized it down to 60 lines without any dependencies. Maybe it can be minimized further but it's getting really hard. I've also left a few comments to say what's going on. "Minimized"trait Project {
type Assoc;
}
pub struct Wrap<T>(T);
impl<T> Project for Wrap<T> {
type Assoc = Result<T, ()>;
}
pub trait Stream {
type Item;
fn get_projected<Fut, F>(self, f: F) -> Self::Item
where
F: FnMut(Self::Item) -> Fut,
Self: Sized,
{
loop {}
}
}
pub struct ProjectFnOutput<F>(F);
impl<F> Stream for ProjectFnOutput<F>
where
F: GetFnOutput,
F::Output: Project,
{
type Item = <F::Output as Project>::Assoc;
}
pub trait GetFnOutput {
type Output;
}
impl<T, R> GetFnOutput for T
where
T: FnOnce() -> R,
{
type Output = R;
}
fn main() {
let proj = ProjectFnOutput(|| {
Wrap(
// This is `Result<(), _1>` but since no type annotations are provided the tpye of _1 is unknown.
Ok(()),
)
});
proj.get_projected(|b| async {
// The type of `b` is `Result<Result<(), _1>, ()> where _1 is unknown.
match b {
Ok(Ok(url)) => {}
Err(e) => {}
Ok(Err(e)) => {}
}
});
} |
This appears to have regressed in Rust 1.64 1.62
1.63
1.64
|
This continues to ICE on beta and nightly
|
I bisected the regression, here is the output of searched nightlies: from nightly-2022-06-24 to nightly-2022-08-05 bisected with cargo-bisect-rustc v0.6.4Host triple: x86_64-pc-windows-msvc cargo bisect-rustc --access=github --regress=ice --start 1.63.0 --end 1.64.0 -- check |
Out of these #98574 seems the most likely, cc @dingxiangfei2009 |
Zooming onto |
Found MVCE: type Result<T, E = Error> = ::core::result::Result<T, E>;
struct Error;
trait ForEach {
type Input;
fn for_each<F, U>(self, f: F)
where
F: FnOnce(Self::Input) -> U;
}
impl<T> ForEach for A<T> {
type Input = T;
fn for_each<F, U>(self, f: F)
where
F: FnOnce(Self::Input) -> U,
{
todo!()
}
}
struct A<T>(T);
fn main() {
let a = A(Result::Ok(Result::Ok(())));
//~^ ERROR type annotations needed
a.for_each(|a: Result<_>| {
let f = || {
match a {
Ok(Ok(a)) => {},
Ok(Err(a)) => {},
Err(a) => {},
}
};
});
} Output from Rust Playground
|
Code
Cargo.lock
Meta
rustc --version --verbose
:Error output
The text was updated successfully, but these errors were encountered: