3 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -1298,7 +1298,19 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
1298
1298
1299
1299
fn ty ( & mut self ) -> & mut Self {
1300
1300
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
+ // Ideally, we would normalize in all circumstances, but doing so
1305
+ // currently causes some unexpected type errors.
1306
+ let maybe_normalized_ty = if self . in_assoc_ty {
1307
+ let param_env = self . tcx . param_env ( self . item_def_id ) ;
1308
+ self . tcx . try_normalize_erasing_regions ( param_env, ty) . ok ( )
1309
+ } else {
1310
+ None
1311
+ } ;
1312
+
1313
+ self . visit ( maybe_normalized_ty. unwrap_or ( ty) ) ;
1302
1314
self
1303
1315
}
1304
1316
Original file line number Diff line number Diff line change @@ -17,8 +17,7 @@ mod m {
17
17
18
18
impl Trait4 for u8 {
19
19
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
22
21
}
23
22
}
24
23
Original file line number Diff line number Diff line change @@ -11,24 +11,15 @@ LL | struct Priv;
11
11
| ^^^^^^^^^^^
12
12
= note: `#[warn(private_interfaces)]` on by default
13
13
14
- error[E0446]: private associated type `Trait3::A ` in public interface
14
+ error[E0446]: private type `Priv ` in public interface
15
15
--> $DIR/projections2.rs:19:9
16
16
|
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
28
19
...
29
20
LL | type A<T: Trait> = <u8 as Trait3>::A<T>;
30
- | ^^^^^^^^^^^^^^^^ can't leak private trait
21
+ | ^^^^^^^^^^^^^^^^ can't leak private type
31
22
32
- error: aborting due to 2 previous errors ; 1 warning emitted
23
+ error: aborting due to 1 previous error ; 1 warning emitted
33
24
34
25
For more information about this error, try `rustc --explain E0446`.
0 commit comments