Rollup merge of #98496 - BoxyUwU:instancers_bad_equality, r=lcnr
make `compare_const_impl` a query and use it in `instance.rs` Fixes #88365 the bug in #88365 was caused by some `instance.rs` code using the `PartialEq` impl on `Ty` to check that the type of the associated const in an impl is the same as the type of the associated const in the trait definition. This was wrong for two reasons: - the check typeck does is that the impl type is a subtype of the trait definition's type (see `mismatched_impl_ty_2.rs` which [was ICEing](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f6d60ebe6745011f0d52ab2bc712025d) before this PR on stable) - it assumes that if two types are equal then the `PartialEq` impl will reflect that which isnt true for higher ranked types or type level constants when `feature(generic_const_exprs)` is enabled (see `mismatched_impl_ty_3.rs` for higher ranked types which was [ICEing on stable](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d7af131a655ed515b035624626c62c71)) r? `@lcnr`
This commit is contained in:
@@ -2105,4 +2105,10 @@ rustc_queries! {
|
||||
query permits_zero_init(key: TyAndLayout<'tcx>) -> bool {
|
||||
desc { "checking to see if {:?} permits being left zeroed", key.ty }
|
||||
}
|
||||
|
||||
query compare_assoc_const_impl_item_with_trait_item(
|
||||
key: (LocalDefId, DefId)
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
desc { |tcx| "checking assoc const `{}` has the same type as trait item", tcx.def_path_str(key.0.to_def_id()) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user