Skip to content

Commit 74966b5

Browse files
committed
Auto merge of #47276 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests - Successful merges: #47210, #47233, #47246, #47254, #47256, #47258, #47259, #47263, #47270, #47272 - Failed merges: #47248
2 parents b5392f5 + 9ef9854 commit 74966b5

File tree

45 files changed

+192
-162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+192
-162
lines changed

src/libcore/fmt/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,12 @@ pub type Result = result::Result<(), Error>;
8383
/// some other means.
8484
///
8585
/// An important thing to remember is that the type `fmt::Error` should not be
86-
/// confused with `std::io::Error` or `std::error::Error`, which you may also
86+
/// confused with [`std::io::Error`] or [`std::error::Error`], which you may also
8787
/// have in scope.
8888
///
89+
/// [`std::io::Error`]: ../../std/io/struct.Error.html
90+
/// [`std::error::Error`]: ../../std/error/trait.Error.html
91+
///
8992
/// # Examples
9093
///
9194
/// ```rust

src/librustc/middle/dead.rs

+10-10
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>,
@@ -102,7 +102,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
102102
fn handle_field_access(&mut self, lhs: &hir::Expr, name: ast::Name) {
103103
match self.tables.expr_ty_adjusted(lhs).sty {
104104
ty::TyAdt(def, _) => {
105-
self.insert_def_id(def.struct_variant().field_named(name).did);
105+
self.insert_def_id(def.non_enum_variant().field_named(name).did);
106106
}
107107
_ => span_bug!(lhs.span, "named field access on non-ADT"),
108108
}
@@ -111,7 +111,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
111111
fn handle_tup_field_access(&mut self, lhs: &hir::Expr, idx: usize) {
112112
match self.tables.expr_ty_adjusted(lhs).sty {
113113
ty::TyAdt(def, _) => {
114-
self.insert_def_id(def.struct_variant().fields[idx].did);
114+
self.insert_def_id(def.non_enum_variant().fields[idx].did);
115115
}
116116
ty::TyTuple(..) => {}
117117
_ => span_bug!(lhs.span, "numeric field access on non-ADT"),
@@ -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/middle/expr_use_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
663663
match with_cmt.ty.sty {
664664
ty::TyAdt(adt, substs) if adt.is_struct() => {
665665
// Consume those fields of the with expression that are needed.
666-
for with_field in &adt.struct_variant().fields {
666+
for with_field in &adt.non_enum_variant().fields {
667667
if !contains_field_named(with_field, fields) {
668668
let cmt_field = self.mc.cat_field(
669669
&*with_expr,

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
12481248
Def::StructCtor(_, CtorKind::Fn) => {
12491249
match self.pat_ty(&pat)?.sty {
12501250
ty::TyAdt(adt_def, _) => {
1251-
(cmt, adt_def.struct_variant().fields.len())
1251+
(cmt, adt_def.non_enum_variant().fields.len())
12521252
}
12531253
ref ty => {
12541254
span_bug!(pat.span, "tuple struct pattern unexpected type {:?}", ty);

src/librustc/session/config.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1084,8 +1084,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
10841084
"omit landing pads for unwinding"),
10851085
fewer_names: bool = (false, parse_bool, [TRACKED],
10861086
"reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR)"),
1087-
debug_llvm: bool = (false, parse_bool, [UNTRACKED],
1088-
"enable debug output from LLVM"),
10891087
meta_stats: bool = (false, parse_bool, [UNTRACKED],
10901088
"gather metadata statistics"),
10911089
print_link_args: bool = (false, parse_bool, [UNTRACKED],
@@ -2747,8 +2745,6 @@ mod tests {
27472745
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
27482746
opts.debugging_opts.borrowck_stats = true;
27492747
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
2750-
opts.debugging_opts.debug_llvm = true;
2751-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
27522748
opts.debugging_opts.meta_stats = true;
27532749
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
27542750
opts.debugging_opts.print_link_args = true;

src/librustc/ty/layout.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2295,6 +2295,13 @@ impl<'a, 'tcx> TyLayout<'tcx> {
22952295
}, niche_start))
22962296
};
22972297

2298+
// Locals variables which live across yields are stored
2299+
// in the generator type as fields. These may be uninitialized
2300+
// so we don't look for niches there.
2301+
if let ty::TyGenerator(..) = self.ty.sty {
2302+
return Ok(None);
2303+
}
2304+
22982305
match self.abi {
22992306
Abi::Scalar(ref scalar) => {
23002307
return Ok(scalar_component(scalar, Size::from_bytes(0)));

src/librustc/ty/mod.rs

+7-8
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) => {
@@ -1691,10 +1691,9 @@ impl<'a, 'gcx, 'tcx> AdtDef {
16911691
self.destructor(tcx).is_some()
16921692
}
16931693

1694-
/// Asserts this is a struct and returns the struct's unique
1695-
/// variant.
1696-
pub fn struct_variant(&self) -> &VariantDef {
1697-
assert!(!self.is_enum());
1694+
/// Asserts this is a struct or union and returns its unique variant.
1695+
pub fn non_enum_variant(&self) -> &VariantDef {
1696+
assert!(self.is_struct() || self.is_union());
16981697
&self.variants[0]
16991698
}
17001699

@@ -1733,7 +1732,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
17331732
match def {
17341733
Def::Variant(vid) | Def::VariantCtor(vid, ..) => self.variant_with_id(vid),
17351734
Def::Struct(..) | Def::StructCtor(..) | Def::Union(..) |
1736-
Def::TyAlias(..) | Def::AssociatedTy(..) | Def::SelfTy(..) => self.struct_variant(),
1735+
Def::TyAlias(..) | Def::AssociatedTy(..) | Def::SelfTy(..) => self.non_enum_variant(),
17371736
_ => bug!("unexpected def {:?} in variant_of_def", def)
17381737
}
17391738
}
@@ -2319,11 +2318,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23192318
self.adt_def(enum_did).variant_with_id(did)
23202319
}
23212320
Def::Struct(did) | Def::Union(did) => {
2322-
self.adt_def(did).struct_variant()
2321+
self.adt_def(did).non_enum_variant()
23232322
}
23242323
Def::StructCtor(ctor_did, ..) => {
23252324
let did = self.parent_def_id(ctor_did).expect("struct ctor has no parent");
2326-
self.adt_def(did).struct_variant()
2325+
self.adt_def(did).non_enum_variant()
23272326
}
23282327
_ => bug!("expect_variant_def used with unexpected def {:?}", def)
23292328
}

src/librustc/ty/sty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1351,15 +1351,15 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
13511351
pub fn simd_type(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
13521352
match self.sty {
13531353
TyAdt(def, substs) => {
1354-
def.struct_variant().fields[0].ty(tcx, substs)
1354+
def.non_enum_variant().fields[0].ty(tcx, substs)
13551355
}
13561356
_ => bug!("simd_type called on invalid type")
13571357
}
13581358
}
13591359

13601360
pub fn simd_size(&self, _cx: TyCtxt) -> usize {
13611361
match self.sty {
1362-
TyAdt(def, _) => def.struct_variant().fields.len(),
1362+
TyAdt(def, _) => def.non_enum_variant().fields.len(),
13631363
_ => bug!("simd_size called on invalid type")
13641364
}
13651365
}

src/librustc/ty/util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
258258
adt.variant_with_id(vid).fields.get(i).map(|f| f.ty(self, substs))
259259
}
260260
(&TyAdt(adt, substs), None) => {
261-
// Don't use `struct_variant`, this may be a univariant enum.
261+
// Don't use `non_enum_variant`, this may be a univariant enum.
262262
adt.variants[0].fields.get(i).map(|f| f.ty(self, substs))
263263
}
264264
(&TyTuple(ref v, _), None) => v.get(i).cloned(),
@@ -277,7 +277,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
277277
adt.variant_with_id(vid).find_field_named(n).map(|f| f.ty(self, substs))
278278
}
279279
(&TyAdt(adt, substs), None) => {
280-
adt.struct_variant().find_field_named(n).map(|f| f.ty(self, substs))
280+
adt.non_enum_variant().find_field_named(n).map(|f| f.ty(self, substs))
281281
}
282282
_ => return None
283283
}
@@ -293,7 +293,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
293293
if !def.is_struct() {
294294
break;
295295
}
296-
match def.struct_variant().fields.last() {
296+
match def.non_enum_variant().fields.last() {
297297
Some(f) => ty = f.ty(self, substs),
298298
None => break,
299299
}
@@ -329,7 +329,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
329329
match (&a.sty, &b.sty) {
330330
(&TyAdt(a_def, a_substs), &TyAdt(b_def, b_substs))
331331
if a_def == b_def && a_def.is_struct() => {
332-
if let Some(f) = a_def.struct_variant().fields.last() {
332+
if let Some(f) = a_def.non_enum_variant().fields.last() {
333333
a = f.ty(self, a_substs);
334334
b = f.ty(self, b_substs);
335335
} else {

src/librustc_borrowck/borrowck/gather_loans/restrictions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
107107
ty::TyAdt(adt_def, _) if adt_def.is_union() => match result {
108108
RestrictionResult::Safe => RestrictionResult::Safe,
109109
RestrictionResult::SafeIf(base_lp, mut base_vec) => {
110-
for field in &adt_def.struct_variant().fields {
110+
for field in &adt_def.non_enum_variant().fields {
111111
let field = InteriorKind::InteriorField(mc::NamedField(field.name));
112112
let field_ty = if field == interior {
113113
cmt.ty

src/librustc_borrowck/borrowck/move_data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
343343
if let (&ty::TyAdt(adt_def, _), LpInterior(opt_variant_id, interior))
344344
= (&base_lp.ty.sty, lp_elem) {
345345
if adt_def.is_union() {
346-
for field in &adt_def.struct_variant().fields {
346+
for field in &adt_def.non_enum_variant().fields {
347347
let field = InteriorKind::InteriorField(mc::NamedField(field.name));
348348
if field != interior {
349349
let sibling_lp_kind =
@@ -395,7 +395,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
395395
if let LpExtend(ref base_lp, mutbl, LpInterior(opt_variant_id, interior)) = lp.kind {
396396
if let ty::TyAdt(adt_def, _) = base_lp.ty.sty {
397397
if adt_def.is_union() {
398-
for field in &adt_def.struct_variant().fields {
398+
for field in &adt_def.non_enum_variant().fields {
399399
let field = InteriorKind::InteriorField(mc::NamedField(field.name));
400400
let field_ty = if field == interior {
401401
lp.ty

src/librustc_driver/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ mod rustc_trans {
167167
pub use rustc_trans_utils::trans_crate::TranslatedCrate as CrateTranslation;
168168

169169
pub fn init(_sess: &Session) {}
170-
pub fn enable_llvm_debug() {}
171170
pub fn print_version() {}
172171
pub fn print_passes() {}
173172
pub fn print(_req: PrintRequest, _sess: &Session) {}
@@ -205,10 +204,6 @@ pub fn run_compiler<'a>(args: &[String],
205204

206205
let (sopts, cfg) = config::build_session_options_and_crate_config(&matches);
207206

208-
if sopts.debugging_opts.debug_llvm {
209-
rustc_trans::enable_llvm_debug();
210-
}
211-
212207
let descriptions = diagnostics_registry();
213208

214209
do_or_return!(callbacks.early_callback(&matches,

src/librustc_lint/bad_style.rs

+5-7
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/librustc_lint/types.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,15 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
422422
consider adding a #[repr(C)] attribute to the type");
423423
}
424424

425-
if def.struct_variant().fields.is_empty() {
425+
if def.non_enum_variant().fields.is_empty() {
426426
return FfiUnsafe("found zero-size struct in foreign module, consider \
427427
adding a member to this struct");
428428
}
429429

430430
// We can't completely trust repr(C) markings; make sure the
431431
// fields are actually safe.
432432
let mut all_phantom = true;
433-
for field in &def.struct_variant().fields {
433+
for field in &def.non_enum_variant().fields {
434434
let field_ty = cx.fully_normalize_associated_types_in(
435435
&field.ty(cx, substs)
436436
);
@@ -458,13 +458,13 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
458458
consider adding a #[repr(C)] attribute to the type");
459459
}
460460

461-
if def.struct_variant().fields.is_empty() {
461+
if def.non_enum_variant().fields.is_empty() {
462462
return FfiUnsafe("found zero-size union in foreign module, consider \
463463
adding a member to this union");
464464
}
465465

466466
let mut all_phantom = true;
467-
for field in &def.struct_variant().fields {
467+
for field in &def.non_enum_variant().fields {
468468
let field_ty = cx.fully_normalize_associated_types_in(
469469
&field.ty(cx, substs)
470470
);

src/librustc_llvm/ffi.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1315,9 +1315,6 @@ extern "C" {
13151315
ElementCount: c_uint,
13161316
Packed: Bool);
13171317

1318-
/// Enables LLVM debug output.
1319-
pub fn LLVMRustSetDebug(Enabled: c_int);
1320-
13211318
/// Prepares inline assembly.
13221319
pub fn LLVMRustInlineAsm(Ty: TypeRef,
13231320
AsmString: *const c_char,
@@ -1610,7 +1607,6 @@ extern "C" {
16101607
pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
16111608
pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool);
16121609
pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef, bc: *const c_char, len: size_t) -> bool;
1613-
pub fn LLVMRustLinkInParsedExternalBitcode(M: ModuleRef, M: ModuleRef) -> bool;
16141610
pub fn LLVMRustRunRestrictionPass(M: ModuleRef, syms: *const *const c_char, len: size_t);
16151611
pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
16161612

@@ -1646,8 +1642,6 @@ extern "C" {
16461642
pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
16471643
pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
16481644

1649-
pub fn LLVMRustWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1650-
16511645
pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
16521646
H: InlineAsmDiagHandler,
16531647
CX: *mut c_void);

src/librustc_llvm/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,6 @@ pub unsafe fn twine_to_string(tr: TwineRef) -> String {
296296
build_string(|s| LLVMRustWriteTwineToString(tr, s)).expect("got a non-UTF8 Twine from LLVM")
297297
}
298298

299-
pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
300-
build_string(|s| LLVMRustWriteDebugLocToString(c, tr, s))
301-
.expect("got a non-UTF8 DebugLoc from LLVM")
302-
}
303-
304299
pub fn initialize_available_targets() {
305300
macro_rules! init_target(
306301
($cfg:meta, $($method:ident),*) => { {

0 commit comments

Comments
 (0)