Closed
Description
This code (playground)
#![feature(const_generics)]
pub trait Foo {
fn foo(&self);
}
pub struct FooImpl<const N: usize>;
impl<const N: usize> Foo for FooImpl<N> {
fn foo(&self) {}
}
pub trait Bar: 'static {
type Foo: Foo;
fn get() -> &'static Self::Foo;
}
struct BarImpl;
impl Bar for BarImpl {
type Foo = FooImpl<{ 4 }>;
fn get() -> &'static Self::Foo {
&FooImpl
}
}
pub fn boom<B: Bar>() {
B::get().foo();
}
fn main() {
boom::<BarImpl>();
}
fails to link with
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-m64" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-Wl,--as-needed" "-L" "/playground/.rustup/toolchains/nightly-x86_*snip*own-linux-gnu/lib/libcompiler_builtins-8b33f9cbbc9652fe.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
= note: /usr/bin/ld: /playground/target/debug/deps/playground-dea6a74639071602.playground.27snrtcg-cgu.0.rcgu.o: in function `playground::boom':
/playground/src/main.rs:26: undefined reference to `<playground::FooImpl<_> as playground::Foo>::foo'
/usr/bin/ld: /playground/target/debug/deps/playground-dea6a74639071602: hidden symbol `_ZN64_$LT$playground..FooImpl$LT$_$GT$$u20$as$u20$playground..Foo$GT$3foo17hc9e5ef50b3fc24d9E' isn't defined
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
rustc --version --verbose
:
rustc 1.53.0-nightly (c051c5ddd 2021-04-06)
binary: rustc
commit-hash: c051c5ddda79f45fad196ca3a4690251e377d043
commit-date: 2021-04-06
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0