Skip to content

Commit

Permalink
Auto merge of #63998 - Centril:rollup-pfuwxz3, r=Centril
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 29, 2019
2 parents 85ed538 + 3f05cf6 commit 7445622
Show file tree
Hide file tree
Showing 33 changed files with 430 additions and 325 deletions.
3 changes: 0 additions & 3 deletions src/bootstrap/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
//! parent directory, and otherwise documentation can be found throughout the `build`
//! directory in each respective module.

// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]

use std::env;

use bootstrap::{Config, Build};
Expand Down
8 changes: 3 additions & 5 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
//! switching compilers for the bootstrap and for build scripts will probably
//! never get replaced.

// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]

use std::env;
use std::ffi::OsString;
use std::io;
Expand Down Expand Up @@ -124,8 +121,9 @@ fn main() {

if env::var_os("RUSTC_DENY_WARNINGS").is_some() &&
env::var_os("RUSTC_EXTERNAL_TOOL").is_none() {
// When extending this list, search for `NO-RUSTC-WRAPPER` and add the new lints
// there as well, some code doesn't go through this `rustc` wrapper.
// When extending this list, add the new lints to the RUSTFLAGS of the
// build_bootstrap function of src/bootstrap/bootstrap.py as well as
// some code doesn't go through this `rustc` wrapper.
cmd.arg("-Dwarnings");
cmd.arg("-Drust_2018_idioms");
cmd.arg("-Dunused_lifetimes");
Expand Down
3 changes: 0 additions & 3 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
//!
//! See comments in `src/bootstrap/rustc.rs` for more information.

// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]

use std::env;
use std::process::Command;
use std::path::PathBuf;
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@ def build_bootstrap(self):
target_linker = self.get_toml("linker", build_section)
if target_linker is not None:
env["RUSTFLAGS"] += "-C linker=" + target_linker + " "
if self.get_toml("deny-warnings", "rust") != "false":
env["RUSTFLAGS"] += "-Dwarnings -Drust_2018_idioms -Dunused_lifetimes "

env["PATH"] = os.path.join(self.bin_root(), "bin") + \
os.pathsep + env["PATH"]
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Step for Std {
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.all_krates("std")
run.all_krates("test")
}

fn make_run(run: RunConfig<'_>) {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Step for Std {
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.all_krates("std")
run.all_krates("test")
}

fn make_run(run: RunConfig<'_>) {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl Step for Std {

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

fn make_run(run: RunConfig<'_>) {
Expand Down
3 changes: 0 additions & 3 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@
//! More documentation can be found in each respective module below, and you can
//! also check out the `src/bootstrap/README.md` file for more information.

// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]

#![feature(core_intrinsics)]
#![feature(drain_filter)]

Expand Down
3 changes: 0 additions & 3 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]

use std::fs::File;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,8 @@ mod impls {
// The order here is important to generate more optimal assembly.
// See <https://github.com/rust-lang/rust/issues/63758> for more info.
if *self < *other { Less }
else if *self > *other { Greater }
else { Equal }
else if *self == *other { Equal }
else { Greater }
}
}
)*)
Expand Down
49 changes: 19 additions & 30 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,12 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
repr: &ReprOptions,
kind: StructKind) -> Result<LayoutDetails, LayoutError<'tcx>> {
let dl = self.data_layout();
let packed = repr.packed();
if packed && repr.align > 0 {
let pack = repr.pack;
if pack.is_some() && repr.align.is_some() {
bug!("struct cannot be packed and aligned");
}

let pack = Align::from_bytes(repr.pack as u64).unwrap();

let mut align = if packed {
let mut align = if pack.is_some() {
dl.i8_align
} else {
dl.aggregate_align
Expand All @@ -303,7 +301,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
};
let optimizing = &mut inverse_memory_index[..end];
let field_align = |f: &TyLayout<'_>| {
if packed { f.align.abi.min(pack) } else { f.align.abi }
if let Some(pack) = pack { f.align.abi.min(pack) } else { f.align.abi }
};
match kind {
StructKind::AlwaysSized |
Expand Down Expand Up @@ -334,7 +332,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
let mut largest_niche_available = 0;

if let StructKind::Prefixed(prefix_size, prefix_align) = kind {
let prefix_align = if packed {
let prefix_align = if let Some(pack) = pack {
prefix_align.min(pack)
} else {
prefix_align
Expand All @@ -355,7 +353,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
}

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

if repr.align > 0 {
let repr_align = repr.align as u64;
align = align.max(AbiAndPrefAlign::new(Align::from_bytes(repr_align).unwrap()));
debug!("univariant repr_align: {:?}", repr_align);
if let Some(repr_align) = repr.align {
align = align.max(AbiAndPrefAlign::new(repr_align));
}

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

if def.is_union() {
let packed = def.repr.packed();
if packed && def.repr.align > 0 {
bug!("Union cannot be packed and aligned");
if def.repr.pack.is_some() && def.repr.align.is_some() {
bug!("union cannot be packed and aligned");
}

let pack = Align::from_bytes(def.repr.pack as u64).unwrap();

let mut align = if packed {
let mut align = if def.repr.pack.is_some() {
dl.i8_align
} else {
dl.aggregate_align
};

if def.repr.align > 0 {
let repr_align = def.repr.align as u64;
align = align.max(
AbiAndPrefAlign::new(Align::from_bytes(repr_align).unwrap()));
if let Some(repr_align) = def.repr.align {
align = align.max(AbiAndPrefAlign::new(repr_align));
}

let optimize = !def.repr.inhibit_union_abi_opt();
Expand All @@ -755,13 +746,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
let index = VariantIdx::new(0);
for field in &variants[index] {
assert!(!field.is_unsized());

let field_align = if packed {
field.align.min(AbiAndPrefAlign::new(pack))
} else {
field.align
};
align = align.max(field_align);
align = align.max(field.align);

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

if let Some(pack) = def.repr.pack {
align = align.min(AbiAndPrefAlign::new(pack));
}

return Ok(tcx.intern_layout(LayoutDetails {
variants: Variants::Single { index },
fields: FieldPlacement::Union(variants[index].len()),
Expand Down Expand Up @@ -1637,7 +1626,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
};

let adt_kind = adt_def.adt_kind();
let adt_packed = adt_def.repr.packed();
let adt_packed = adt_def.repr.pack.is_some();

let build_variant_info = |n: Option<Ident>,
flds: &[ast::Name],
Expand Down
28 changes: 17 additions & 11 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use arena::SyncDroplessArena;
use crate::session::DataTypeKind;

use rustc_serialize::{self, Encodable, Encoder};
use rustc_target::abi::Align;
use std::cell::RefCell;
use std::cmp::{self, Ordering};
use std::fmt;
Expand Down Expand Up @@ -2057,8 +2058,8 @@ impl_stable_hash_for!(struct ReprFlags {
#[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, Default)]
pub struct ReprOptions {
pub int: Option<attr::IntType>,
pub align: u32,
pub pack: u32,
pub align: Option<Align>,
pub pack: Option<Align>,
pub flags: ReprFlags,
}

Expand All @@ -2073,18 +2074,19 @@ impl ReprOptions {
pub fn new(tcx: TyCtxt<'_>, did: DefId) -> ReprOptions {
let mut flags = ReprFlags::empty();
let mut size = None;
let mut max_align = 0;
let mut min_pack = 0;
let mut max_align: Option<Align> = None;
let mut min_pack: Option<Align> = None;
for attr in tcx.get_attrs(did).iter() {
for r in attr::find_repr_attrs(&tcx.sess.parse_sess, attr) {
flags.insert(match r {
attr::ReprC => ReprFlags::IS_C,
attr::ReprPacked(pack) => {
min_pack = if min_pack > 0 {
cmp::min(pack, min_pack)
let pack = Align::from_bytes(pack as u64).unwrap();
min_pack = Some(if let Some(min_pack) = min_pack {
min_pack.min(pack)
} else {
pack
};
});
ReprFlags::empty()
},
attr::ReprTransparent => ReprFlags::IS_TRANSPARENT,
Expand All @@ -2094,7 +2096,7 @@ impl ReprOptions {
ReprFlags::empty()
},
attr::ReprAlign(align) => {
max_align = cmp::max(align, max_align);
max_align = max_align.max(Some(Align::from_bytes(align as u64).unwrap()));
ReprFlags::empty()
},
});
Expand All @@ -2113,7 +2115,7 @@ impl ReprOptions {
#[inline]
pub fn c(&self) -> bool { self.flags.contains(ReprFlags::IS_C) }
#[inline]
pub fn packed(&self) -> bool { self.pack > 0 }
pub fn packed(&self) -> bool { self.pack.is_some() }
#[inline]
pub fn transparent(&self) -> bool { self.flags.contains(ReprFlags::IS_TRANSPARENT) }
#[inline]
Expand All @@ -2133,8 +2135,12 @@ impl ReprOptions {
/// Returns `true` if this `#[repr()]` should inhibit struct field reordering
/// optimizations, such as with `repr(C)`, `repr(packed(1))`, or `repr(<int>)`.
pub fn inhibit_struct_field_reordering_opt(&self) -> bool {
self.flags.intersects(ReprFlags::IS_UNOPTIMISABLE) || self.pack == 1 ||
self.int.is_some()
if let Some(pack) = self.pack {
if pack.bytes() == 1 {
return true;
}
}
self.flags.intersects(ReprFlags::IS_UNOPTIMISABLE) || self.int.is_some()
}

/// Returns `true` if this `#[repr()]` should inhibit union ABI optimisations.
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,7 @@ impl<'a, 'tcx> CrateMetadata {
attributes.iter().cloned().map(Symbol::intern).collect::<Vec<_>>();
(
trait_name,
SyntaxExtensionKind::Derive(Box::new(ProcMacroDerive {
client, attrs: helper_attrs.clone()
})),
SyntaxExtensionKind::Derive(Box::new(ProcMacroDerive { client })),
helper_attrs,
)
}
Expand Down
Loading

0 comments on commit 7445622

Please sign in to comment.