File tree 4 files changed +60
-4
lines changed
4 files changed +60
-4
lines changed Original file line number Diff line number Diff line change @@ -788,10 +788,14 @@ impl<'tcx> ty::TyS<'tcx> {
788
788
[ component_ty] => component_ty,
789
789
_ => self ,
790
790
} ;
791
+
791
792
// This doesn't depend on regions, so try to minimize distinct
792
793
// query keys used.
793
- let erased = tcx. normalize_erasing_regions ( param_env, query_ty) ;
794
- tcx. needs_drop_raw ( param_env. and ( erased) )
794
+ // If normalization fails, we just use `query_ty`.
795
+ let query_ty =
796
+ tcx. try_normalize_erasing_regions ( param_env, query_ty) . unwrap_or ( query_ty) ;
797
+
798
+ tcx. needs_drop_raw ( param_env. and ( query_ty) )
795
799
}
796
800
}
797
801
}
Original file line number Diff line number Diff line change @@ -147,8 +147,10 @@ where
147
147
Ok ( tys) => tys,
148
148
} ;
149
149
for required_ty in tys {
150
- let required =
151
- tcx. normalize_erasing_regions ( self . param_env , required_ty) ;
150
+ let required = tcx
151
+ . try_normalize_erasing_regions ( self . param_env , required_ty)
152
+ . unwrap_or ( required_ty) ;
153
+
152
154
queue_type ( self , required) ;
153
155
}
154
156
}
Original file line number Diff line number Diff line change
1
+ #[ repr( C ) ]
2
+ union PtrRepr < T : ?Sized > {
3
+ const_ptr : * const T ,
4
+ mut_ptr : * mut T ,
5
+ components : PtrComponents < T > ,
6
+ //~^ ERROR the trait bound
7
+ }
8
+
9
+ #[ repr( C ) ]
10
+ struct PtrComponents < T : Pointee + ?Sized > {
11
+ data_address : * const ( ) ,
12
+ metadata : <T as Pointee >:: Metadata ,
13
+ }
14
+
15
+
16
+
17
+ pub trait Pointee {
18
+ type Metadata ;
19
+ }
20
+
21
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `T: Pointee` is not satisfied in `PtrComponents<T>`
2
+ --> $DIR/issue-81199.rs:5:17
3
+ |
4
+ LL | components: PtrComponents<T>,
5
+ | ^^^^^^^^^^^^^^^^ within `PtrComponents<T>`, the trait `Pointee` is not implemented for `T`
6
+ |
7
+ note: required because it appears within the type `PtrComponents<T>`
8
+ --> $DIR/issue-81199.rs:10:8
9
+ |
10
+ LL | struct PtrComponents<T: Pointee + ?Sized> {
11
+ | ^^^^^^^^^^^^^
12
+ = note: no field of a union may have a dynamically sized type
13
+ = help: change the field's type to have a statically known size
14
+ help: consider further restricting this bound
15
+ |
16
+ LL | union PtrRepr<T: ?Sized + Pointee> {
17
+ | +++++++++
18
+ help: borrowed types always have a statically known size
19
+ |
20
+ LL | components: &PtrComponents<T>,
21
+ | +
22
+ help: the `Box` type always has a statically known size and allocates its contents in the heap
23
+ |
24
+ LL | components: Box<PtrComponents<T>>,
25
+ | ++++ +
26
+
27
+ error: aborting due to previous error
28
+
29
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments