Skip to content

Commit

Permalink
Inline a function that is only called once
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Sep 20, 2021
1 parent 5afeed0 commit 5fb1a65
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions compiler/rustc_trait_selection/src/opaque_types.rs
Expand Up @@ -961,6 +961,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
origin: hir::OpaqueTyOrigin,
) -> Ty<'tcx> {
let infcx = self.infcx;
let tcx = infcx.tcx;
let OpaqueTypeKey { def_id, substs } = opaque_type_key;

// Use the same type variable if the exact same opaque type appears more
Expand Down Expand Up @@ -992,15 +993,6 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
}

debug!("generated new type inference var {:?}", ty_var.kind());
self.compute_opaque_type_obligations(opaque_type_key);

ty_var
}

fn compute_opaque_type_obligations(&mut self, opaque_type_key: OpaqueTypeKey<'tcx>) {
let infcx = self.infcx;
let tcx = infcx.tcx;
let OpaqueTypeKey { def_id, substs } = opaque_type_key;

let item_bounds = tcx.explicit_item_bounds(def_id);
debug!(?item_bounds);
Expand All @@ -1021,7 +1013,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
if let ty::PredicateKind::Projection(projection) = predicate.kind().skip_binder() {
if projection.ty.references_error() {
// No point on adding these obligations since there's a type error involved.
return;
return ty_var;
}
}
}
Expand All @@ -1040,6 +1032,8 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
debug!("instantiate_opaque_types: predicate={:?}", predicate);
self.obligations.push(traits::Obligation::new(cause, self.param_env, predicate));
}

ty_var
}
}

Expand Down

0 comments on commit 5fb1a65

Please sign in to comment.