Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta] More backports #50274

Merged
merged 4 commits into from
Apr 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Down
8 changes: 6 additions & 2 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
}
}
_ => {}
}
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![])
}
7 changes: 7 additions & 0 deletions src/test/ui/feature-gate-generic_associated_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ trait PointerFamily<U> {
//~^ ERROR generic associated types are unstable
type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
//~^ ERROR generic associated types are unstable
//~| ERROR where clauses on associated types are unstable
}

struct Foo;
Expand All @@ -25,4 +26,10 @@ impl PointerFamily<u32> 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() {}
22 changes: 19 additions & 3 deletions src/test/ui/feature-gate-generic_associated_types.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,38 @@ LL | type Pointer2<T>: Deref<Target = T> 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<T>: Deref<Target = T> 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<usize> = Box<usize>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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<u32> = Box<u32>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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`.