Auto merge of #139000 - compiler-errors:rigid-missing-item, r=lcnr

Rigidly project missing item due to guaranteed impossible sized predicate

This is a somewhat involved change, but it amounts to treating missing impl items due to guaranteed impossible where clauses (dyn/str/slice sized, cc #135480) as *rigid projections* rather than projecting to an error term, since that was preventing either reporting a proper error (in an empty param env) *or* successfully type checking the code (in the presence of trivially false where clauses).

Fixes https://github.com/rust-lang/rust/issues/138970

r? `@lcnr` `@oli-obk`
This commit is contained in:
bors 2025-04-10 04:03:59 +00:00
commit 9d28fe3976
19 changed files with 524 additions and 91 deletions

View file

@ -1026,6 +1026,13 @@ rustc_queries! {
separate_provide_extern
}
/// Given an `impl_def_id`, return true if the self type is guaranteed to be unsized due
/// to either being one of the built-in unsized types (str/slice/dyn) or to be a struct
/// whose tail is one of those types.
query impl_self_is_guaranteed_unsized(impl_def_id: DefId) -> bool {
desc { |tcx| "computing whether `{}` has a guaranteed unsized self type", tcx.def_path_str(impl_def_id) }
}
/// Maps a `DefId` of a type to a list of its inherent impls.
/// Contains implementations of methods that are inherent to a type.
/// Methods in these implementations don't need to be exported.

View file

@ -437,6 +437,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
)
}
fn impl_self_is_guaranteed_unsized(self, impl_def_id: DefId) -> bool {
self.impl_self_is_guaranteed_unsized(impl_def_id)
}
fn has_target_features(self, def_id: DefId) -> bool {
!self.codegen_fn_attrs(def_id).target_features.is_empty()
}