Rollup merge of #47256 - rkruppe:misc-cleanup, r=eddyb

Rename ReprExtern to ReprC

… and similarily rename a few other field and locals that mentioned "extern repr".
This commit is contained in:
kennytm 2018-01-09 01:58:50 +08:00
commit d72a509ea0
No known key found for this signature in database
GPG Key ID: FEF6C8051D0E013C
5 changed files with 17 additions and 20 deletions

View File

@ -50,7 +50,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tables: &'a ty::TypeckTables<'tcx>,
live_symbols: Box<FxHashSet<ast::NodeId>>,
struct_has_extern_repr: bool,
repr_has_repr_c: bool,
in_pat: bool,
inherited_pub_visibility: bool,
ignore_variant_stack: Vec<DefId>,
@ -149,8 +149,8 @@ fn mark_live_symbols(&mut self) {
}
fn visit_node(&mut self, node: &hir_map::Node<'tcx>) {
let had_extern_repr = self.struct_has_extern_repr;
self.struct_has_extern_repr = false;
let had_repr_c = self.repr_has_repr_c;
self.repr_has_repr_c = false;
let had_inherited_pub_visibility = self.inherited_pub_visibility;
self.inherited_pub_visibility = false;
match *node {
@ -159,7 +159,7 @@ fn visit_node(&mut self, node: &hir_map::Node<'tcx>) {
hir::ItemStruct(..) | hir::ItemUnion(..) => {
let def_id = self.tcx.hir.local_def_id(item.id);
let def = self.tcx.adt_def(def_id);
self.struct_has_extern_repr = def.repr.c();
self.repr_has_repr_c = def.repr.c();
intravisit::walk_item(self, &item);
}
@ -187,7 +187,7 @@ fn visit_node(&mut self, node: &hir_map::Node<'tcx>) {
}
_ => ()
}
self.struct_has_extern_repr = had_extern_repr;
self.repr_has_repr_c = had_repr_c;
self.inherited_pub_visibility = had_inherited_pub_visibility;
}
@ -223,10 +223,10 @@ fn visit_nested_body(&mut self, body: hir::BodyId) {
fn visit_variant_data(&mut self, def: &'tcx hir::VariantData, _: ast::Name,
_: &hir::Generics, _: ast::NodeId, _: syntax_pos::Span) {
let has_extern_repr = self.struct_has_extern_repr;
let has_repr_c = self.repr_has_repr_c;
let inherited_pub_visibility = self.inherited_pub_visibility;
let live_fields = def.fields().iter().filter(|f| {
has_extern_repr || inherited_pub_visibility || f.vis == hir::Public
has_repr_c || inherited_pub_visibility || f.vis == hir::Public
});
self.live_symbols.extend(live_fields.map(|f| f.id));
@ -428,7 +428,7 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx,
tables: &ty::TypeckTables::empty(None),
live_symbols: box FxHashSet(),
struct_has_extern_repr: false,
repr_has_repr_c: false,
in_pat: false,
inherited_pub_visibility: false,
ignore_variant_stack: vec![],

View File

@ -1538,7 +1538,7 @@ pub fn new(tcx: TyCtxt, did: DefId) -> ReprOptions {
for attr in tcx.get_attrs(did).iter() {
for r in attr::find_repr_attrs(tcx.sess.diagnostic(), attr) {
flags.insert(match r {
attr::ReprExtern => ReprFlags::IS_C,
attr::ReprC => ReprFlags::IS_C,
attr::ReprPacked => ReprFlags::IS_PACKED,
attr::ReprSimd => ReprFlags::IS_SIMD,
attr::ReprInt(i) => {

View File

@ -120,17 +120,15 @@ fn get_lints(&self) -> LintArray {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
let extern_repr_count = it.attrs
let has_repr_c = it.attrs
.iter()
.filter(|attr| {
.any(|attr| {
attr::find_repr_attrs(cx.tcx.sess.diagnostic(), attr)
.iter()
.any(|r| r == &attr::ReprExtern)
})
.count();
let has_extern_repr = extern_repr_count > 0;
.any(|r| r == &attr::ReprC)
});
if has_extern_repr {
if has_repr_c {
return;
}

View File

@ -1008,8 +1008,7 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr>
if let Some(mi) = item.word() {
let word = &*mi.name().as_str();
let hint = match word {
// Can't use "extern" because it's not a lexical identifier.
"C" => Some(ReprExtern),
"C" => Some(ReprC),
"packed" => Some(ReprPacked),
"simd" => Some(ReprSimd),
_ => match int_type_of_word(word) {
@ -1080,7 +1079,7 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
#[derive(PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)]
pub enum ReprAttr {
ReprInt(IntType),
ReprExtern,
ReprC,
ReprPacked,
ReprSimd,
ReprAlign(u32),

View File

@ -831,7 +831,7 @@ fn find_repr_type_name(diagnostic: &Handler, type_attrs: &[ast::Attribute]) -> &
for r in &attr::find_repr_attrs(diagnostic, a) {
repr_type_name = match *r {
attr::ReprPacked | attr::ReprSimd | attr::ReprAlign(_) => continue,
attr::ReprExtern => "i32",
attr::ReprC => "i32",
attr::ReprInt(attr::SignedInt(ast::IntTy::Isize)) => "isize",
attr::ReprInt(attr::SignedInt(ast::IntTy::I8)) => "i8",