From: Mazdak Farrokhzad Date: Mon, 20 May 2019 21:03:07 +0000 (+0200) Subject: Rollup merge of #60959 - petrochenkov:sassert, r=estebank X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=581cf70367d89af738a4f6be5eda8b7f157de25e;hp=-c;p=rust.git 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]` ``` --- 581cf70367d89af738a4f6be5eda8b7f157de25e diff --combined src/librustc/hir/mod.rs index 22312e7459b,3ca79cb8501..57304c5ed37 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@@ -609,9 -609,9 +609,9 @@@ impl Generics own_counts } - pub fn get_named(&self, name: &InternedString) -> Option<&GenericParam> { + pub fn get_named(&self, name: InternedString) -> Option<&GenericParam> { for param in &self.params { - if *name == param.name.ident().as_interned_str() { + if name == param.name.ident().as_interned_str() { return Some(param); } } @@@ -1356,7 -1356,7 +1356,7 @@@ pub struct Expr // `Expr` is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(target_arch = "x86_64")] - static_assert!(MEM_SIZE_OF_EXPR: std::mem::size_of::() == 72); + static_assert_size!(Expr, 72); impl Expr { pub fn precedence(&self) -> ExprPrecedence { diff --combined src/librustc/ty/mod.rs index e1c432d5b6d,1e4bb37c44e..91e996178e7 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@@ -510,7 -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::>() == 32); + static_assert_size!(TyS<'_>, 32); impl<'tcx> Ord for TyS<'tcx> { fn cmp(&self, other: &TyS<'tcx>) -> Ordering { @@@ -3405,7 -3405,7 +3405,7 @@@ impl_stable_hash_for!(struct self::Symb impl SymbolName { pub fn new(name: &str) -> SymbolName { SymbolName { - name: Symbol::intern(name).as_interned_str() + name: InternedString::intern(name) } } diff --combined src/librustc/ty/sty.rs index d20840ef7cf,269064af93b..e8f3bad4d3e --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@@ -211,7 -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::>() == 24); + static_assert_size!(TyKind<'_>, 24); /// A closure can be modeled as a struct that looks like: /// @@@ -1136,7 -1136,7 +1136,7 @@@ impl<'a, 'gcx, 'tcx> ParamTy // FIXME(#50125): Ignoring `Self` with `index != 0` might lead to weird behavior elsewhere, // but this should only be possible when using `-Z continue-parse-after-error` like // `compile-fail/issue-36638.rs`. - self.name == keywords::SelfUpper.name().as_str() && self.index == 0 + self.name.as_symbol() == keywords::SelfUpper.name() && self.index == 0 } } @@@ -2207,7 -2207,7 +2207,7 @@@ pub struct Const<'tcx> } #[cfg(target_arch = "x86_64")] - static_assert!(CONST_SIZE: ::std::mem::size_of::>() == 48); + static_assert_size!(Const<'_>, 48); impl<'tcx> Const<'tcx> { #[inline]