fix for late-bound regions
This commit is contained in:
parent
e5284b0b57
commit
3860eabbb6
@ -12,7 +12,7 @@ use rustc::hir;
|
||||
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;
|
||||
@ -208,14 +208,26 @@ fn insert_required_predicates_to_be_wf<'tcx>(
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,7 @@ fn inferred_outlives_of<'a, 'tcx>(
|
||||
ty::Predicate::TypeOutlives(p) => p.to_string(),
|
||||
|
||||
err => bug!("unexpected predicate {:?}", err),
|
||||
})
|
||||
.collect();
|
||||
}).collect();
|
||||
pred.sort();
|
||||
|
||||
let span = tcx.def_span(item_def_id);
|
||||
@ -117,11 +116,9 @@ fn inferred_outlives_crate<'tcx>(
|
||||
ty::Binder::bind(ty::OutlivesPredicate(region1, region2)),
|
||||
),
|
||||
},
|
||||
)
|
||||
.collect();
|
||||
).collect();
|
||||
(def_id, Lrc::new(vec))
|
||||
})
|
||||
.collect();
|
||||
}).collect();
|
||||
|
||||
let empty_predicate = Lrc::new(Vec::new());
|
||||
|
||||
|
21
src/test/ui/issue-53419.rs
Normal file
21
src/test/ui/issue-53419.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// 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() {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user