-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
infer outlives doesn't work across crates #51858
Comments
Going to run the error scenario locally to better debug the issue. |
OK I think I see the problem. First, to explain what I expect to happen:When we are inferred the outlives for How to fixI believe the problem is centered on this line:
In particular, this is part of the function that handles the case where we see a reference to a struct lke I think what we want is to rework the "explicit predicates map" setup. Currently, we do a kind of pre-pass that populates this map: rust/src/librustc_typeck/outlives/mod.rs Line 95 in a385095
I think we should populate the map lazilly instead. I would think it should be a type: crate struct ExplicitPredicatesMap<'tcx> {
map: FxHashMap<DefId, RequiredPredicates<'tcx>>
} The map would publish one method: impl ExplicitPredicatesMap<'tcx> {
crate fn explicit_predicates_of(&mut self, tcx: TyCtxt<'_, '_, 'tcx>, def_id: DefId) -> &RequiredPredicates<'tcx> {
self.map.entry(def_id).or_insert_with(|| {
let predicates = if def_id.is_local() {
tcx.explicit_predicates_of(def_id)
} else {
tcx.predicates_of(def_id)
};
let required_predicates = {
// process predicates and convert to `RequiredPredicates` entry, see below
};
required_predicates
}
}
} The "processing comment" would basically be doing the same as this existing code, which filters down rust/src/librustc_typeck/outlives/explicit.rs Lines 51 to 76 in a385095
|
Fix: infer outlives requirements across crates Fixes #51858
This example fails to compile:
however this purely intra-crate example works:
cc @toidiu
The text was updated successfully, but these errors were encountered: