Skip to content

Commit 7688266

Browse files
committed
Auto merge of rust-lang#71014 - Centril:rollup-3lc8cnt, r=Centril
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
2 parents 1f3b659 + 0a6d177 commit 7688266

File tree

7 files changed

+49
-2
lines changed

7 files changed

+49
-2
lines changed

src/bootstrap/builder.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,13 @@ impl<'a> Builder<'a> {
10991099

11001100
if self.config.deny_warnings {
11011101
rustflags.arg("-Dwarnings");
1102+
1103+
// FIXME(#58633) hide "unused attribute" errors in incremental
1104+
// builds of the standard library, as the underlying checks are
1105+
// not yet properly integrated with incremental recompilation.
1106+
if mode == Mode::Std && compiler.stage == 0 && self.config.incremental {
1107+
rustflags.arg("-Aunused-attributes");
1108+
}
11021109
}
11031110
}
11041111

src/librustc_mir/interpret/machine.rs

+8
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ pub trait Machine<'mir, 'tcx>: Sized {
254254
kind: Option<MemoryKind<Self::MemoryKind>>,
255255
) -> (Cow<'b, Allocation<Self::PointerTag, Self::AllocExtra>>, Self::PointerTag);
256256

257+
/// Called to notify the machine before a deallocation occurs.
258+
fn before_deallocation(
259+
_memory_extra: &mut Self::MemoryExtra,
260+
_id: AllocId,
261+
) -> InterpResult<'tcx> {
262+
Ok(())
263+
}
264+
257265
/// Return the "base" tag for the given *global* allocation: the one that is used for direct
258266
/// accesses to this static/const/fn allocation. If `id` is not a global allocation,
259267
/// this will return an unusable tag (i.e., accesses will be UB)!

src/librustc_mir/interpret/memory.rs

+2
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
254254
);
255255
}
256256

257+
M::before_deallocation(&mut self.extra, ptr.alloc_id)?;
258+
257259
let (alloc_kind, mut alloc) = match self.alloc_map.remove(&ptr.alloc_id) {
258260
Some(alloc) => alloc,
259261
None => {

src/librustc_mir/transform/generator.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -721,15 +721,18 @@ fn compute_layout<'tcx>(
721721
_ => bug!(),
722722
};
723723

724+
let param_env = tcx.param_env(source.def_id());
725+
724726
for (local, decl) in body.local_decls.iter_enumerated() {
725727
// Ignore locals which are internal or not live
726728
if !live_locals.contains(local) || decl.internal {
727729
continue;
728730
}
731+
let decl_ty = tcx.normalize_erasing_regions(param_env, decl.ty);
729732

730733
// Sanity check that typeck knows about the type of locals which are
731734
// live across a suspension point
732-
if !allowed.contains(&decl.ty) && !allowed_upvars.contains(&decl.ty) {
735+
if !allowed.contains(&decl_ty) && !allowed_upvars.contains(&decl_ty) {
733736
span_bug!(
734737
body.span,
735738
"Broken MIR: generator contains type {} in MIR, \

src/librustc_typeck/check/cast.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,10 @@ impl<'a, 'tcx> CastCheck<'tcx> {
536536
match self.expr_ty.kind {
537537
ty::FnDef(..) => {
538538
// Attempt a coercion to a fn pointer type.
539-
let f = self.expr_ty.fn_sig(fcx.tcx);
539+
let f = fcx.normalize_associated_types_in(
540+
self.expr.span,
541+
&self.expr_ty.fn_sig(fcx.tcx),
542+
);
540543
let res = fcx.try_coerce(
541544
self.expr,
542545
self.expr_ty,

src/test/ui/issues/issue-54094.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
trait Zoo {
3+
type X;
4+
}
5+
6+
impl Zoo for u16 {
7+
type X = usize;
8+
}
9+
10+
fn foo(abc: <u16 as Zoo>::X) {}
11+
12+
fn main() {
13+
let x: *const u8 = foo as _;
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
// edition:2018
3+
// compile-flags: --crate-type=lib
4+
5+
pub async fn test() {
6+
const C: usize = 4;
7+
foo(&mut [0u8; C]).await;
8+
}
9+
10+
async fn foo(_: &mut [u8]) {}

0 commit comments

Comments
 (0)