Skip to content

Commit

Permalink
Rollup merge of #113165 - compiler-errors:rpitits-foreign-bounds, r=s…
Browse files Browse the repository at this point in the history
…pastorino

Encode item bounds for `DefKind::ImplTraitPlaceholder`

This was lost in a refactoring -- `hir::ItemKind::OpaqueTy` doesn't always map to `DefKind::Opaque`, specifically for RPITITs, so the check was migrated subtly wrong, and unfortunately I never had a test for this 🙃

Fixes #113155

r? ``@cjgillot``
  • Loading branch information
matthiaskrgr authored Jun 30, 2023
2 parents 0b96b25 + 0506250 commit c8f50ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
.is_type_alias_impl_trait
.set(def_id.index, self.tcx.is_type_alias_impl_trait(def_id));
}
if let DefKind::ImplTraitPlaceholder = def_kind {
self.encode_explicit_item_bounds(def_id);
}
if tcx.impl_method_has_trait_impl_trait_tys(def_id)
&& let Ok(table) = self.tcx.collect_return_position_impl_trait_in_trait_tys(def_id)
{
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/impl-trait/in-trait/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ impl Foo for Local {
fn bar(self) -> Arc<String> { Arc::new(String::new()) }
}

fn generic(f: impl Foo) {
let x = &*f.bar();
}

fn main() {
// Witness an RPITIT from another crate.
let &() = Foreign.bar();
Expand Down

0 comments on commit c8f50ee

Please sign in to comment.