-
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
ICE: panic on type inference with possible Deref coercion #111739
Comments
reduced a bit use std::ops::Deref;
use std::rc::Rc;
struct Value<T>(T);
pub trait Wrap<T: ?Sized> {
fn wrap(f: T) -> Self;
}
impl<R, A1, A2> Wrap<fn(A1, A2) -> R> for Value<fn(A1, A2) -> R> {}
impl<F, R, A1, A2> Wrap<F> for Value<Rc<dyn Fn(A1, A2) -> R>> {}
impl<F> Deref for Value<Rc<F>> {
type Target = F;
}
fn fn_select(var_x: bool) -> i64 {
let var_fn = Value::wrap();
match var_fn.clone() {}
} |
Regression in nightly-2020-06-24 |
This is minimized in the sense that spurious errors are avoided: use std::ops::Deref;
use std::rc::Rc;
struct Value<T>(T);
pub trait Wrap<T> {
fn wrap() -> Self;
}
impl<R, A1, A2> Wrap<fn(A1, A2) -> R> for Value<fn(A1, A2) -> R> {
fn wrap() -> Self {
todo!()
}
}
impl<F, R, A1, A2> Wrap<F> for Value<Rc<dyn Fn(A1, A2) -> R>> {
fn wrap() -> Self {
todo!()
}
}
impl<F> Deref for Value<Rc<F>> {
type Target = F;
fn deref(&self) -> &Self::Target {
&*self.0
}
}
fn main() {
let var_fn = Value::wrap();
let _ = var_fn.clone();
} The problem here is that the autoderef of a method is interacting strangely with the |
I've tried bisecting to a narrower point but didn't get far: commit[0] 2020-06-22: Auto merge of 73415 - ehuss:update-cargo, r=ehuss So I guess one #72389, #73635 or #73643 WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-low |
…ide-effects, r=fee1-dead Don't structurally resolve during method ambiguity in probe See comment in UI test for reason for the failure. This is all on the error path anyways, not really sure what the assertion is there to achieve anyways... Fixes rust-lang#111739
Code
It seems this is a particularly tricky interaction of
Clone
,Deref
coercion and these twoimpl
; take away any one, and the compiler spits out a type annotation error as seen below.The compiler is also happy if
var_fn
is annotated asValue<fn(_, _) -> _>
but I don't quite understand why this needs to be specified, given the inner casts on both branches.Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: