Skip to content

Commit

Permalink
Add 80231
Browse files Browse the repository at this point in the history
  • Loading branch information
fanninpm committed Dec 20, 2020
1 parent 09dee98 commit 3de8016
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions ices/80231.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

rustc -Zchalk - <<'EOF'
use std::ops::Add;
pub trait Encoder {
type Size: Add<Output = Self::Size>;
fn foo(&self) -> Self::Size;
}
pub trait SubEncoder : Encoder {
type ActualSize;
fn bar(&self) -> Self::Size;
}
impl<T> Encoder for T where T: SubEncoder {
type Size = <Self as SubEncoder>::ActualSize;
fn foo(&self) -> Self::Size {
self.bar() + self.bar()
}
}
pub struct UnitEncoder;
impl SubEncoder for UnitEncoder {
type ActualSize = ();
fn bar(&self) {}
}
fn main() {
fun(&UnitEncoder {});
}
pub fn fun<R: Encoder>(encoder: &R) {
encoder.foo();
}
EOF

0 comments on commit 3de8016

Please sign in to comment.