Instance::resolve -> Instance::try_resolve, and other nits

This commit is contained in:
Michael Goulet 2024-07-02 15:55:17 -04:00
parent 3273ccea4b
commit b1059ccda2
22 changed files with 44 additions and 27 deletions

View file

@ -103,7 +103,7 @@ fn extract_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<
let args = cx.typeck_results().node_args(expr.hir_id);
// If we could not resolve the method, don't apply the lint
let Ok(Some(resolved_method)) = Instance::resolve(cx.tcx, cx.param_env, fn_def_id, args) else {
let Ok(Some(resolved_method)) = Instance::try_resolve(cx.tcx, cx.param_env, fn_def_id, args) else {
return None;
};
if is_trait_method(cx, expr, sym::Clone) && path.ident.name == sym::clone {
@ -119,7 +119,7 @@ fn extract_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<
// If we could not resolve the method, don't apply the lint
let Ok(Some(resolved_method)) = (match kind {
ty::FnDef(_, args) => Instance::resolve(cx.tcx, cx.param_env, fn_def_id, args),
ty::FnDef(_, args) => Instance::try_resolve(cx.tcx, cx.param_env, fn_def_id, args),
_ => Ok(None),
}) else {
return None;

View file

@ -293,7 +293,7 @@ impl<'tcx> NonCopyConst<'tcx> {
ct: ty::UnevaluatedConst<'tcx>,
span: Span,
) -> EvalToValTreeResult<'tcx> {
match ty::Instance::resolve(tcx, param_env, ct.def, ct.args) {
match ty::Instance::try_resolve(tcx, param_env, ct.def, ct.args) {
Ok(Some(instance)) => {
let cid = GlobalId {
instance,

View file

@ -375,7 +375,7 @@ pub fn create_ecx<'tcx>(
});
let main_ret_ty = tcx.fn_sig(entry_id).no_bound_vars().unwrap().output();
let main_ret_ty = main_ret_ty.no_bound_vars().unwrap();
let start_instance = ty::Instance::resolve(
let start_instance = ty::Instance::try_resolve(
tcx,
ty::ParamEnv::reveal_all(),
start_id,