Auto merge of #71014 - Centril:rollup-3lc8cnt, r=Centril

Rollup of 5 pull requests

Successful merges:

 - #69573 (tests encoding current behavior for various cases of "binding" to _.)
 - #70881 (bootstrap: work around "unused attribute" errors in incremental stdlib rebuilds.)
 - #70957 (Normalize MIR locals' types for generator layout computation.)
 - #70962 (added machine hooks to track deallocations)
 - #70982 (Normalize function signature in function casting check procedure)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-04-11 12:22:00 +00:00
commit 76882666eb
7 changed files with 49 additions and 2 deletions

View File

@ -1099,6 +1099,13 @@ impl<'a> Builder<'a> {
if self.config.deny_warnings {
rustflags.arg("-Dwarnings");
// FIXME(#58633) hide "unused attribute" errors in incremental
// builds of the standard library, as the underlying checks are
// not yet properly integrated with incremental recompilation.
if mode == Mode::Std && compiler.stage == 0 && self.config.incremental {
rustflags.arg("-Aunused-attributes");
}
}
}

View File

@ -254,6 +254,14 @@ pub trait Machine<'mir, 'tcx>: Sized {
kind: Option<MemoryKind<Self::MemoryKind>>,
) -> (Cow<'b, Allocation<Self::PointerTag, Self::AllocExtra>>, Self::PointerTag);
/// Called to notify the machine before a deallocation occurs.
fn before_deallocation(
_memory_extra: &mut Self::MemoryExtra,
_id: AllocId,
) -> InterpResult<'tcx> {
Ok(())
}
/// Return the "base" tag for the given *global* allocation: the one that is used for direct
/// accesses to this static/const/fn allocation. If `id` is not a global allocation,
/// this will return an unusable tag (i.e., accesses will be UB)!

View File

@ -254,6 +254,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
);
}
M::before_deallocation(&mut self.extra, ptr.alloc_id)?;
let (alloc_kind, mut alloc) = match self.alloc_map.remove(&ptr.alloc_id) {
Some(alloc) => alloc,
None => {

View File

@ -721,15 +721,18 @@ fn compute_layout<'tcx>(
_ => bug!(),
};
let param_env = tcx.param_env(source.def_id());
for (local, decl) in body.local_decls.iter_enumerated() {
// Ignore locals which are internal or not live
if !live_locals.contains(local) || decl.internal {
continue;
}
let decl_ty = tcx.normalize_erasing_regions(param_env, decl.ty);
// Sanity check that typeck knows about the type of locals which are
// live across a suspension point
if !allowed.contains(&decl.ty) && !allowed_upvars.contains(&decl.ty) {
if !allowed.contains(&decl_ty) && !allowed_upvars.contains(&decl_ty) {
span_bug!(
body.span,
"Broken MIR: generator contains type {} in MIR, \

View File

@ -536,7 +536,10 @@ impl<'a, 'tcx> CastCheck<'tcx> {
match self.expr_ty.kind {
ty::FnDef(..) => {
// Attempt a coercion to a fn pointer type.
let f = self.expr_ty.fn_sig(fcx.tcx);
let f = fcx.normalize_associated_types_in(
self.expr.span,
&self.expr_ty.fn_sig(fcx.tcx),
);
let res = fcx.try_coerce(
self.expr,
self.expr_ty,

View File

@ -0,0 +1,14 @@
// check-pass
trait Zoo {
type X;
}
impl Zoo for u16 {
type X = usize;
}
fn foo(abc: <u16 as Zoo>::X) {}
fn main() {
let x: *const u8 = foo as _;
}

View File

@ -0,0 +1,10 @@
// check-pass
// edition:2018
// compile-flags: --crate-type=lib
pub async fn test() {
const C: usize = 4;
foo(&mut [0u8; C]).await;
}
async fn foo(_: &mut [u8]) {}