mirror of https://github.com/rust-lang/rust.git
Auto merge of #122891 - compiler-errors:encode-implied-predicates-always, r=oli-obk
Encode implied predicates for traits In #112629, we decided to make associated type bounds in the "supertrait" AST position *implied* even though they're not supertraits themselves. This means that the `super_predicates` and `implied_predicates` queries now differ for regular traits. The assumption that they didn't differ was hard-coded in #107614, so in cross-crate positions this means that we forget the implied predicates from associated type bounds. This isn't unsound, just kind of annoying. This should be backported since associated type bounds are slated to stabilize for 1.78 -- either that, or associated type bounds can be reverted on beta and re-shipped in 1.79 with this patch. Fixes #122859
This commit is contained in:
commit
6a92312a1e
|
@ -211,6 +211,7 @@ provide! { tcx, def_id, other, cdata,
|
|||
generics_of => { table }
|
||||
inferred_outlives_of => { table_defaulted_array }
|
||||
super_predicates_of => { table }
|
||||
implied_predicates_of => { table }
|
||||
type_of => { table }
|
||||
type_alias_is_lazy => { cdata.root.tables.type_alias_is_lazy.get(cdata, def_id.index) }
|
||||
variances_of => { table }
|
||||
|
@ -276,18 +277,6 @@ provide! { tcx, def_id, other, cdata,
|
|||
.map(|lazy| lazy.decode((cdata, tcx)))
|
||||
.process_decoded(tcx, || panic!("{def_id:?} does not have trait_impl_trait_tys")))
|
||||
}
|
||||
implied_predicates_of => {
|
||||
cdata
|
||||
.root
|
||||
.tables
|
||||
.implied_predicates_of
|
||||
.get(cdata, def_id.index)
|
||||
.map(|lazy| lazy.decode((cdata, tcx)))
|
||||
.unwrap_or_else(|| {
|
||||
debug_assert_eq!(tcx.def_kind(def_id), DefKind::Trait);
|
||||
tcx.super_predicates_of(def_id)
|
||||
})
|
||||
}
|
||||
|
||||
associated_types_for_impl_traits_in_associated_fn => { table_defaulted_array }
|
||||
|
||||
|
|
|
@ -1435,6 +1435,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
if let DefKind::Trait = def_kind {
|
||||
record!(self.tables.trait_def[def_id] <- self.tcx.trait_def(def_id));
|
||||
record!(self.tables.super_predicates_of[def_id] <- self.tcx.super_predicates_of(def_id));
|
||||
record!(self.tables.implied_predicates_of[def_id] <- self.tcx.implied_predicates_of(def_id));
|
||||
|
||||
let module_children = self.tcx.module_children_local(local_id);
|
||||
record_array!(self.tables.module_children_non_reexports[def_id] <-
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
pub trait Bar: Super<SuperAssoc: Bound> {}
|
||||
|
||||
pub trait Super {
|
||||
type SuperAssoc;
|
||||
}
|
||||
|
||||
pub trait Bound {}
|
|
@ -0,0 +1,9 @@
|
|||
//@ aux-build:implied-predicates.rs
|
||||
//@ check-pass
|
||||
|
||||
extern crate implied_predicates;
|
||||
use implied_predicates::Bar;
|
||||
|
||||
fn bar<B: Bar>() {}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue