about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-07-16 22:11:03 +0000
committerMichael Goulet <michael@errs.io>2023-07-25 15:15:25 +0000
commit24eefd08e25b8ffec2df092f0add812ed58875a0 (patch)
treebae3d7c004922f168bbe608b950ce74addd10174 /compiler/rustc_trait_selection
parent7e66c0b7edaf680f26c6170d81ce18869345046e (diff)
downloadrust-24eefd08e25b8ffec2df092f0add812ed58875a0.tar.gz
rust-24eefd08e25b8ffec2df092f0add812ed58875a0.zip
Make sure to detect trait upcasting coercion even after normalization
Diffstat (limited to 'compiler/rustc_trait_selection')
-rw-r--r--compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs
index 27d877b84dd..1cedbb6b761 100644
--- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs
+++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs
@@ -315,7 +315,13 @@ fn rematch_object<'tcx>(
     // If we're upcasting, get the offset of the vtable pointer, otherwise get
     // the base of the vtable.
     Ok(Some(if is_upcasting {
-        ImplSource::TraitUpcasting(ImplSourceTraitUpcastingData { vtable_vptr_slot, nested })
+        // If source and target trait def ids are identical,
+        // then we are simply removing auto traits.
+        if source_trait_ref.def_id() == target_trait_ref.def_id() {
+            ImplSource::Builtin(nested)
+        } else {
+            ImplSource::TraitUpcasting(ImplSourceTraitUpcastingData { vtable_vptr_slot, nested })
+        }
     } else {
         ImplSource::Object(ImplSourceObjectData { vtable_base, nested })
     }))