use crate::mir::interpret::GlobalId;
use crate::ty::fast_reject;
use crate::ty::relate::TypeRelation;
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable};
use crate::hir;
if let ty::FnSig {
unsafety: hir::Unsafety::Normal,
abi: Abi::Rust,
- variadic: false,
+ c_variadic: false,
..
} = self_ty.fn_sig(self.tcx()).skip_binder()
{
fn vtable_impl(
&mut self,
impl_def_id: DefId,
- mut substs: Normalized<'tcx, &'tcx Substs<'tcx>>,
+ mut substs: Normalized<'tcx, SubstsRef<'tcx>>,
cause: ObligationCause<'tcx>,
recursion_depth: usize,
param_env: ty::ParamEnv<'tcx>,
tcx.mk_existential_predicates(iter)
});
let source_trait = tcx.mk_dynamic(existential_predicates, r_b);
+
+ // Require that the traits involved in this upcast are **equal**;
+ // only the **lifetime bound** is changed.
+ //
+ // FIXME: This condition is arguably too strong -- it
+ // would suffice for the source trait to be a
+ // *subtype* of the target trait. In particular
+ // changing from something like `for<'a, 'b> Foo<'a,
+ // 'b>` to `for<'a> Foo<'a, 'a>` should be
+ // permitted. And, indeed, in the in commit
+ // 904a0bde93f0348f69914ee90b1f8b6e4e0d7cbc, this
+ // condition was loosened. However, when the leak check was added
+ // back, using subtype here actually guies the coercion code in
+ // such a way that it accepts `old-lub-glb-object.rs`. This is probably
+ // a good thing, but I've modified this to `.eq` because I want
+ // to continue rejecting that test (as we have done for quite some time)
+ // before we are firmly comfortable with what our behavior
+ // should be there. -nikomatsakis
let InferOk { obligations, .. } = self.infcx
.at(&obligation.cause, obligation.param_env)
- .sup(target, source_trait)
+ .eq(target, source_trait) // FIXME -- see below
.map_err(|_| Unimplemented)?;
nested.extend(obligations);
impl_def_id: DefId,
obligation: &TraitObligation<'tcx>,
snapshot: &CombinedSnapshot<'_, 'tcx>,
- ) -> Normalized<'tcx, &'tcx Substs<'tcx>> {
+ ) -> Normalized<'tcx, SubstsRef<'tcx>> {
match self.match_impl(impl_def_id, obligation, snapshot) {
Ok(substs) => substs,
Err(()) => {
impl_def_id: DefId,
obligation: &TraitObligation<'tcx>,
snapshot: &CombinedSnapshot<'_, 'tcx>,
- ) -> Result<Normalized<'tcx, &'tcx Substs<'tcx>>, ()> {
+ ) -> Result<Normalized<'tcx, SubstsRef<'tcx>>, ()> {
let impl_trait_ref = self.tcx().impl_trait_ref(impl_def_id).unwrap();
// Before we create the substitutions and everything, first
recursion_depth: usize,
param_env: ty::ParamEnv<'tcx>,
def_id: DefId, // of impl or trait
- substs: &Substs<'tcx>, // for impl or trait
+ substs: SubstsRef<'tcx>, // for impl or trait
) -> Vec<PredicateObligation<'tcx>> {
debug!("impl_or_trait_obligations(def_id={:?})", def_id);
let tcx = self.tcx();