diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2023-03-08 17:59:06 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2023-03-14 10:20:35 -0300 |
| commit | a4e40370d018bf2a5c5a9713a7532638838f740d (patch) | |
| tree | 96cafca745c8db2ba910e4e9641bd484360f0e48 | |
| parent | b535da6841c8dec255a1734b9ac1ed9e9e7c5e25 (diff) | |
| download | rust-a4e40370d018bf2a5c5a9713a7532638838f740d.tar.gz rust-a4e40370d018bf2a5c5a9713a7532638838f740d.zip | |
Make fns from other crates with RPITIT work
| -rw-r--r-- | compiler/rustc_hir/src/definitions.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/assoc.rs | 6 | ||||
| -rw-r--r-- | tests/ui/impl-trait/in-trait/foreign.rs | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index 8ceb176491b..3c4fc9cb530 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -404,8 +404,12 @@ impl DefPathData { match *self { TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name), + // We use this name when collecting `ModChild`s. + // FIXME this could probably be removed with some refactoring to the name resolver. + ImplTraitAssocTy => Some(kw::Empty), + Impl | ForeignMod | CrateRoot | Use | GlobalAsm | ClosureExpr | Ctor | AnonConst - | ImplTrait | ImplTraitAssocTy => None, + | ImplTrait => None, } } diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 867974749d5..a2816124538 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -328,6 +328,9 @@ fn impl_associated_item_for_impl_trait_in_trait( // `opt_local_def_id_to_hir_id` with `None`. impl_assoc_ty.opt_local_def_id_to_hir_id(None); + // Copy span of the opaque. + impl_assoc_ty.def_ident_span(Some(span)); + impl_assoc_ty.associated_item(ty::AssocItem { name: kw::Empty, kind: ty::AssocKind::Type, @@ -342,6 +345,9 @@ fn impl_associated_item_for_impl_trait_in_trait( // extra predicates to assume. impl_assoc_ty.param_env(tcx.param_env(impl_fn_def_id)); + // Copy visility of the containing function. + impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id)); + // Copy impl_defaultness of the containing function. impl_assoc_ty.impl_defaultness(tcx.impl_defaultness(impl_fn_def_id)); diff --git a/tests/ui/impl-trait/in-trait/foreign.rs b/tests/ui/impl-trait/in-trait/foreign.rs index 6341f5b4284..df77372aabd 100644 --- a/tests/ui/impl-trait/in-trait/foreign.rs +++ b/tests/ui/impl-trait/in-trait/foreign.rs @@ -1,5 +1,7 @@ // check-pass // aux-build: rpitit.rs +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next extern crate rpitit; |
