Change:
I tried this code: I expected to see this happen: The code would compile and link normally, and run Instead, this happened: Compilation failed with the following linker error: This failure seems to only occurs if the is defined in the trait, and the trait must have a lifetime parameter. The above is a minimum reproducing case that managed to produce on the forums, based of a more convoluted reproducing case I originally had (). They also produced a version that uses a generator to cause a similar linker failure (in nightly), with very similar setup () and pointed to as a possible suspect (based on bisecting the issue). Let me know if any more information is needed, thanks! : Also failed with nightly:
label T-compiler -regression-untriaged +regression-from-stable-to-stable For clarification (for prioritization): This regression happens between and , so it’s not a very recent regression. Of course, hitting such a linking error is a serious bug either way. Bisection looks like searched toolchains nightly-2021-09-27 through nightly-2021-09-30 Regression in nightly-2021-09-28 fetching nightly manifest 2021-09-27: 40 B / 40 B [=========================================================================================================================] 100.00 % 344.14 KB/s converted 2021-09-27 to fetching nightly manifest 2021-09-28: 40 B / 40 B [=========================================================================================================================] 100.00 % 396.34 KB/s converted 2021-09-28 to looking for regression commit between 2021-09-27 and 2021-09-28 fetching (via remote github) commits from max(, 2021-09-25) to ending github query because we found starting sha: getcommitsbetween returning commits, len: 8 commit[0] 2021-09-26UTC: Auto merge of - sexxi-goose:insigstdlib, r=nikomatsakis commit[1] 2021-09-26UTC: Auto merge of - bjorn3:synccgclif-2021-09-19, r=bjorn3 commit[2] 2021-09-27UTC: Auto merge of - rusticstuff:bumpstdarch, r=kennytm commit[3] 2021-09-27UTC: Auto merge of - GuillaumeGomez:boostrap-explicit-request, r=Mark-Simulacrum commit[4] 2021-09-27UTC: Auto merge of - GuillaumeGomez:cleanup-rustdoc-types, r=camelid commit[5] 2021-09-27UTC: Auto merge of - TaKO8Ki:suggest-both-immutable-and-mutable-trait-implementations, r=estebank commit[6] 2021-09-27UTC: Auto merge of - jackh726:issue-, r=nikomatsakis commit[7] 2021-09-27UTC: Auto merge of - smoelius:register_tool, r=petrochenkov ERROR: no CI builds available between and within last 167 day
Hm, I bet it's
Given that was a revert of , and that it was un-reverted by , I wonder if simply unmasked a regression that occurred between and .
WG-prioritization assigning priority (). label -I-prioritize +P-high
I don't think this is the case. This is definitely caused by , which was fixed by , and then un-fixed by . I'm gonna try to look into fixing this behavior for real in .
seems the symbol names get normalized correctly with
Hey folks, really appreciate you all looking at this. Is there any update? Anything I can do to assist? I'll admit the technical details of the failure here are beyond me though :laughing:
Out of curiosity, how does this look like today on nightly, now that is gone completely? This might also be related / a duplicate of , as that describes a similar linker error.
This linker error happens with any generic function that takes the generator type. See, e.g., my :

Discussion:
// to make sure we don't forget to fold the substs regardless. match kind { <del> // This is really important. While we *can* handle this, this has // severe performance implications for large opaque types with // late-bound regions. See `issue-88862` benchmark. ty::Opaque if !data.substs.has_escaping_bound_vars() => { </del> <ins> ty::Opaque => { </ins> // Only normalize `impl Trait` outside of type inference, usually in codegen. match self.param_env.reveal() { Reveal::UserFacing => ty.super_fold_with(self),

} } } <del> ty::Opaque => ty.super_fold_with(self), </del> ty::Projection if !data.has_escaping_bound_vars() => { // This branch is *mostly* just an optimization: when we don't

// Wrap this in a closure so we don't accidentally return from the outer function let res = match kind { <del> // This is really important. While we *can* handle this, this has // severe performance implications for large opaque types with // late-bound regions. See `issue-88862` benchmark. ty::Opaque if !data.substs.has_escaping_bound_vars() => { </del> <ins> ty::Opaque => { </ins> // Only normalize `impl Trait` outside of type inference, usually in codegen. match self.param_env.reveal() { Reveal::UserFacing => ty.try_super_fold_with(self)?,

} } <del> ty::Opaque => ty.try_super_fold_with(self)?, </del> ty::Projection | ty::Inherent | ty::Weak => { // See note in `rustc_trait_selection::traits::project`

use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::{FulfillmentErrorCode, TraitEngineExt as _}; <del> use rustc_middle::traits::{CodegenObligationError, DefiningAnchor}; </del> <ins> use rustc_middle::traits::CodegenObligationError; </ins> use rustc_middle::ty::{self, TyCtxt}; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt; use rustc_trait_selection::traits::{

// Do the initial selection for the obligation. This yields the // shallow result we are looking for -- that is, what specific impl. <del> let infcx = tcx .infer_ctxt() .ignoring_regions() .with_opaque_type_inference(DefiningAnchor::Bubble) .build(); //~^ HACK `Bubble` is required for // this test to pass: type-alias-impl-trait/assoc-projection-ice.rs </del> <ins> let infcx = tcx.infer_ctxt().ignoring_regions().build(); </ins> let mut selcx = SelectionContext::new(&infcx); let obligation_cause = ObligationCause::dummy();

let impl_source = infcx.resolve_vars_if_possible(impl_source); let impl_source = infcx.tcx.erase_regions(impl_source); <del> // Opaque types may have gotten their hidden types constrained, but we can ignore them safely // as they will get constrained elsewhere, too. // (ouz-a) This is required for `type-alias-impl-trait/assoc-projection-ice.rs` to pass let _ = infcx.take_opaque_types(); </del> Ok(&*tcx.arena.alloc(impl_source)) }

<ins> // build-pass // edition:2021 // compile-flags: -Cdebuginfo=2 // We were not normalizing opaques with escaping bound vars during codegen, // leading to later errors during debuginfo computation. #![feature(async_fn_in_trait)] #[derive(Clone, Copy)] pub struct SharedState {} pub trait State { async fn execute(self, shared_state: &SharedState); } pub trait StateComposer { fn and_then<T, F>(self, map_fn: F) -> AndThen<Self, F> where Self: State + Sized, T: State, F: FnOnce() -> T, { AndThen { previous: self, map_fn } } } impl<T> StateComposer for T where T: State {} pub struct AndThen<T, F> { previous: T, map_fn: F, } impl<T, U, F> State for AndThen<T, F> where T: State, U: State, F: FnOnce() -> U, { async fn execute(self, shared_state: &SharedState) where Self: Sized, { self.previous.execute(shared_state).await; (self.map_fn)().execute(shared_state).await } } pub struct SomeState {} impl State for SomeState { async fn execute(self, shared_state: &SharedState) {} } pub fn main() { let shared_state = SharedState {}; async { SomeState {} .and_then(|| SomeState {}) .and_then(|| SomeState {}) .execute(&shared_state) .await; }; } </ins>

<ins> // build-pass // edition:2021 // compile-flags: -Cdebuginfo=2 // We were not normalizing opaques with escaping bound vars during codegen, // leading to later linker errors because of differences in mangled symbol name. fn func<T>() -> impl Sized {} trait Trait<'a> { type Assoc; fn call() { let _ = async { let _value = func::<Self::Assoc>(); std::future::ready(()).await }; } } impl Trait<'static> for () { type Assoc = (); } fn main() { <()>::call(); } </ins>