Skip to content

Commit a4e4037

Browse files
committed
Make fns from other crates with RPITIT work
1 parent b535da6 commit a4e4037

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

compiler/rustc_hir/src/definitions.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,12 @@ impl DefPathData {
404404
match *self {
405405
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
406406

407+
// We use this name when collecting `ModChild`s.
408+
// FIXME this could probably be removed with some refactoring to the name resolver.
409+
ImplTraitAssocTy => Some(kw::Empty),
410+
407411
Impl | ForeignMod | CrateRoot | Use | GlobalAsm | ClosureExpr | Ctor | AnonConst
408-
| ImplTrait | ImplTraitAssocTy => None,
412+
| ImplTrait => None,
409413
}
410414
}
411415

compiler/rustc_ty_utils/src/assoc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ fn impl_associated_item_for_impl_trait_in_trait(
328328
// `opt_local_def_id_to_hir_id` with `None`.
329329
impl_assoc_ty.opt_local_def_id_to_hir_id(None);
330330

331+
// Copy span of the opaque.
332+
impl_assoc_ty.def_ident_span(Some(span));
333+
331334
impl_assoc_ty.associated_item(ty::AssocItem {
332335
name: kw::Empty,
333336
kind: ty::AssocKind::Type,
@@ -342,6 +345,9 @@ fn impl_associated_item_for_impl_trait_in_trait(
342345
// extra predicates to assume.
343346
impl_assoc_ty.param_env(tcx.param_env(impl_fn_def_id));
344347

348+
// Copy visility of the containing function.
349+
impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id));
350+
345351
// Copy impl_defaultness of the containing function.
346352
impl_assoc_ty.impl_defaultness(tcx.impl_defaultness(impl_fn_def_id));
347353

tests/ui/impl-trait/in-trait/foreign.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// check-pass
22
// aux-build: rpitit.rs
3+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
4+
// revisions: current next
35

46
extern crate rpitit;
57

0 commit comments

Comments
 (0)