Always encode implied_predicates query for traits

With associated type bounds enabled, the implied_predicates and super_predicates
queries may differ for traits, since associated type bounds are also
implied but are not counted as super predicates.
This commit is contained in:
Michael Goulet 2024-03-22 13:13:40 -04:00
parent c855bf62d7
commit 3361488681
4 changed files with 3 additions and 31 deletions

View File

@ -211,6 +211,7 @@ fn into_args(self) -> (DefId, SimplifiedType) {
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 @@ fn into_args(self) -> (DefId, SimplifiedType) {
.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 }

View File

@ -1435,6 +1435,7 @@ fn encode_def_ids(&mut self) {
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] <-

View File

@ -1,4 +1,5 @@
//@ aux-build:implied-predicates.rs
//@ check-pass
extern crate implied_predicates;
use implied_predicates::Bar;

View File

@ -1,19 +0,0 @@
error[E0277]: the trait bound `<B as Super>::SuperAssoc: implied_predicates::Bound` is not satisfied
--> $DIR/implied-predicates.rs:6:11
|
LL | fn bar<B: Bar>() {}
| ^^^ the trait `implied_predicates::Bound` is not implemented for `<B as Super>::SuperAssoc`
|
note: required by a bound in `Bar`
--> $DIR/auxiliary/implied-predicates.rs:1:34
|
LL | pub trait Bar: Super<SuperAssoc: Bound> {}
| ^^^^^ required by this bound in `Bar`
help: consider further restricting the associated type
|
LL | fn bar<B: Bar>() where <B as Super>::SuperAssoc: implied_predicates::Bound {}
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.