-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Borrowck deduces empty lifetime #74429
Comments
For reproduction, the following [package]
name = "testrust"
version = "0.1.0"
edition = "2018"
[dependencies]
rayon = "1.3.0"
num = "0.2.0"
[dependencies.ndarray]
version = "0.13.0"
features = ["rayon"] |
This is a regression from stable to nightly. |
Let’s bisect this and try to find an MCVE. |
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke |
The code succeeds to compile on 1.44.1 and fails on 1.45, so this is actually a stable-to-stable regression. |
Assigning |
So far I've reduced it to this, which depends only on use ndarray::{s, Array2, Axis, Zip};
pub fn gaussian_elimination<T>(mut a: Array2<T>)
{
let (mut rest_equations, this_equation) =
a.slice_mut(s![..=0, ..]).split_at(Axis(0), 0);
let this_equation = this_equation.index_axis(Axis(0), 0);
rest_equations.axis_iter_mut(Axis(0)).for_each(|_eqn| {
Zip::from(this_equation);
});
} |
searched nightlies: from nightly-2020-04-20 to nightly-2020-06-02 bisected with cargo-bisect-rustc v0.5.2Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --start 2020-04-20 --end 2020-06-02 regressed in #72362 |
@SNCPlay42 The reproduction does not produce error in use ndarray::{s, Array2, Axis, Zip};
pub fn gaussian_elimination<T>(a: Array2<T>)
{
(0..1).filter(|_| true);
let (rest_equations, this_equation) =
a.slice(s![.., ..]).split_at(Axis(0), 0);
let this_equation = this_equation.index_axis(Axis(0), 0);
rest_equations.axis_iter(Axis(0)).for_each(|_| {
Zip::from(this_equation);
});
} Here is an even shorter one: use ndarray::{Array2, Axis, Zip};
fn x<T>(a: Array2<T>) {
(0..1).filter(|_| true);
let y = a.index_axis(Axis(0), 0);
a.axis_iter(Axis(0)).for_each(|_| {
Zip::from(y);
});
} The line This is also reproducible on the nightly |
The PR that made my reduced code (without Full bisect-rustcsearched nightlies: from nightly-2020-05-25 to nightly-2020-07-17 bisected with cargo-bisect-rustc v0.5.2Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --start 2020-05-25 --regress non-error |
Single-crate repro: 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);
});
} |
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. 😄 |
I tried this code:
I expected to see this happen:
On Rust 1.44.0, this compiles.
Instead, this happened:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: