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:
Guillaume Gomez 2020-10-20 21:46:32 +02:00 committed by GitHub
commit 3fea201b11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -187,6 +187,12 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
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)
}

View file

@ -0,0 +1,5 @@
// build-pass
fn main() {
println!("{}", [(); std::usize::MAX].len());
}