Skip to content

Commit d72a509

Browse files
committed
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".
2 parents 4c0823a + 1df384d commit d72a509

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

src/librustc/middle/dead.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
5050
tcx: TyCtxt<'a, 'tcx, 'tcx>,
5151
tables: &'a ty::TypeckTables<'tcx>,
5252
live_symbols: Box<FxHashSet<ast::NodeId>>,
53-
struct_has_extern_repr: bool,
53+
repr_has_repr_c: bool,
5454
in_pat: bool,
5555
inherited_pub_visibility: bool,
5656
ignore_variant_stack: Vec<DefId>,
@@ -149,8 +149,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
149149
}
150150

151151
fn visit_node(&mut self, node: &hir_map::Node<'tcx>) {
152-
let had_extern_repr = self.struct_has_extern_repr;
153-
self.struct_has_extern_repr = false;
152+
let had_repr_c = self.repr_has_repr_c;
153+
self.repr_has_repr_c = false;
154154
let had_inherited_pub_visibility = self.inherited_pub_visibility;
155155
self.inherited_pub_visibility = false;
156156
match *node {
@@ -159,7 +159,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
159159
hir::ItemStruct(..) | hir::ItemUnion(..) => {
160160
let def_id = self.tcx.hir.local_def_id(item.id);
161161
let def = self.tcx.adt_def(def_id);
162-
self.struct_has_extern_repr = def.repr.c();
162+
self.repr_has_repr_c = def.repr.c();
163163

164164
intravisit::walk_item(self, &item);
165165
}
@@ -187,7 +187,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
187187
}
188188
_ => ()
189189
}
190-
self.struct_has_extern_repr = had_extern_repr;
190+
self.repr_has_repr_c = had_repr_c;
191191
self.inherited_pub_visibility = had_inherited_pub_visibility;
192192
}
193193

@@ -223,10 +223,10 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
223223

224224
fn visit_variant_data(&mut self, def: &'tcx hir::VariantData, _: ast::Name,
225225
_: &hir::Generics, _: ast::NodeId, _: syntax_pos::Span) {
226-
let has_extern_repr = self.struct_has_extern_repr;
226+
let has_repr_c = self.repr_has_repr_c;
227227
let inherited_pub_visibility = self.inherited_pub_visibility;
228228
let live_fields = def.fields().iter().filter(|f| {
229-
has_extern_repr || inherited_pub_visibility || f.vis == hir::Public
229+
has_repr_c || inherited_pub_visibility || f.vis == hir::Public
230230
});
231231
self.live_symbols.extend(live_fields.map(|f| f.id));
232232

@@ -428,7 +428,7 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
428428
tcx,
429429
tables: &ty::TypeckTables::empty(None),
430430
live_symbols: box FxHashSet(),
431-
struct_has_extern_repr: false,
431+
repr_has_repr_c: false,
432432
in_pat: false,
433433
inherited_pub_visibility: false,
434434
ignore_variant_stack: vec![],

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ impl ReprOptions {
15381538
for attr in tcx.get_attrs(did).iter() {
15391539
for r in attr::find_repr_attrs(tcx.sess.diagnostic(), attr) {
15401540
flags.insert(match r {
1541-
attr::ReprExtern => ReprFlags::IS_C,
1541+
attr::ReprC => ReprFlags::IS_C,
15421542
attr::ReprPacked => ReprFlags::IS_PACKED,
15431543
attr::ReprSimd => ReprFlags::IS_SIMD,
15441544
attr::ReprInt(i) => {

src/librustc_lint/bad_style.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,15 @@ impl LintPass for NonCamelCaseTypes {
120120

121121
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
122122
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
123-
let extern_repr_count = it.attrs
123+
let has_repr_c = it.attrs
124124
.iter()
125-
.filter(|attr| {
125+
.any(|attr| {
126126
attr::find_repr_attrs(cx.tcx.sess.diagnostic(), attr)
127127
.iter()
128-
.any(|r| r == &attr::ReprExtern)
129-
})
130-
.count();
131-
let has_extern_repr = extern_repr_count > 0;
128+
.any(|r| r == &attr::ReprC)
129+
});
132130

133-
if has_extern_repr {
131+
if has_repr_c {
134132
return;
135133
}
136134

src/libsyntax/attr.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,7 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr>
10081008
if let Some(mi) = item.word() {
10091009
let word = &*mi.name().as_str();
10101010
let hint = match word {
1011-
// Can't use "extern" because it's not a lexical identifier.
1012-
"C" => Some(ReprExtern),
1011+
"C" => Some(ReprC),
10131012
"packed" => Some(ReprPacked),
10141013
"simd" => Some(ReprSimd),
10151014
_ => match int_type_of_word(word) {
@@ -1080,7 +1079,7 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
10801079
#[derive(PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)]
10811080
pub enum ReprAttr {
10821081
ReprInt(IntType),
1083-
ReprExtern,
1082+
ReprC,
10841083
ReprPacked,
10851084
ReprSimd,
10861085
ReprAlign(u32),

src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ fn find_repr_type_name(diagnostic: &Handler, type_attrs: &[ast::Attribute]) -> &
831831
for r in &attr::find_repr_attrs(diagnostic, a) {
832832
repr_type_name = match *r {
833833
attr::ReprPacked | attr::ReprSimd | attr::ReprAlign(_) => continue,
834-
attr::ReprExtern => "i32",
834+
attr::ReprC => "i32",
835835

836836
attr::ReprInt(attr::SignedInt(ast::IntTy::Isize)) => "isize",
837837
attr::ReprInt(attr::SignedInt(ast::IntTy::I8)) => "i8",

0 commit comments

Comments
 (0)