Change:
I went through the process of updating one of my projects from actix-web 0.7 to 1.0 and ran into a compiler bug. I'm not sure what is causing the issue because I had to change a lot of code to get to this point. Cargo check passes but cargo run produces the provided backtrace. Here is a link to the project that produces the issue: rustc 1.34.0 ( 2019-04-10) binary: rustc commit-hash: commit-date: 2019-04-10 host: x8664-unknown-linux-gnu release: 1.34.0 LLVM version: 8.0 Backtrace:
One quick note: This is GitHub. It is meant for sharing code, but yet you share your code via google drive? :| (please don't get me wrong! Thanks for reporting the issue, but that bugged me ^^)
Sorry, it's a private project on gitlab. There's not a lot there yet so I didn't mind posting the code here as a zip file. If anyone needs access via gitlab to look into this I'd be happy to provide it
You could have created a new repo at GitHub/GitLab ;) As said, thanks again!
Good point, I should have thought of that
It seems like what we really need here is to reduce this to a smaller, standalone test case -- or at minimum to bisect the failure to a particular PR, perhaps using
Sadly I haden't time yet to look into it :| If somebody comes up with a MCVE I will happily bisect it
Would seeing the diff between the working code and failing code help at all?
Looks related to ? (which is working on)

Discussion:
<ins> use rustc_data_structures::fx::FxHashMap; use syntax_pos::Span; </ins> use crate::hir::def_id::DefId; use crate::hir; use crate::hir::Node; use crate::infer::{self, InferCtxt, InferOk, TypeVariableOrigin}; use crate::infer::outlives::free_region_map::FreeRegionRelations; <del> use rustc_data_structures::fx::FxHashMap; </del> use crate::traits::{self, PredicateObligation}; use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind}; <del> use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder}; use crate::ty::outlives::Component; </del> <ins> use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor}; </ins> use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, UnpackedKind}; use crate::util::nodemap::DefIdMap;

let least_region = least_region.unwrap_or(self.tcx.lifetimes.re_static); debug!("constrain_opaque_types: least_region={:?}", least_region); <del> // Require that the type `concrete_ty` outlives // `least_region`, modulo any type parameters that appear // in the type, which we ignore. This is because impl // trait values are assumed to capture all the in-scope // type parameters. This little loop here just invokes // `outlives` repeatedly, draining all the nested // obligations that result. let mut types = vec![concrete_ty]; let bound_region = |r| self.sub_regions(infer::CallReturn(span), least_region, r); while let Some(ty) = types.pop() { let mut components = smallvec![]; self.tcx.push_outlives_components(ty, &mut components); while let Some(component) = components.pop() { match component { Component::Region(r) => { bound_region(r); } Component::Param(_) => { // ignore type parameters like `T`, they are captured // implicitly by the `impl Trait` } Component::UnresolvedInferenceVariable(_) => { // we should get an error that more type // annotations are needed in this case self.tcx .sess .delay_span_bug(span, "unresolved inf var in opaque"); } Component::Projection(ty::ProjectionTy { substs, item_def_id: _, }) => { for k in substs { match k.unpack() { UnpackedKind::Lifetime(lt) => bound_region(lt), UnpackedKind::Type(ty) => types.push(ty), UnpackedKind::Const(_) => { // Const parameters don't impose constraints. } } } } Component::EscapingProjection(more_components) => { components.extend(more_components); } } } } </del> <ins> concrete_ty.visit_with(&mut OpaqueTypeOutlivesVisitor { infcx: self, least_region, span, }); </ins> } /// Given the fully resolved, instantiated type for an opaque

} } <ins> // Visitor that requires that (almost) all regions in the type visited outlive // `least_region`. We cannot use `push_outlives_components` because regions in // closure signatures are not included in their outlives components. We need to // ensure all regions outlive the given bound so that we don't end up with, // say, `ReScope` appearing in a return type and causing ICEs when other // functions end up with region constraints involving regions from other // functions. // // We also cannot use `for_each_free_region` because for closures it includes // the regions parameters from the enclosing item. // // We ignore any type parameters because impl trait values are assumed to // capture all the in-scope type parameters. struct OpaqueTypeOutlivesVisitor<'a, 'gcx, 'tcx> { infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, least_region: ty::Region<'tcx>, span: Span, } impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx> { fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> bool { t.skip_binder().visit_with(self); false // keep visiting } fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { match *r { // ignore bound regions, keep visiting ty::ReLateBound(_, _) => false, _ => { self.infcx.sub_regions(infer::CallReturn(self.span), self.least_region, r); false } } } fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { // We're only interested in types involving regions if !ty.flags.intersects(ty::TypeFlags::HAS_FREE_REGIONS) { return false; // keep visiting } match ty.sty { ty::Closure(def_id, ref substs) => { // Skip lifetime parameters of the enclosing item(s) for upvar_ty in substs.upvar_tys(def_id, self.infcx.tcx) { upvar_ty.visit_with(self); } substs.closure_sig_ty(def_id, self.infcx.tcx).visit_with(self); } ty::Generator(def_id, ref substs, _) => { // Skip lifetime parameters of the enclosing item(s) // Also skip the witness type, because that has no free regions. for upvar_ty in substs.upvar_tys(def_id, self.infcx.tcx) { upvar_ty.visit_with(self); } substs.return_ty(def_id, self.infcx.tcx).visit_with(self); substs.yield_ty(def_id, self.infcx.tcx).visit_with(self); } _ => { ty.super_visit_with(self); } } false } } </ins> struct ReverseMapper<'cx, 'gcx: 'tcx, 'tcx: 'cx> { tcx: TyCtxt<'cx, 'gcx, 'tcx>,

// ignore `'static`, as that can appear anywhere ty::ReStatic | <del> // ignore `ReScope`, as that can appear anywhere // See `src/test/run-pass/issue-49556.rs` for example. </del> <ins> // ignore `ReScope`, which may appear in impl Trait in bindings. </ins> ty::ReScope(..) => return r, _ => { }

<ins> // Test that we are special casing "outlives" for opaque types. // // The return type of a closure is not required to outlive the closure. As such // the following code would not compile if we used a standard outlives check // when checking the return type, because the return type of the closure would // be `&ReEmpty i32`, and we don't allow `ReEmpty` to occur in the concrete // type used for an opaque type. // // However, opaque types are special cased to include check all regions in the // concrete type against the bound, which forces the return type to be // `&'static i32` here. // compile-pass fn make_identity() -> impl Sized { |x: &'static i32| x } fn main() {} </ins>

// This used to ICE because it creates an `impl Trait` that captures a // hidden empty region. <del> #![feature(conservative_impl_trait)] </del> <ins> // compile-pass </ins> <del> fn server() -> impl FilterBase2 { //~ ERROR [E0700] </del> <ins> fn server() -> impl FilterBase2 { </ins> segment2(|| { loop { } }).map2(|| "") }

<del> error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/issue-55608-captures-empty-region.rs:6:16 | LL | fn server() -> impl FilterBase2 { |                ^^^^^^^^^^^^^^^^ | = note: hidden type `Map2<[closure@$DIR/issue-55608-captures-empty-region.rs:7:36: 7:41]>` captures an empty lifetime error: aborting due to previous error For more information about this error, try `rustc --explain E0700`. </del>

<ins> // Regression test for issue 57464. // // Closure are (surprisingly) allowed to outlive their signature. As such it // was possible to end up with `ReScope`s appearing in the concrete type of an // opaque type. As all regions are now required to outlive the bound in an // opaque type we avoid the issue here. // compile-pass struct A<F>(F); unsafe impl <'a, 'b, F: Fn(&'a i32) -> &'b i32> Send for A<F> {} fn wrapped_closure() -> impl Sized { let f = |x| x; f(&0); A(f) } fn main() { let x: Box<dyn Send> = Box::new(wrapped_closure()); } </ins>

fn iter<'a>(data: &'a [usize]) -> impl Iterator<Item = usize> + 'a { data.iter() .map( <del> |x| x // fn(&'a usize) -> &'(ReScope) usize </del> <ins> |x| x // fn(&'a usize) -> &'a usize </ins> ) .map( <del> |x| *x // fn(&'(ReScope) usize) -> usize </del> <ins> |x| *x // fn(&'a usize) -> usize </ins> ) }