Skip to content

Commit

Permalink
Normalize in needs_drop_raw
Browse files Browse the repository at this point in the history
This is limited to `Reveal::All` `ParamEnv`s because it's a performance
regression otherwise.
  • Loading branch information
matthewjasper committed Dec 21, 2019
1 parent e95280d commit b231749
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/librustc/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,8 +1122,26 @@ fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>

// Can refer to a type which may drop.
// FIXME(eddyb) check this against a ParamEnv.
ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) | ty::Bound(..) |
ty::Placeholder(..) | ty::Opaque(..) | ty::Infer(_) | ty::Error => true,
ty::Dynamic(..) |
ty::Param(_) |
ty::Bound(..) |
ty::Placeholder(..) |
ty::Opaque(..) |
ty::Infer(_) |
ty::Error => true,

ty::Projection(..) => {
if let traits::Reveal::All = param_env.reveal {
let normalized = tcx.normalize_erasing_regions(param_env, ty);
if let ty::Projection(..) = normalized.kind {
true
} else {
needs_drop(normalized)
}
} else {
true
}
}

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

Expand Down

0 comments on commit b231749

Please sign in to comment.