-
Notifications
You must be signed in to change notification settings - Fork 13k
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: bincode v2 alpha cannot be used with nightly rustc #92470
Comments
Still ICE's on |
I created a minimal reproduction of the issue. This ICEs on stable as of 1.57 fn main() {
let writer = WriteImpl;
let mut encoder = EncoderImpl::<_>::new(writer);
Item.encode(&mut encoder);
}
pub trait Encode {
fn encode<E: Encoder>(&self, encoder: E);
}
pub trait Encoder {
type W: Writer;
fn writer(&mut self) -> &mut Self::W;
}
pub trait Writer {
fn write(&mut self);
}
struct Item;
impl Encode for Item {
fn encode<E: Encoder>(&self, mut encoder: E) {
encoder.writer().write();
self.encode(&mut encoder);
}
}
struct EncoderImpl<W: Writer> {
writer: W,
}
impl<W: Writer> EncoderImpl<W> {
pub fn new(writer: W) -> EncoderImpl<W> {
EncoderImpl { writer }
}
}
impl<W: Writer> Encoder for EncoderImpl<W> {
type W = W;
fn writer(&mut self) -> &mut Self::W {
&mut self.writer
}
}
struct WriteImpl;
impl Writer for WriteImpl {
fn write(&mut self) {}
}
impl<'a, T> Encoder for &'a mut T
where
T: Encoder,
{
type W = T::W;
fn writer(&mut self) -> &mut Self::W {
T::writer(self)
}
} The expectation is that the type checker should hit the recursion limit. In fact you can see this happen if you comment out the line |
@Aaron1011 I was told by @lqd that this should hopefully be fixed by #92210 which doesn't seem to be changing anything.
|
Minimized a bit further: fn main() {
encode(&mut EncoderImpl);
}
pub trait Encoder {
type W;
fn writer(&self) -> Self::W;
}
fn encode<E: Encoder>(mut encoder: E) {
encoder.writer();
encode(&mut encoder);
}
struct EncoderImpl;
impl Encoder for EncoderImpl {
type W = ();
fn writer(&self) {}
}
impl<'a, T: Encoder> Encoder for &'a mut T {
type W = T::W;
fn writer(&self) -> Self::W {
panic!()
}
} |
(That was an incorrect guess on my part: I've seen this query in other incremental issues recently, and this actually does not seem to be related to that at all) |
Bisected to 50171c3 with |
Are you sure you bisected correctly? A cargo update should not have introduced it, as the bug is reproducible without any cargo involvement at all. But the ICE does seem to be a regression, as according to experiments on godbolt.org, it doesn't ICE on rustc 1.30.0, but does ICE on rustc 1.31.0 (both Zoey's shared snippet and my example).
|
Yeah the bisect is very weird. I tried running some versions manually that were reported as good by the tool and they still ICEd. I think |
Another reproducer from fn to_fn_once<F:FnOnce()>(f: F) -> F { f }
fn f<T: std::fmt::Display>(y: T) {
struct Foo<U: std::fmt::Display> {
x: U
};
let foo = Foo{ x: "x" };
let c = to_fn_once(move|| {
println!("{} {}", foo.x, y);
});
c();
c();
//~^ ERROR use of moved value
}
fn main() {
f("S");
} |
Triage: Fixed by #100757, I think it has a regression test that should cover this case, closing. |
Reopened by #104610 |
See: kdy1/wasm-perf#1
Code
minimal reproduction.
I'll see if I can reduce further.
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: