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
This commit is contained in:
commit
7d8f0e22f5
@ -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.
|
||||
|
@ -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) => {
|
||||
@ -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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
@ -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),
|
||||
|
@ -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| {
|
||||
|
22
src/test/run-pass/issue-49685.rs
Normal file
22
src/test/run-pass/issue-49685.rs
Normal file
@ -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![])
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user