diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 1c091d68a2ef1..5ec2e32b6a4c1 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -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. diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 2a62d0b5ee39a..de336c2922940 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -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 }) + } } } diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 6a0f42c6dbb66..59501f1474fb0 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -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), diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 2e8dd623d744d..f63a5ef301a68 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -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; diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 19f33ef5d45a8..e5719407da639 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -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), diff --git a/src/librustc_traits/normalize_erasing_regions.rs b/src/librustc_traits/normalize_erasing_regions.rs index 14f8694dbf72a..f781d9c54e4a1 100644 --- a/src/librustc_traits/normalize_erasing_regions.rs +++ b/src/librustc_traits/normalize_erasing_regions.rs @@ -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 diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2291add0c511b..563db6cfd5b93 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1724,8 +1724,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } ast::TraitItemKind::Type(_, ref default) => { - // We use two if statements instead of something like match guards so that both - // of these errors can be emitted if both cases apply. + // We use three if statements instead of something like match guards so that all + // of these errors can be emitted if all cases apply. if default.is_some() { gate_feature_post!(&self, associated_type_defaults, ti.span, "associated type defaults are unstable"); @@ -1734,6 +1734,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { gate_feature_post!(&self, generic_associated_types, ti.span, "generic associated types are unstable"); } + if !ti.generics.where_clause.predicates.is_empty() { + gate_feature_post!(&self, generic_associated_types, ti.span, + "where clauses on associated types are unstable"); + } } _ => {} } diff --git a/src/test/run-pass/issue-49685.rs b/src/test/run-pass/issue-49685.rs new file mode 100644 index 0000000000000..1e4e795532371 --- /dev/null +++ b/src/test/run-pass/issue-49685.rs @@ -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 or the MIT license +// , 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 { + Some(()).into_iter().flat_map(|_| vec![]) +} diff --git a/src/test/ui/feature-gate-generic_associated_types.rs b/src/test/ui/feature-gate-generic_associated_types.rs index 724ec2496f24c..3470662686643 100644 --- a/src/test/ui/feature-gate-generic_associated_types.rs +++ b/src/test/ui/feature-gate-generic_associated_types.rs @@ -15,6 +15,7 @@ trait PointerFamily { //~^ ERROR generic associated types are unstable type Pointer2: Deref where T: Clone, U: Clone; //~^ ERROR generic associated types are unstable + //~| ERROR where clauses on associated types are unstable } struct Foo; @@ -25,4 +26,10 @@ impl PointerFamily for Foo { //~^ ERROR generic associated types are unstable } +trait Bar { + type Assoc where Self: Sized; + //~^ ERROR where clauses on associated types are unstable +} + + fn main() {} diff --git a/src/test/ui/feature-gate-generic_associated_types.stderr b/src/test/ui/feature-gate-generic_associated_types.stderr index 5f23def88eb06..d7891f13c6b4d 100644 --- a/src/test/ui/feature-gate-generic_associated_types.stderr +++ b/src/test/ui/feature-gate-generic_associated_types.stderr @@ -14,8 +14,16 @@ LL | type Pointer2: Deref where T: Clone, U: Clone; | = help: add #![feature(generic_associated_types)] to the crate attributes to enable +error[E0658]: where clauses on associated types are unstable (see issue #44265) + --> $DIR/feature-gate-generic_associated_types.rs:16:5 + | +LL | type Pointer2: Deref where T: Clone, U: Clone; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(generic_associated_types)] to the crate attributes to enable + error[E0658]: generic associated types are unstable (see issue #44265) - --> $DIR/feature-gate-generic_associated_types.rs:22:5 + --> $DIR/feature-gate-generic_associated_types.rs:23:5 | LL | type Pointer = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,13 +31,21 @@ LL | type Pointer = Box; = help: add #![feature(generic_associated_types)] to the crate attributes to enable error[E0658]: generic associated types are unstable (see issue #44265) - --> $DIR/feature-gate-generic_associated_types.rs:24:5 + --> $DIR/feature-gate-generic_associated_types.rs:25:5 | LL | type Pointer2 = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(generic_associated_types)] to the crate attributes to enable -error: aborting due to 4 previous errors +error[E0658]: where clauses on associated types are unstable (see issue #44265) + --> $DIR/feature-gate-generic_associated_types.rs:30:5 + | +LL | type Assoc where Self: Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(generic_associated_types)] to the crate attributes to enable + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0658`.