Closed
Description
MVCE:
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
trait TraitOne {
const MY_NUM:usize;
type MyErr : std::fmt::Debug;
fn do_one_stuff(arr: [u8; Self::MY_NUM]) -> Result<(), Self::MyErr>;
}
trait TraitTwo {
fn do_two_stuff();
}
impl<O: TraitOne> TraitTwo for O
where [(); Self::MY_NUM]: {
fn do_two_stuff() { O::do_one_stuff([5; Self::MY_NUM]).unwrap() }
}
struct Blargotron;
#[derive(Debug)]
struct ErrTy<const N:usize> ([(); N]);
impl TraitOne for Blargotron {
const MY_NUM:usize = 3;
type MyErr = ErrTy<{Self::MY_NUM}>;
fn do_one_stuff(_arr: [u8; Self::MY_NUM]) -> Result<(), Self::MyErr> { Ok(()) }
}
fn main() {
Blargotron::do_two_stuff();
}
(longer than I'd usually like an MVCE to be, but I couldn't find any more ways to shorten it)
Output with linker error:
$ cargo +nightly run
Compiling rustbugrepro v0.1.0 (/home/shelvacu/rustbugrepro)
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-m64" "/tmp/rustcpdm3oV/symbols.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.1ihqumwagrufjop0.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.1mup2xyy24n4gk36.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.23s252vpk659ujid.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.2stlozizc5uxjd7b.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.32r5fw7gu7hn650.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.3m9r4hpnytp8i5eg.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.3y6kclqhz0icogsf.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.4gqxo0wsc252b81i.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.5gj6i7t0wm9u39r7.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.8gtzyztqdis5wfk.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.b2wiaz2930r642i.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.h4vu5fvuiuflzws.rcgu.o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.20c23rlj3dtxnb5h.rcgu.o" "-Wl,--as-needed" "-L" "/home/shelvacu/rustbugrepro/target/debug/deps" "-L" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-9a60c77fcb3cb120.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-5b44c7aad80856ae.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-ff65b550b4dcd2ac.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-7f1169f253822fce.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-a981dbda6aeca1f9.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-fc1281d9e6392569.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-1fbfdea3abefe497.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-9c50e59a7c82c7d4.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-49ab78c1bdf400c6.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-640f18ffcf376a48.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-8448e4d3e976ee3c.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-cb13682f9c2a7246.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-cfa8f6cd7fbf314f.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-0f3268324638da83.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-9dba3f083c9eb142.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-aaaa00ed48be7dc8.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-522518611024dce5.rlib" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "-Wl,--end-group" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-6088bc0426d36242.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/shelvacu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
= note: /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6.b2wiaz2930r642i.rcgu.o: in function `<O as rustbugrepro::TraitTwo>::do_two_stuff':
/home/shelvacu/rustbugrepro/src/main.rs:17: undefined reference to `core::result::Result<T,E>::unwrap'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /home/shelvacu/rustbugrepro/target/debug/deps/rustbugrepro-b454c4cbfd8105b6: hidden symbol `_ZN4core6result19Result$LT$T$C$E$GT$6unwrap17h3f789d9c8ef9bb3fE' isn't defined
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
= help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
error: could not compile `rustbugrepro` due to previous error
Rustc version:
$ rustc +nightly -vV
rustc 1.65.0-nightly (2befdefdd 2022-08-06)
binary: rustc
commit-hash: 2befdefdda0f2bc5ff93f7f95633c98841409098
commit-date: 2022-08-06
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 14.0.6
Also looked at other issues, one of these may be a dupe but none match the structure of the MVCE or the same linker error:
- const_generics: link fails with undefined reference, hidden symbol isn't defined #83972 - also tried with
RUSTC_FLAGS="-Zsymbol-mangling-version=v0"
, no difference - more generic const expr linker errors #84669
- Link fails with hidden symbol isn't defined #86710
- linker error with
feature(generic_const_exprs)
#82268 - "error: linking with
cc
failed: exit code: 1" regression in release build with const generics #73298