File tree Expand file tree Collapse file tree 3 files changed +19
-17
lines changed
compiler/rustc_privacy/src Expand file tree Collapse file tree 3 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -1302,7 +1302,19 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
13021302
13031303 fn ty ( & mut self ) -> & mut Self {
13041304 self . in_primary_interface = true ;
1305- self . visit ( self . tcx . type_of ( self . item_def_id ) . instantiate_identity ( ) ) ;
1305+ let ty = self . tcx . type_of ( self . item_def_id ) . instantiate_identity ( ) ;
1306+
1307+ // If `in_assoc_ty`, attempt to normalize `ty`.
1308+ // Ideally, we would normalize in all circumstances, but doing so
1309+ // currently causes some unexpected type errors.
1310+ let maybe_normalized_ty = if self . in_assoc_ty {
1311+ let param_env = self . tcx . param_env ( self . item_def_id ) ;
1312+ self . tcx . try_normalize_erasing_regions ( param_env, ty) . ok ( )
1313+ } else {
1314+ None
1315+ } ;
1316+
1317+ self . visit ( maybe_normalized_ty. unwrap_or ( ty) ) ;
13061318 self
13071319 }
13081320
Original file line number Diff line number Diff line change @@ -17,8 +17,7 @@ mod m {
1717
1818 impl Trait4 for u8 {
1919 type A < T : Trait > = <u8 as Trait3 >:: A < T > ;
20- //~^ ERROR: private associated type `Trait3::A` in public interface
21- //~| ERROR: private trait `Trait3` in public interface
20+ //~^ ERROR: private type `Priv` in public interface
2221 }
2322}
2423
Original file line number Diff line number Diff line change @@ -11,24 +11,15 @@ LL | struct Priv;
1111 | ^^^^^^^^^^^
1212 = note: `#[warn(private_interfaces)]` on by default
1313
14- error[E0446]: private associated type `Trait3::A ` in public interface
14+ error[E0446]: private type `Priv ` in public interface
1515 --> $DIR/projections2.rs:19:9
1616 |
17- LL | type A<T: Trait>;
18- | ---------------- `Trait3::A` declared as private
19- ...
20- LL | type A<T: Trait> = <u8 as Trait3>::A<T>;
21- | ^^^^^^^^^^^^^^^^ can't leak private associated type
22-
23- error[E0446]: private trait `Trait3` in public interface
24- --> $DIR/projections2.rs:19:9
25- |
26- LL | trait Trait3 {
27- | ------------ `Trait3` declared as private
17+ LL | struct Priv;
18+ | ----------- `Priv` declared as private
2819...
2920LL | type A<T: Trait> = <u8 as Trait3>::A<T>;
30- | ^^^^^^^^^^^^^^^^ can't leak private trait
21+ | ^^^^^^^^^^^^^^^^ can't leak private type
3122
32- error: aborting due to 2 previous errors ; 1 warning emitted
23+ error: aborting due to 1 previous error ; 1 warning emitted
3324
3425For more information about this error, try `rustc --explain E0446`.
You can’t perform that action at this time.
0 commit comments