Change:
I tried this code: I expected to see this happen: On Rust 1.44.0, this compiles. Instead, this happened: :
For reproduction, the following is used.
This is a regression from stable to nightly.
Let’s bisect this and try to find an MCVE. ping cleanup
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good "Cleanup ICE-breaking candidate". In case it's useful, here are some [instructions] for tackling these sorts of bugs. Maybe take a look? Thanks! <3 [instructions]: https://rustc-dev- cc
The code succeeds to compile on 1.44.1 and fails on 1.45, so this is actually a stable-to-stable regression.
Assigning as and removing .
So far I've reduced it to this, which depends only on (without the feature):
: searched nightlies: from nightly-2020-04-20 to nightly-2020-06-02 regressed nightly: nightly-2020-05-25 searched commits: from to regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.5.2</summaryHost triple: x86_64-unknown-linux-gnu Reproduce with: </detailsregressed in
The reproduction does not produce error in . However, I find this throws error on this nightly, as well as on 1.45.0. Here is an even shorter one: The line seems critical. Without this, there will be no reproduction with both snippets. This is also reproducible on the nightly .
cc
The PR that made my reduced code (without ) start successfully compiling again is , in case it helps show what's going on. <details<summaryFull bisect-rustc</summarysearched nightlies: from nightly-2020-05-25 to nightly-2020-07-17 regressed nightly: nightly-2020-06-24 searched commits: from to regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.5.2</summaryHost triple: x8664-unknown-linux-gnu Reproduce with: </summary
Single-crate repro:
I can volunteer myself for looking into the issue. I have a question about the region inference. Is there a way to visualize, or trace the region inference? Guidance and mentoring instructions are very welcome. :smile:

Discussion:
/// opaque type. opaque_types_vars: RefCell<FxHashMap<Ty<'tcx>, Ty<'tcx>>>, <del> /// Each type parameter has an implicit region bound that /// indicates it must outlive at least the function body (the user /// may specify stronger requirements). This field indicates the /// region of the callee. If it is `None`, then the parameter /// environment is for an item or something where the "callee" is /// not clear. implicit_region_bound: Option<ty::Region<'tcx>>, </del> body_id: Option<hir::BodyId>, }

deferred_generator_interiors: RefCell::new(Vec::new()), opaque_types: RefCell::new(Default::default()), opaque_types_vars: RefCell::new(Default::default()), <del> implicit_region_bound: None, </del> body_id, } }

fn resolve_regions_and_report_errors(&self, mode: RegionckMode) { self.infcx.process_registered_region_obligations( self.outlives_environment.region_bound_pairs_map(), <del> self.implicit_region_bound, </del> <ins> Some(self.tcx.lifetimes.re_root_empty), </ins> self.param_env, );

<ins> // Regression test for #74429, where we didn't think that a type parameter // outlived `ReEmpty`. // check-pass use std::marker::PhantomData; use std::ptr::NonNull; pub unsafe trait RawData { type Elem; } unsafe impl<A> RawData for OwnedRepr<A> { type Elem = A; } unsafe impl<'a, A> RawData for ViewRepr<&'a A> { type Elem = A; } pub struct OwnedRepr<A> { ptr: PhantomData<A>, } // these Copy impls are not necessary for the repro, but allow the code to compile without error // on 1.44.1 #[derive(Copy, Clone)] pub struct ViewRepr<A> { life: PhantomData<A>, } #[derive(Copy, Clone)] pub struct ArrayBase<S> where S: RawData, { ptr: NonNull<S::Elem>, } pub type Array<A> = ArrayBase<OwnedRepr<A>>; pub type ArrayView<'a, A> = ArrayBase<ViewRepr<&'a A>>; impl<A, S> ArrayBase<S> where S: RawData<Elem = A>, { pub fn index_axis(&self) -> ArrayView<'_, A> { unimplemented!() } pub fn axis_iter<'a>(&'a self) -> std::iter::Empty<&'a A> { unimplemented!() } } pub fn x<T: Copy>(a: Array<T>) { // drop just avoids a must_use warning drop((0..1).filter(|_| true)); let y = a.index_axis(); a.axis_iter().for_each(|_| { drop(y); }); } fn main() {} </ins>

<ins> // Regression test for #74429, where we didn't think that a type parameter // outlived `ReEmpty`. // check-pass use std::marker::PhantomData; fn apply<T, F: FnOnce(T)>(_: T, _: F) {} #[derive(Clone, Copy)] struct Invariant<T> { t: T, p: PhantomData<fn(T) -> T>, } fn verify_reempty<T>(x: T) { // r is inferred to have type `Invariant<&ReEmpty(U0) T>` let r = Invariant { t: &x, p: PhantomData }; // Creates a new universe, all variables from now on are in `U1`, say. let _: fn(&()) = |_| {}; // Closure parameter is of type `&ReEmpty(U1) T`, so the closure has an implied // bound of `T: ReEmpty(U1)` apply(&x, |_| { // Requires `typeof(r)` is well-formed, i.e. `T: ReEmpty(U0)`. If we // only have the implied bound from the closure parameter to use this // requires `ReEmpty(U1): ReEmpty(U0)`, which isn't true so we reported // an error. // // This doesn't happen any more because we ensure that `T: ReEmpty(U0)` // is an implicit bound for all type parameters. drop(r); }); } fn main() {} </ins>