about summary refs log tree commit diff
path: root/src/librustc/ty
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-05-20 23:03:07 +0200
committerGitHub <noreply@github.com>2019-05-20 23:03:07 +0200
commit581cf70367d89af738a4f6be5eda8b7f157de25e (patch)
tree34d1b91dd649005d18e03c5e7dc11502ee49f176 /src/librustc/ty
parent864e7a9251057ba31e4f316d459ad6a1dc48baab (diff)
parent88fa5c6a45a533a78c698a22f4b16002a3bc9fc3 (diff)
downloadrust-581cf70367d89af738a4f6be5eda8b7f157de25e.tar.gz
rust-581cf70367d89af738a4f6be5eda8b7f157de25e.zip
Rollup merge of #60959 - petrochenkov:sassert, r=estebank
rustc: Improve type size assertions

Now they
- Tell what the new size is, when it changes
- Do not require passing an identifier

```
   ::: src\libsyntax\parse\token.rs:223:1
    |
223 |    static_assert_size!(Token, 123);
    |    -------------------------------- in this macro invocation
    |
    = note: expected type `[(); 123]`
               found type `[(); 16]`
```
Diffstat (limited to 'src/librustc/ty')
-rw-r--r--src/librustc/ty/mod.rs2
-rw-r--r--src/librustc/ty/sty.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index e1c432d5b6d..91e996178e7 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -510,7 +510,7 @@ pub struct TyS<'tcx> {
 
 // `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
 #[cfg(target_arch = "x86_64")]
-static_assert!(MEM_SIZE_OF_TY_S: ::std::mem::size_of::<TyS<'_>>() == 32);
+static_assert_size!(TyS<'_>, 32);
 
 impl<'tcx> Ord for TyS<'tcx> {
     fn cmp(&self, other: &TyS<'tcx>) -> Ordering {
diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs
index d20840ef7cf..e8f3bad4d3e 100644
--- a/src/librustc/ty/sty.rs
+++ b/src/librustc/ty/sty.rs
@@ -211,7 +211,7 @@ pub enum TyKind<'tcx> {
 
 // `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger.
 #[cfg(target_arch = "x86_64")]
-static_assert!(MEM_SIZE_OF_TY_KIND: ::std::mem::size_of::<TyKind<'_>>() == 24);
+static_assert_size!(TyKind<'_>, 24);
 
 /// A closure can be modeled as a struct that looks like:
 ///
@@ -2207,7 +2207,7 @@ pub struct Const<'tcx> {
 }
 
 #[cfg(target_arch = "x86_64")]
-static_assert!(CONST_SIZE: ::std::mem::size_of::<Const<'static>>() == 48);
+static_assert_size!(Const<'_>, 48);
 
 impl<'tcx> Const<'tcx> {
     #[inline]