Rollup merge of #102493 - nnethercote:improve-size-assertions-some-more, r=lqd

Group together more size assertions.

Also add a few more assertions for some relevant token-related types.

And fix an erroneous comment in `rustc_errors`.

r? `@lqd`
This commit is contained in:
Matthias Krüger 2022-09-30 23:38:27 +02:00 committed by GitHub
commit eaf1c7a0da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 25 deletions

View file

@ -32,11 +32,6 @@ pub struct AttrWrapper {
start_pos: usize,
}
// This struct is passed around very frequently,
// so make sure it doesn't accidentally get larger
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(AttrWrapper, 16);
impl AttrWrapper {
pub(super) fn new(attrs: AttrVec, start_pos: usize) -> AttrWrapper {
AttrWrapper { attrs, start_pos }
@ -96,9 +91,6 @@ struct LazyAttrTokenStreamImpl {
replace_ranges: Box<[ReplaceRange]>,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(LazyAttrTokenStreamImpl, 144);
impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
fn to_attr_token_stream(&self) -> AttrTokenStream {
// The token produced by the final call to `{,inlined_}next` was not
@ -461,3 +453,13 @@ fn make_token_stream(
}
AttrTokenStream::new(final_buf.inner)
}
// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
mod size_asserts {
use super::*;
use rustc_data_structures::static_assert_size;
// These are in alphabetical order, which is easy to maintain.
static_assert_size!(AttrWrapper, 16);
static_assert_size!(LazyAttrTokenStreamImpl, 144);
}