Rollup merge of #131857 - WaffleLapkin:dyn-drop-principal-3, r=compiler-errors

Allow dropping dyn principal

Revival of #126660, which was a revival of #114679. Fixes #126313.

Allows dropping principal when coercing trait objects, e.g. `dyn Debug + Send` -> `dyn Send`.

cc `@compiler-errors` `@Jules-Bertholet`
r? `@lcnr`
This commit is contained in:
Matthias Krüger 2024-10-18 06:59:07 +02:00 committed by GitHub
commit 13b398401f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 167 additions and 35 deletions

View file

@ -785,7 +785,8 @@ where
let mut responses = vec![];
// If the principal def ids match (or are both none), then we're not doing
// trait upcasting. We're just removing auto traits (or shortening the lifetime).
if a_data.principal_def_id() == b_data.principal_def_id() {
let b_principal_def_id = b_data.principal_def_id();
if a_data.principal_def_id() == b_principal_def_id || b_principal_def_id.is_none() {
responses.extend(self.consider_builtin_upcast_to_principal(
goal,
CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),