Rollup merge of #78061 - wesleywiser:opt_zst_const_interning, r=oli-obk
Optimize const value interning for ZST types Interning can skip any inhabited ZST type in general. Fixes #68010 r? @oli-obk
This commit is contained in:
commit
3fea201b11
2 changed files with 11 additions and 0 deletions
|
@ -187,6 +187,12 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
|
||||||
return walked;
|
return walked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ZSTs do not need validation unless they're uninhabited
|
||||||
|
if mplace.layout.is_zst() && !mplace.layout.abi.is_uninhabited() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.walk_aggregate(mplace, fields)
|
self.walk_aggregate(mplace, fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
src/test/ui/issues/issue-68010-large-zst-consts.rs
Normal file
5
src/test/ui/issues/issue-68010-large-zst-consts.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// build-pass
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("{}", [(); std::usize::MAX].len());
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue