You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
yes. Constant propagation does not cross variables (for now). To do this correctly we'll need to detect loops and conditions. Without such a detection mechanism our current implemementation will do a few bogus things.
Since rustc 1.61, the following code is not giving a compile-time error:
fn main() {
let xs = [10, 20, 30];
println!("{}", xs[10]);
let _n = xs.len();
}
If I uncomment the last line, the compile-time error shows up.
Is this right? I would expect the compile-time error to show up in both cases (this is what happens for rustc < 1.61).
Activity
oli-obk commentedon Mar 11, 2018
Yea, there's a FIXME comment in
librustc_mir::transform:: const_propfor this.varkor commentedon Mar 11, 2018
I imagine it was specific to the old implementation, but just a note that we want to make sure #48900 doesn't reappear when this is reimplemented.
Rollup merge of rust-lang#51308 - fanzier:const-prop-array-bounds-che…
steveklabnik commentedon Oct 21, 2019
This code still errors, but this case doesn't:
is this expected?
oli-obk commentedon Oct 21, 2019
yes. Constant propagation does not cross variables (for now). To do this correctly we'll need to detect loops and conditions. Without such a detection mechanism our current implemementation will do a few bogus things.
paolieri commentedon Sep 5, 2022
Since rustc 1.61, the following code is not giving a compile-time error:
If I uncomment the last line, the compile-time error shows up.
Is this right? I would expect the compile-time error to show up in both cases (this is what happens for rustc < 1.61).
cc @oli-obk