Skip to content

Commit

Permalink
Auto merge of #50253 - nikomatsakis:regressions-2018-04-26, r=eddyb
Browse files Browse the repository at this point in the history
drop elaboration should reveal all

This used to happen implicitly through the normalization function; but we now keep the param-env as is, which seems less surprising.

cc #49685

r? @eddyb
  • Loading branch information
bors committed Apr 26, 2018
2 parents 7f3444e + 86e9a7a commit 7d8f0e2
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/librustc/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> {
selcx,
register_region_obligations: self.register_region_obligations
});
debug!("select: outcome={:?}", outcome);
debug!("select: outcome={:#?}", outcome);

// FIXME: if we kept the original cache key, we could mark projection
// obligations as complete for the projection cache here.
Expand Down
10 changes: 8 additions & 2 deletions src/librustc/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ pub fn poly_project_and_unify_type<'cx, 'gcx, 'tcx>(
let span = obligation.cause.span;
match infcx.leak_check(false, span, &skol_map, snapshot) {
Ok(()) => Ok(infcx.plug_leaks(skol_map, snapshot, result)),
Err(e) => Err(MismatchedProjectionTypes { err: e }),
Err(e) => {
debug!("poly_project_and_unify_type: leak check encountered error {:?}", e);
Err(MismatchedProjectionTypes { err: e })
}
}
}
Err(e) => {
Expand Down Expand Up @@ -243,7 +246,10 @@ fn project_and_unify_type<'cx, 'gcx, 'tcx>(
obligations.extend(inferred_obligations);
Ok(Some(obligations))
},
Err(err) => Err(MismatchedProjectionTypes { err: err }),
Err(err) => {
debug!("project_and_unify_type: equating types encountered error {:?}", err);
Err(MismatchedProjectionTypes { err: err })
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

if let Some(..) = ty {
let patch = {
let param_env = tcx.param_env(def_id);
let param_env = tcx.param_env(def_id).with_reveal_all();
let mut elaborator = DropShimElaborator {
mir: &mir,
patch: MirPatch::new(&mir),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/elaborate_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl MirPass for ElaborateDrops {
(hir::BodyOwnerKind::Fn, None) => {},
_ => return
}
let param_env = tcx.param_env(src.def_id);
let param_env = tcx.param_env(src.def_id).with_reveal_all();
let move_data = MoveData::gather_moves(mir, tcx).unwrap();
let elaborate_patch = {
let mir = &*mir;
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_mir/util/elaborate_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use rustc::hir;
use rustc::mir::*;
use rustc::middle::const_val::ConstVal;
use rustc::middle::lang_items;
use rustc::traits::Reveal;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::subst::{Kind, Substs};
use rustc::ty::util::IntTypeExt;
Expand Down Expand Up @@ -206,6 +207,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
let field = Field::new(i);
let subpath = self.elaborator.field_subpath(variant_path, field);

assert_eq!(self.elaborator.param_env().reveal, Reveal::All);
let field_ty = self.tcx().normalize_erasing_regions(
self.elaborator.param_env(),
f.ty(self.tcx(), substs),
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_traits/normalize_erasing_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ crate fn normalize_ty_after_erasing_regions<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
goal: ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> Ty<'tcx> {
debug!("normalize_ty_after_erasing_regions(goal={:#?})", goal);

let ParamEnvAnd { param_env, value } = goal;
tcx.sess.perf_stats.normalize_ty_after_erasing_regions.fetch_add(1, Ordering::Relaxed);
tcx.infer_ctxt().enter(|infcx| {
Expand Down
22 changes: 22 additions & 0 deletions src/test/run-pass/issue-49685.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Regression test for #49685: drop elaboration was not revealing the
// value of `impl Trait` returns, leading to an ICE.

fn main() {
let _ = Some(())
.into_iter()
.flat_map(|_| Some(()).into_iter().flat_map(func));
}

fn func(_: ()) -> impl Iterator<Item = ()> {
Some(()).into_iter().flat_map(|_| vec![])
}

0 comments on commit 7d8f0e2

Please sign in to comment.