File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
compiler/rustc_monomorphize/src Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -1326,6 +1326,21 @@ fn create_mono_items_for_default_impls<'tcx>(
13261326 return ;
13271327 }
13281328
1329+ // Unlike 'lazy' monomorphization that begins by collecting items transitively
1330+ // called by `main` or other global items, when eagerly monomorphizing impl
1331+ // items, we never actually check that the predicates of this impl are satisfied
1332+ // in a empty reveal-all param env (i.e. with no assumptions).
1333+ //
1334+ // Even though this impl has no substitutions, because we don't consider higher-
1335+ // ranked predicates such as `for<'a> &'a mut [u8]: Copy` to be trivially false,
1336+ // we must now check that the impl has no impossible-to-satisfy predicates.
1337+ if tcx. subst_and_check_impossible_predicates ( (
1338+ item. owner_id . to_def_id ( ) ,
1339+ & InternalSubsts :: identity_for_item ( tcx, item. owner_id . to_def_id ( ) ) ,
1340+ ) ) {
1341+ return ;
1342+ }
1343+
13291344 let Some ( trait_ref) = tcx. impl_trait_ref ( item. owner_id ) else {
13301345 return ;
13311346 } ;
Original file line number Diff line number Diff line change 1+ // compile-flags: -Clink-dead-code=on --crate-type=lib
2+ // build-pass
3+
4+ // Make sure that we don't monomorphize the impossible method `<() as Visit>::visit`,
5+ // which does not hold under a reveal-all param env.
6+
7+ pub trait Visit {
8+ fn visit ( ) { }
9+ }
10+
11+ pub trait Array < ' a > { }
12+
13+ impl Visit for ( ) where ( ) : for < ' a > Array < ' a > { }
You can’t perform that action at this time.
0 commit comments