Skip to content

Commit 597a1c0

Browse files
committed
Undo some changes
1 parent 40e5b35 commit 597a1c0

File tree

2 files changed

+3
-55
lines changed

2 files changed

+3
-55
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -347,37 +347,6 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
347347
trace!("const eval: {:?} ({})", key, instance);
348348
}
349349

350-
if let ty::InstanceKind::Item(def_id) = key.value.instance.def
351-
&& matches!(tcx.def_kind(def_id), DefKind::Const | DefKind::AssocConst)
352-
{
353-
let ct = tcx.const_of_item(def_id).instantiate(tcx, key.value.instance.args);
354-
match ct.kind() {
355-
ty::ConstKind::Unevaluated(uv) => {
356-
assert_eq!(tcx.def_kind(uv.def), DefKind::AnonConst);
357-
358-
let id = GlobalId {
359-
instance: ty::Instance { def: ty::InstanceKind::Item(uv.def), args: uv.args },
360-
promoted: None,
361-
};
362-
return eval_in_interpreter(tcx, id, key.typing_env);
363-
}
364-
ty::ConstKind::Value(cv) => return Ok(tcx.valtree_to_const_alloc(cv)),
365-
ty::ConstKind::Error(guar) => {
366-
return Err(ErrorHandled::Reported(
367-
ReportedErrorInfo::const_eval_error(guar),
368-
DUMMY_SP,
369-
));
370-
}
371-
ty::ConstKind::Expr(_) => return Err(ErrorHandled::TooGeneric(DUMMY_SP)),
372-
ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(_) => {
373-
return Err(ErrorHandled::TooGeneric(DUMMY_SP));
374-
}
375-
ty::ConstKind::Infer(_) | ty::ConstKind::Bound(..) => {
376-
bug!("unexpected constant {ct:?}")
377-
}
378-
};
379-
}
380-
381350
eval_in_interpreter(tcx, key.value, key.typing_env)
382351
}
383352

compiler/rustc_ty_utils/src/instance.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use rustc_errors::ErrorGuaranteed;
2-
use rustc_hir::def::DefKind;
32
use rustc_hir::LangItem;
43
use rustc_hir::def_id::DefId;
54
use rustc_infer::infer::TyCtxtInferExt;
@@ -11,12 +10,11 @@ use rustc_middle::ty::{
1110
};
1211
use rustc_span::sym;
1312
use rustc_trait_selection::traits;
14-
use tracing::{debug, instrument};
13+
use tracing::debug;
1514
use traits::translate_args;
1615

1716
use crate::errors::UnexpectedFnPtrAssociatedItem;
1817

19-
#[instrument(level = "debug", skip(tcx), ret)]
2018
fn resolve_instance_raw<'tcx>(
2119
tcx: TyCtxt<'tcx>,
2220
key: ty::PseudoCanonicalInput<'tcx, (DefId, GenericArgsRef<'tcx>)>,
@@ -92,32 +90,13 @@ fn resolve_instance_raw<'tcx>(
9290
let ty = args.type_at(0);
9391
ty::InstanceKind::AsyncDropGlue(def_id, ty)
9492
} else {
95-
debug!(" => free or inherent item");
93+
debug!(" => free item");
9694
ty::InstanceKind::Item(def_id)
9795
};
9896

9997
Ok(Some(Instance { def, args }))
10098
};
101-
102-
if let Ok(Some(Instance { def: ty::InstanceKind::Item(def_id), args })) = result
103-
&& matches!(tcx.def_kind(def_id), DefKind::Const | DefKind::AssocConst)
104-
{
105-
debug!(" => resolved to const item");
106-
let ct = tcx.const_of_item(def_id).instantiate(tcx, args);
107-
debug!("ct={ct:?}");
108-
if let ty::ConstKind::Unevaluated(uv) = ct.kind() {
109-
if tcx.def_kind(uv.def) == DefKind::AnonConst {
110-
return Ok(Some(ty::Instance {
111-
def: ty::InstanceKind::Item(uv.def),
112-
args: uv.args,
113-
}));
114-
} else {
115-
let input = PseudoCanonicalInput { typing_env, value: (uv.def, uv.args) };
116-
return tcx.resolve_instance_raw(input);
117-
}
118-
}
119-
}
120-
99+
debug!("resolve_instance: result={:?}", result);
121100
result
122101
}
123102

0 commit comments

Comments
 (0)