Skip to content

Commit b231749

Browse files
committed
Normalize in needs_drop_raw
This is limited to `Reveal::All` `ParamEnv`s because it's a performance regression otherwise.
1 parent e95280d commit b231749

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/librustc/ty/util.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -1122,8 +1122,26 @@ fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>
11221122

11231123
// Can refer to a type which may drop.
11241124
// FIXME(eddyb) check this against a ParamEnv.
1125-
ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) | ty::Bound(..) |
1126-
ty::Placeholder(..) | ty::Opaque(..) | ty::Infer(_) | ty::Error => true,
1125+
ty::Dynamic(..) |
1126+
ty::Param(_) |
1127+
ty::Bound(..) |
1128+
ty::Placeholder(..) |
1129+
ty::Opaque(..) |
1130+
ty::Infer(_) |
1131+
ty::Error => true,
1132+
1133+
ty::Projection(..) => {
1134+
if let traits::Reveal::All = param_env.reveal {
1135+
let normalized = tcx.normalize_erasing_regions(param_env, ty);
1136+
if let ty::Projection(..) = normalized.kind {
1137+
true
1138+
} else {
1139+
needs_drop(normalized)
1140+
}
1141+
} else {
1142+
true
1143+
}
1144+
}
11271145

11281146
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
11291147

0 commit comments

Comments
 (0)