Skip to content

Commit 7445622

Browse files
committed
Auto merge of #63998 - Centril:rollup-pfuwxz3, r=Centril
Rollup of 7 pull requests Successful merges: - #63867 (resolve: Block expansion of a derive container until all its derives are resolved) - #63880 (Validation: check raw wide pointer metadata) - #63914 (ty: use Align for ReprOptions pack and align.) - #63941 (rustbuild: allow disabling deny(warnings) for bootstrap) - #63949 (Fix build src/libtest) - #63984 (Update rust-installer to limit memory use) - #63992 (Small improvement for Ord implementation of integers) Failed merges: r? @ghost
2 parents 85ed538 + 3f05cf6 commit 7445622

33 files changed

+430
-325
lines changed

src/bootstrap/bin/main.rs

-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
//! parent directory, and otherwise documentation can be found throughout the `build`
66
//! directory in each respective module.
77
8-
// NO-RUSTC-WRAPPER
9-
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
10-
118
use std::env;
129

1310
use bootstrap::{Config, Build};

src/bootstrap/bin/rustc.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
//! switching compilers for the bootstrap and for build scripts will probably
1616
//! never get replaced.
1717
18-
// NO-RUSTC-WRAPPER
19-
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
20-
2118
use std::env;
2219
use std::ffi::OsString;
2320
use std::io;
@@ -124,8 +121,9 @@ fn main() {
124121

125122
if env::var_os("RUSTC_DENY_WARNINGS").is_some() &&
126123
env::var_os("RUSTC_EXTERNAL_TOOL").is_none() {
127-
// When extending this list, search for `NO-RUSTC-WRAPPER` and add the new lints
128-
// there as well, some code doesn't go through this `rustc` wrapper.
124+
// When extending this list, add the new lints to the RUSTFLAGS of the
125+
// build_bootstrap function of src/bootstrap/bootstrap.py as well as
126+
// some code doesn't go through this `rustc` wrapper.
129127
cmd.arg("-Dwarnings");
130128
cmd.arg("-Drust_2018_idioms");
131129
cmd.arg("-Dunused_lifetimes");

src/bootstrap/bin/rustdoc.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
//!
33
//! See comments in `src/bootstrap/rustc.rs` for more information.
44
5-
// NO-RUSTC-WRAPPER
6-
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
7-
85
use std::env;
96
use std::process::Command;
107
use std::path::PathBuf;

src/bootstrap/bootstrap.py

+2
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ def build_bootstrap(self):
631631
target_linker = self.get_toml("linker", build_section)
632632
if target_linker is not None:
633633
env["RUSTFLAGS"] += "-C linker=" + target_linker + " "
634+
if self.get_toml("deny-warnings", "rust") != "false":
635+
env["RUSTFLAGS"] += "-Dwarnings -Drust_2018_idioms -Dunused_lifetimes "
634636

635637
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
636638
os.pathsep + env["PATH"]

src/bootstrap/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl Step for Std {
3434
const DEFAULT: bool = true;
3535

3636
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
37-
run.all_krates("std")
37+
run.all_krates("test")
3838
}
3939

4040
fn make_run(run: RunConfig<'_>) {

src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Step for Std {
3939
const DEFAULT: bool = true;
4040

4141
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
42-
run.all_krates("std")
42+
run.all_krates("test")
4343
}
4444

4545
fn make_run(run: RunConfig<'_>) {

src/bootstrap/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl Step for Std {
413413

414414
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
415415
let builder = run.builder;
416-
run.all_krates("std").default_condition(builder.config.docs)
416+
run.all_krates("test").default_condition(builder.config.docs)
417417
}
418418

419419
fn make_run(run: RunConfig<'_>) {

src/bootstrap/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@
103103
//! More documentation can be found in each respective module below, and you can
104104
//! also check out the `src/bootstrap/README.md` file for more information.
105105
106-
// NO-RUSTC-WRAPPER
107-
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
108-
109106
#![feature(core_intrinsics)]
110107
#![feature(drain_filter)]
111108

src/build_helper/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// NO-RUSTC-WRAPPER
2-
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
3-
41
use std::fs::File;
52
use std::path::{Path, PathBuf};
63
use std::process::{Command, Stdio};

src/libcore/cmp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,8 @@ mod impls {
10151015
// The order here is important to generate more optimal assembly.
10161016
// See <https://github.com/rust-lang/rust/issues/63758> for more info.
10171017
if *self < *other { Less }
1018-
else if *self > *other { Greater }
1019-
else { Equal }
1018+
else if *self == *other { Equal }
1019+
else { Greater }
10201020
}
10211021
}
10221022
)*)

src/librustc/ty/layout.rs

+19-30
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,12 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
273273
repr: &ReprOptions,
274274
kind: StructKind) -> Result<LayoutDetails, LayoutError<'tcx>> {
275275
let dl = self.data_layout();
276-
let packed = repr.packed();
277-
if packed && repr.align > 0 {
276+
let pack = repr.pack;
277+
if pack.is_some() && repr.align.is_some() {
278278
bug!("struct cannot be packed and aligned");
279279
}
280280

281-
let pack = Align::from_bytes(repr.pack as u64).unwrap();
282-
283-
let mut align = if packed {
281+
let mut align = if pack.is_some() {
284282
dl.i8_align
285283
} else {
286284
dl.aggregate_align
@@ -303,7 +301,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
303301
};
304302
let optimizing = &mut inverse_memory_index[..end];
305303
let field_align = |f: &TyLayout<'_>| {
306-
if packed { f.align.abi.min(pack) } else { f.align.abi }
304+
if let Some(pack) = pack { f.align.abi.min(pack) } else { f.align.abi }
307305
};
308306
match kind {
309307
StructKind::AlwaysSized |
@@ -334,7 +332,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
334332
let mut largest_niche_available = 0;
335333

336334
if let StructKind::Prefixed(prefix_size, prefix_align) = kind {
337-
let prefix_align = if packed {
335+
let prefix_align = if let Some(pack) = pack {
338336
prefix_align.min(pack)
339337
} else {
340338
prefix_align
@@ -355,7 +353,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
355353
}
356354

357355
// Invariant: offset < dl.obj_size_bound() <= 1<<61
358-
let field_align = if packed {
356+
let field_align = if let Some(pack) = pack {
359357
field.align.min(AbiAndPrefAlign::new(pack))
360358
} else {
361359
field.align
@@ -379,10 +377,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
379377
.ok_or(LayoutError::SizeOverflow(ty))?;
380378
}
381379

382-
if repr.align > 0 {
383-
let repr_align = repr.align as u64;
384-
align = align.max(AbiAndPrefAlign::new(Align::from_bytes(repr_align).unwrap()));
385-
debug!("univariant repr_align: {:?}", repr_align);
380+
if let Some(repr_align) = repr.align {
381+
align = align.max(AbiAndPrefAlign::new(repr_align));
386382
}
387383

388384
debug!("univariant min_size: {:?}", offset);
@@ -730,23 +726,18 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
730726
}).collect::<Result<IndexVec<VariantIdx, _>, _>>()?;
731727

732728
if def.is_union() {
733-
let packed = def.repr.packed();
734-
if packed && def.repr.align > 0 {
735-
bug!("Union cannot be packed and aligned");
729+
if def.repr.pack.is_some() && def.repr.align.is_some() {
730+
bug!("union cannot be packed and aligned");
736731
}
737732

738-
let pack = Align::from_bytes(def.repr.pack as u64).unwrap();
739-
740-
let mut align = if packed {
733+
let mut align = if def.repr.pack.is_some() {
741734
dl.i8_align
742735
} else {
743736
dl.aggregate_align
744737
};
745738

746-
if def.repr.align > 0 {
747-
let repr_align = def.repr.align as u64;
748-
align = align.max(
749-
AbiAndPrefAlign::new(Align::from_bytes(repr_align).unwrap()));
739+
if let Some(repr_align) = def.repr.align {
740+
align = align.max(AbiAndPrefAlign::new(repr_align));
750741
}
751742

752743
let optimize = !def.repr.inhibit_union_abi_opt();
@@ -755,13 +746,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
755746
let index = VariantIdx::new(0);
756747
for field in &variants[index] {
757748
assert!(!field.is_unsized());
758-
759-
let field_align = if packed {
760-
field.align.min(AbiAndPrefAlign::new(pack))
761-
} else {
762-
field.align
763-
};
764-
align = align.max(field_align);
749+
align = align.max(field.align);
765750

766751
// If all non-ZST fields have the same ABI, forward this ABI
767752
if optimize && !field.is_zst() {
@@ -796,6 +781,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
796781
size = cmp::max(size, field.size);
797782
}
798783

784+
if let Some(pack) = def.repr.pack {
785+
align = align.min(AbiAndPrefAlign::new(pack));
786+
}
787+
799788
return Ok(tcx.intern_layout(LayoutDetails {
800789
variants: Variants::Single { index },
801790
fields: FieldPlacement::Union(variants[index].len()),
@@ -1637,7 +1626,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
16371626
};
16381627

16391628
let adt_kind = adt_def.adt_kind();
1640-
let adt_packed = adt_def.repr.packed();
1629+
let adt_packed = adt_def.repr.pack.is_some();
16411630

16421631
let build_variant_info = |n: Option<Ident>,
16431632
flds: &[ast::Name],

src/librustc/ty/mod.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use arena::SyncDroplessArena;
3333
use crate::session::DataTypeKind;
3434

3535
use rustc_serialize::{self, Encodable, Encoder};
36+
use rustc_target::abi::Align;
3637
use std::cell::RefCell;
3738
use std::cmp::{self, Ordering};
3839
use std::fmt;
@@ -2057,8 +2058,8 @@ impl_stable_hash_for!(struct ReprFlags {
20572058
#[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, Default)]
20582059
pub struct ReprOptions {
20592060
pub int: Option<attr::IntType>,
2060-
pub align: u32,
2061-
pub pack: u32,
2061+
pub align: Option<Align>,
2062+
pub pack: Option<Align>,
20622063
pub flags: ReprFlags,
20632064
}
20642065

@@ -2073,18 +2074,19 @@ impl ReprOptions {
20732074
pub fn new(tcx: TyCtxt<'_>, did: DefId) -> ReprOptions {
20742075
let mut flags = ReprFlags::empty();
20752076
let mut size = None;
2076-
let mut max_align = 0;
2077-
let mut min_pack = 0;
2077+
let mut max_align: Option<Align> = None;
2078+
let mut min_pack: Option<Align> = None;
20782079
for attr in tcx.get_attrs(did).iter() {
20792080
for r in attr::find_repr_attrs(&tcx.sess.parse_sess, attr) {
20802081
flags.insert(match r {
20812082
attr::ReprC => ReprFlags::IS_C,
20822083
attr::ReprPacked(pack) => {
2083-
min_pack = if min_pack > 0 {
2084-
cmp::min(pack, min_pack)
2084+
let pack = Align::from_bytes(pack as u64).unwrap();
2085+
min_pack = Some(if let Some(min_pack) = min_pack {
2086+
min_pack.min(pack)
20852087
} else {
20862088
pack
2087-
};
2089+
});
20882090
ReprFlags::empty()
20892091
},
20902092
attr::ReprTransparent => ReprFlags::IS_TRANSPARENT,
@@ -2094,7 +2096,7 @@ impl ReprOptions {
20942096
ReprFlags::empty()
20952097
},
20962098
attr::ReprAlign(align) => {
2097-
max_align = cmp::max(align, max_align);
2099+
max_align = max_align.max(Some(Align::from_bytes(align as u64).unwrap()));
20982100
ReprFlags::empty()
20992101
},
21002102
});
@@ -2113,7 +2115,7 @@ impl ReprOptions {
21132115
#[inline]
21142116
pub fn c(&self) -> bool { self.flags.contains(ReprFlags::IS_C) }
21152117
#[inline]
2116-
pub fn packed(&self) -> bool { self.pack > 0 }
2118+
pub fn packed(&self) -> bool { self.pack.is_some() }
21172119
#[inline]
21182120
pub fn transparent(&self) -> bool { self.flags.contains(ReprFlags::IS_TRANSPARENT) }
21192121
#[inline]
@@ -2133,8 +2135,12 @@ impl ReprOptions {
21332135
/// Returns `true` if this `#[repr()]` should inhibit struct field reordering
21342136
/// optimizations, such as with `repr(C)`, `repr(packed(1))`, or `repr(<int>)`.
21352137
pub fn inhibit_struct_field_reordering_opt(&self) -> bool {
2136-
self.flags.intersects(ReprFlags::IS_UNOPTIMISABLE) || self.pack == 1 ||
2137-
self.int.is_some()
2138+
if let Some(pack) = self.pack {
2139+
if pack.bytes() == 1 {
2140+
return true;
2141+
}
2142+
}
2143+
self.flags.intersects(ReprFlags::IS_UNOPTIMISABLE) || self.int.is_some()
21382144
}
21392145

21402146
/// Returns `true` if this `#[repr()]` should inhibit union ABI optimisations.

src/librustc_metadata/decoder.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,7 @@ impl<'a, 'tcx> CrateMetadata {
527527
attributes.iter().cloned().map(Symbol::intern).collect::<Vec<_>>();
528528
(
529529
trait_name,
530-
SyntaxExtensionKind::Derive(Box::new(ProcMacroDerive {
531-
client, attrs: helper_attrs.clone()
532-
})),
530+
SyntaxExtensionKind::Derive(Box::new(ProcMacroDerive { client })),
533531
helper_attrs,
534532
)
535533
}

0 commit comments

Comments
 (0)