Closed
Description
Having an impl Trait
type, containing a closure, where the closure has a locally defined function inside it, being passed across crate boundaries, results in an ICE.
The following function, defined in one crate, then used in another:
pub fn foo2() -> impl Future<Item=String, Error=()> {
future::ok(()).and_then(|()| {
fn msg() -> String { format!("Hello, {}!", "world") }
future::ok(msg())
})
}
gives the error:
error: internal compiler error: src/librustc_trans/collector.rs:662: Cannot create local trans-item for DefId { krate: CrateNum(12), node: DefIndex(9) => bar/ab23142::foo2[0]::{{closure}}[0]::msg[0] }
note: rustc 1.20.0-nightly (9b85e1cfa 2017-07-07) running on x86_64-apple-darwin
Presumably related to #40839/#35870, I found this while trying to come up with a decent workaround for #40839 specifically.
I have pushed a full testcase to https://github.com/Nemo157/impl-trait-across-crates, try building the foo2
crate.