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:
commit
d72a509ea0
@ -50,7 +50,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
|
|||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
tables: &'a ty::TypeckTables<'tcx>,
|
tables: &'a ty::TypeckTables<'tcx>,
|
||||||
live_symbols: Box<FxHashSet<ast::NodeId>>,
|
live_symbols: Box<FxHashSet<ast::NodeId>>,
|
||||||
struct_has_extern_repr: bool,
|
repr_has_repr_c: bool,
|
||||||
in_pat: bool,
|
in_pat: bool,
|
||||||
inherited_pub_visibility: bool,
|
inherited_pub_visibility: bool,
|
||||||
ignore_variant_stack: Vec<DefId>,
|
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>) {
|
fn visit_node(&mut self, node: &hir_map::Node<'tcx>) {
|
||||||
let had_extern_repr = self.struct_has_extern_repr;
|
let had_repr_c = self.repr_has_repr_c;
|
||||||
self.struct_has_extern_repr = false;
|
self.repr_has_repr_c = false;
|
||||||
let had_inherited_pub_visibility = self.inherited_pub_visibility;
|
let had_inherited_pub_visibility = self.inherited_pub_visibility;
|
||||||
self.inherited_pub_visibility = false;
|
self.inherited_pub_visibility = false;
|
||||||
match *node {
|
match *node {
|
||||||
@ -159,7 +159,7 @@ fn visit_node(&mut self, node: &hir_map::Node<'tcx>) {
|
|||||||
hir::ItemStruct(..) | hir::ItemUnion(..) => {
|
hir::ItemStruct(..) | hir::ItemUnion(..) => {
|
||||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||||
let def = self.tcx.adt_def(def_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);
|
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;
|
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,
|
fn visit_variant_data(&mut self, def: &'tcx hir::VariantData, _: ast::Name,
|
||||||
_: &hir::Generics, _: ast::NodeId, _: syntax_pos::Span) {
|
_: &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 inherited_pub_visibility = self.inherited_pub_visibility;
|
||||||
let live_fields = def.fields().iter().filter(|f| {
|
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));
|
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,
|
tcx,
|
||||||
tables: &ty::TypeckTables::empty(None),
|
tables: &ty::TypeckTables::empty(None),
|
||||||
live_symbols: box FxHashSet(),
|
live_symbols: box FxHashSet(),
|
||||||
struct_has_extern_repr: false,
|
repr_has_repr_c: false,
|
||||||
in_pat: false,
|
in_pat: false,
|
||||||
inherited_pub_visibility: false,
|
inherited_pub_visibility: false,
|
||||||
ignore_variant_stack: vec![],
|
ignore_variant_stack: vec![],
|
||||||
|
@ -1538,7 +1538,7 @@ pub fn new(tcx: TyCtxt, did: DefId) -> ReprOptions {
|
|||||||
for attr in tcx.get_attrs(did).iter() {
|
for attr in tcx.get_attrs(did).iter() {
|
||||||
for r in attr::find_repr_attrs(tcx.sess.diagnostic(), attr) {
|
for r in attr::find_repr_attrs(tcx.sess.diagnostic(), attr) {
|
||||||
flags.insert(match r {
|
flags.insert(match r {
|
||||||
attr::ReprExtern => ReprFlags::IS_C,
|
attr::ReprC => ReprFlags::IS_C,
|
||||||
attr::ReprPacked => ReprFlags::IS_PACKED,
|
attr::ReprPacked => ReprFlags::IS_PACKED,
|
||||||
attr::ReprSimd => ReprFlags::IS_SIMD,
|
attr::ReprSimd => ReprFlags::IS_SIMD,
|
||||||
attr::ReprInt(i) => {
|
attr::ReprInt(i) => {
|
||||||
|
@ -120,17 +120,15 @@ fn get_lints(&self) -> LintArray {
|
|||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
|
||||||
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
|
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
|
||||||
let extern_repr_count = it.attrs
|
let has_repr_c = it.attrs
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|attr| {
|
.any(|attr| {
|
||||||
attr::find_repr_attrs(cx.tcx.sess.diagnostic(), attr)
|
attr::find_repr_attrs(cx.tcx.sess.diagnostic(), attr)
|
||||||
.iter()
|
.iter()
|
||||||
.any(|r| r == &attr::ReprExtern)
|
.any(|r| r == &attr::ReprC)
|
||||||
})
|
});
|
||||||
.count();
|
|
||||||
let has_extern_repr = extern_repr_count > 0;
|
|
||||||
|
|
||||||
if has_extern_repr {
|
if has_repr_c {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1008,8 +1008,7 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr>
|
|||||||
if let Some(mi) = item.word() {
|
if let Some(mi) = item.word() {
|
||||||
let word = &*mi.name().as_str();
|
let word = &*mi.name().as_str();
|
||||||
let hint = match word {
|
let hint = match word {
|
||||||
// Can't use "extern" because it's not a lexical identifier.
|
"C" => Some(ReprC),
|
||||||
"C" => Some(ReprExtern),
|
|
||||||
"packed" => Some(ReprPacked),
|
"packed" => Some(ReprPacked),
|
||||||
"simd" => Some(ReprSimd),
|
"simd" => Some(ReprSimd),
|
||||||
_ => match int_type_of_word(word) {
|
_ => 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)]
|
#[derive(PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)]
|
||||||
pub enum ReprAttr {
|
pub enum ReprAttr {
|
||||||
ReprInt(IntType),
|
ReprInt(IntType),
|
||||||
ReprExtern,
|
ReprC,
|
||||||
ReprPacked,
|
ReprPacked,
|
||||||
ReprSimd,
|
ReprSimd,
|
||||||
ReprAlign(u32),
|
ReprAlign(u32),
|
||||||
|
@ -831,7 +831,7 @@ fn find_repr_type_name(diagnostic: &Handler, type_attrs: &[ast::Attribute]) -> &
|
|||||||
for r in &attr::find_repr_attrs(diagnostic, a) {
|
for r in &attr::find_repr_attrs(diagnostic, a) {
|
||||||
repr_type_name = match *r {
|
repr_type_name = match *r {
|
||||||
attr::ReprPacked | attr::ReprSimd | attr::ReprAlign(_) => continue,
|
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::Isize)) => "isize",
|
||||||
attr::ReprInt(attr::SignedInt(ast::IntTy::I8)) => "i8",
|
attr::ReprInt(attr::SignedInt(ast::IntTy::I8)) => "i8",
|
||||||
|
Loading…
Reference in New Issue
Block a user