use rustc::hir::def_id::DefId;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::ty::subst::{Kind, Subst, UnpackedKind};
-use rustc::ty::{self, Ty, TyCtxt};
+use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc::util::nodemap::FxHashMap;
use super::explicit::ExplicitPredicatesMap;
debug!("field_ty = {}", &field_ty);
debug!("ty in field = {}", &ty);
if let Some(ex_trait_ref) = obj.principal() {
- check_explicit_predicates(
- tcx,
- &ex_trait_ref.skip_binder().def_id,
- ex_trait_ref.with_self_ty(tcx, ty).skip_binder().substs,
- required_predicates,
- explicit_map,
- true,
- );
+ // The method `has_escaping_regions` checks if
+ // there are any late-bound regions, which is
+ // the lifetime `'r`. It is safe to ignore
+ // these since `'r` is not in scope for `Foo`.
+ //
+ // ```
+ // struct Foo {
+ // bar: for<'r> Fn(usize, &'r FnMut())
+ // }
+ // ```
+ if !ty.has_escaping_regions() {
+ check_explicit_predicates(
+ tcx,
+ &ex_trait_ref.skip_binder().def_id,
+ ex_trait_ref.with_self_ty(tcx, ty).skip_binder().substs,
+ required_predicates,
+ explicit_map,
+ true,
+ );
+ }
}
}
ty::Predicate::TypeOutlives(p) => p.to_string(),
err => bug!("unexpected predicate {:?}", err),
- })
- .collect();
+ }).collect();
pred.sort();
let span = tcx.def_span(item_def_id);
ty::Binder::bind(ty::OutlivesPredicate(region1, region2)),
),
},
- )
- .collect();
+ ).collect();
(def_id, Lrc::new(vec))
- })
- .collect();
+ }).collect();
let empty_predicate = Lrc::new(Vec::new());
--- /dev/null
+// Copyright 2012 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.
+
+//compile-pass
+
+#![feature(infer_outlives_requirements)]
+
+struct Foo {
+ bar: for<'r> Fn(usize, &'r FnMut())
+}
+
+fn main() {
+}
+