Skip to content

Commit 7d8f0e2

Browse files
committed
Auto merge of #50253 - nikomatsakis:regressions-2018-04-26, r=eddyb
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
2 parents 7f3444e + 86e9a7a commit 7d8f0e2

File tree

7 files changed

+37
-5
lines changed

7 files changed

+37
-5
lines changed

src/librustc/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> {
112112
selcx,
113113
register_region_obligations: self.register_region_obligations
114114
});
115-
debug!("select: outcome={:?}", outcome);
115+
debug!("select: outcome={:#?}", outcome);
116116

117117
// FIXME: if we kept the original cache key, we could mark projection
118118
// obligations as complete for the projection cache here.

src/librustc/traits/project.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ pub fn poly_project_and_unify_type<'cx, 'gcx, 'tcx>(
196196
let span = obligation.cause.span;
197197
match infcx.leak_check(false, span, &skol_map, snapshot) {
198198
Ok(()) => Ok(infcx.plug_leaks(skol_map, snapshot, result)),
199-
Err(e) => Err(MismatchedProjectionTypes { err: e }),
199+
Err(e) => {
200+
debug!("poly_project_and_unify_type: leak check encountered error {:?}", e);
201+
Err(MismatchedProjectionTypes { err: e })
202+
}
200203
}
201204
}
202205
Err(e) => {
@@ -243,7 +246,10 @@ fn project_and_unify_type<'cx, 'gcx, 'tcx>(
243246
obligations.extend(inferred_obligations);
244247
Ok(Some(obligations))
245248
},
246-
Err(err) => Err(MismatchedProjectionTypes { err: err }),
249+
Err(err) => {
250+
debug!("project_and_unify_type: equating types encountered error {:?}", err);
251+
Err(MismatchedProjectionTypes { err: err })
252+
}
247253
}
248254
}
249255

src/librustc_mir/shim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
210210

211211
if let Some(..) = ty {
212212
let patch = {
213-
let param_env = tcx.param_env(def_id);
213+
let param_env = tcx.param_env(def_id).with_reveal_all();
214214
let mut elaborator = DropShimElaborator {
215215
mir: &mir,
216216
patch: MirPatch::new(&mir),

src/librustc_mir/transform/elaborate_drops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl MirPass for ElaborateDrops {
5050
(hir::BodyOwnerKind::Fn, None) => {},
5151
_ => return
5252
}
53-
let param_env = tcx.param_env(src.def_id);
53+
let param_env = tcx.param_env(src.def_id).with_reveal_all();
5454
let move_data = MoveData::gather_moves(mir, tcx).unwrap();
5555
let elaborate_patch = {
5656
let mir = &*mir;

src/librustc_mir/util/elaborate_drops.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc::hir;
1313
use rustc::mir::*;
1414
use rustc::middle::const_val::ConstVal;
1515
use rustc::middle::lang_items;
16+
use rustc::traits::Reveal;
1617
use rustc::ty::{self, Ty, TyCtxt};
1718
use rustc::ty::subst::{Kind, Substs};
1819
use rustc::ty::util::IntTypeExt;
@@ -206,6 +207,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
206207
let field = Field::new(i);
207208
let subpath = self.elaborator.field_subpath(variant_path, field);
208209

210+
assert_eq!(self.elaborator.param_env().reveal, Reveal::All);
209211
let field_ty = self.tcx().normalize_erasing_regions(
210212
self.elaborator.param_env(),
211213
f.ty(self.tcx(), substs),

src/librustc_traits/normalize_erasing_regions.rs

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ crate fn normalize_ty_after_erasing_regions<'tcx>(
1717
tcx: TyCtxt<'_, 'tcx, 'tcx>,
1818
goal: ParamEnvAnd<'tcx, Ty<'tcx>>,
1919
) -> Ty<'tcx> {
20+
debug!("normalize_ty_after_erasing_regions(goal={:#?})", goal);
21+
2022
let ParamEnvAnd { param_env, value } = goal;
2123
tcx.sess.perf_stats.normalize_ty_after_erasing_regions.fetch_add(1, Ordering::Relaxed);
2224
tcx.infer_ctxt().enter(|infcx| {

src/test/run-pass/issue-49685.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Regression test for #49685: drop elaboration was not revealing the
12+
// value of `impl Trait` returns, leading to an ICE.
13+
14+
fn main() {
15+
let _ = Some(())
16+
.into_iter()
17+
.flat_map(|_| Some(()).into_iter().flat_map(func));
18+
}
19+
20+
fn func(_: ()) -> impl Iterator<Item = ()> {
21+
Some(()).into_iter().flat_map(|_| vec![])
22+
}

0 commit comments

Comments
 (0)