Skip to content

Commit

Permalink
Auto merge of rust-lang#71014 - Centril:rollup-3lc8cnt, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

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

Failed merges:

r? @ghost
  • Loading branch information
bors committed Apr 11, 2020
2 parents 1f3b659 + 0a6d177 commit 7688266
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/librustc_mir/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)!
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_mir/transform/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_typeck/check/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/issues/issue-54094.rs
Original file line number Diff line number Diff line change
@@ -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 _;
}
10 changes: 10 additions & 0 deletions src/test/ui/repeat_count_const_in_async_fn.rs
Original file line number Diff line number Diff line change
@@ -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]) {}

0 comments on commit 7688266

Please sign in to comment.