File tree Expand file tree Collapse file tree 3 files changed +17
-17
lines changed
compiler/rustc_privacy/src Expand file tree Collapse file tree 3 files changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -1298,7 +1298,17 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
12981298
12991299 fn ty ( & mut self ) -> & mut Self {
13001300 self . in_primary_interface = true ;
1301- self . visit ( self . tcx . type_of ( self . item_def_id ) . instantiate_identity ( ) ) ;
1301+ let ty = self . tcx . type_of ( self . item_def_id ) . instantiate_identity ( ) ;
1302+
1303+ // if `in_assoc_ty`, attempt to normalize `ty`
1304+ let maybe_normalized_ty = if self . in_assoc_ty {
1305+ let param_env = self . tcx . param_env ( self . item_def_id ) ;
1306+ self . tcx . try_normalize_erasing_regions ( param_env, ty) . ok ( )
1307+ } else {
1308+ None
1309+ } ;
1310+
1311+ self . visit ( maybe_normalized_ty. unwrap_or ( ty) ) ;
13021312 self
13031313 }
13041314
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